Skip to content

Surgical Changes principle

The Surgical Changes principle is a discipline for code modification that prioritizes precision, focus, and minimal impact over comprehensive refactoring^[001-TODO__Andrej_Karpathy_Skills_-_AI_Coding_Agent_行为框架.md].

It is a core component of the Andrej Karpathy Skills behavioral framework, designed to prevent AI coding agents (and developers) from introducing instability by making unnecessary or overly broad changes^[001-TODO__Andrej_Karpathy_Skills_-_AI_Coding_Agent_行为框架.md].

Core Principles

Adhering to the Surgical Changes principle means strictly limiting the scope of modifications to only what is required to address the immediate task^[001-TODO__Andrej_Karpathy_Skills_-_AI_Coding_Agent_行为框架.md].

  • Strict Relevance: Only touch code that is directly related to the task at hand^[001-TODO__Andrej_Karpathy_Skills_-_AI_Coding_Agent_行为框架.md].
  • Preserve Context: Do not clean up unrelated code, rewrite existing comments, or refactor adjacent functions that are not part of the requirements^[001-TODO__Andrej_Karpathy_Skills_-_AI_Coding_Agent_行为框架.md].
  • No Improvisation: Avoid implementing improvements or optimizations that fall outside the defined scope of the current assignment^[001-TODO__Andrej_Karpathy_Skills_-_AI_Coding_Agent_行为框架.md].

Benefits

Applying the Surgical Changes principle results in changes that are easier to review and safer to merge^[001-TODO__Andrej_Karpathy_Skills_-AI_Coding_Agent_行为框架.md]. By producing small, focused diffs, it prevents "good idea" refactoring from creeping into the workstream, ensuring that the system's stability is not compromised by speculative changes^[001-TODO__Andrej_Karpathy_Skills-_AI_Coding_Agent_行为框架.md].

  • [[Simplicity First]]
  • [[Think Before Coding]]
  • [[Scope Creep]]
  • [[Code Refactoring]]

Sources

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