Skip to content

Think Before Coding principle

Think Before Coding is a behavioral principle for AI coding agents that emphasizes clarifying requirements and reasoning about trade-offs before generating code^[001-TODO__Andrej_Karpathy_Skills_-AI_Coding_Agent_行为框架.md]. It is part of a broader framework designed to make agents behave more like cautious engineers and less like over-conficient writers^[001-TODO__Andrej_Karpathy_Skills-_AI_Coding_Agent_行为框架.md].

The principle operates on the core philosophy that reliability in software development comes from disciplined workflows rather than increased raw intelligence or feature set^[001-TODO__Andrej_Karpathy_Skills_-AI_Coding_Agent_行为框架.md]. Instead of blindly guessing user intent or immediately generating solutions based on assumptions, an agent following this principle pauses to validate understanding^[001-TODO__Andrej_Karpathy_Skills-_AI_Coding_Agent_行为框架.md].

Key Behaviors

When applying the Think Before Coding principle, an agent exhibits the following behaviors when facing a task or request^[001-TODO__Andrej_Karpathy_Skills_-_AI_Coding_Agent_行为框架.md]:

  • Exposing Ambiguities: The agent actively identifies parts of the requirements that are unclear or incomplete.
  • Asking Clarifying Questions: Rather than guessing, the agent queries the user for specific details (e.g., subscription vs. one-time payment, specific providers to use, or the scope of a Minimum Viable Product).
  • Presenting Trade-offs: The agent outlines the pros and cons of different technical approaches instead of arbitrarily choosing one and starting to code immediately.

Impact on Workflow

Adopting this principle changes the execution pattern from direct implementation to a verification-first approach^[001-TODO__Andrej_Karpathy_Skills_-AI_Coding_Agent_行为框架.md]. For example, when asked to "add a billing dashboard," a disciplined agent will first clarify the scope (full-featured vs. read-only summary), define the payment model, and agree on the minimal viable version before writing a single line of code^[001-TODO__Andrej_Karpathy_Skills-_AI_Coding_Agent_行为框架.md].

This leads to smaller, focused code changes (diffs) and prevents the common failure mode where an agent generates a large amount of unnecessary or incorrect infrastructure based on a misinterpretation of the goal^[001-TODO__Andrej_Karpathy_Skills_-_AI_Coding_Agent_行为框架.md].

  • [[Simplicity First]]
  • [[Surgical Changes]]
  • [[Goal-Driven Execution]]

Sources

  • 001-TODO__Andrej_Karpathy_Skills_-_AI_Coding_Agent_行为框架.md