AI coding agent behavior patterns¶
AI coding agent behavior patterns refer to the strategic frameworks and constraints applied to Large Language Models (LLMs) to ensure they function as reliable software engineering assistants rather than overconfident text generators^[001-TODO__Andrej_Karpathy_Skills_-_AI_Coding_Agent_行为框架.md].
The core philosophy behind these patterns is that reliability comes from workflow discipline, not just model intelligence^[001-TODO__Andrej_Karpathy_Skills_-_AI_Coding_Agent_行为框架.md].
核心模式 (Core Patterns)¶
These patterns are designed to mitigate common failure modes such as hallucination, unnecessary refactoring, and vague execution^[001-TODO__Andrej_Karpathy_Skills_-_AI_Coding_Agent_行为框架.md].
Think Before Coding¶
AI agents should not blindly guess user intent. Instead of acting on ambiguous requirements, the agent should: - Expose ambiguities by asking clarifying questions^[001-TODO__Andrej_Karpathy_Skills_-AI_Coding_Agent_行为框架.md]. - Present trade-offs to the user rather than making assumptions^[001-TODO__Andrej_Karpathy_Skills-_AI_Coding_Agent_行为框架.md].
Simplicity First¶
Agents should write the minimum amount of code necessary to solve the specific problem^[001-TODO__Andrej_Karpathy_Skills_-AI_Coding_Agent_行为框架.md]. Negative behaviors to avoid include: - Speculative abstraction (adding structure for hypothetical future needs)^[001-TODO__Andrej_Karpathy_Skills-AI_Coding_Agent_行为框架.md]. - Over-engineering frameworks for simple function-level tasks^[001-TODO__Andrej_Karpathy_Skills-_AI_Coding_Agent_行为框架.md].
Surgical Changes¶
To maintain codebase stability and reviewability, agents should modify only what is strictly required^[001-TODO__Andrej_Karpathy_Skills_-AI_Coding_Agent_行为框架.md]. This pattern prohibits: - Refactoring adjacent or unrelated functions^[001-TODO__Andrej_Karpathy_Skills-AI_Coding_Agent_行为框架.md]. - Cleaning up unrelated code or comments outside the task scope^[001-TODO__Andrej_Karpathy_Skills-_AI_Coding_Agent_行为框架.md].
Goal-Driven Execution¶
This pattern focuses on verification rather than just completion^[001-TODO__Andrej_Karpathy_Skills_-AI_Coding_Agent_行为框架.md]. The workflow typically follows: 1. Reproduce the issue or requirement. 2. Implement the fix. 3. Verify the result against a success standard^[001-TODO__Andrej_Karpathy_Skills-_AI_Coding_Agent_行为框架.md].
Comparison of Behaviors¶
The following table illustrates the shift in agent behavior when these patterns are applied^[001-TODO__Andrej_Karpathy_Skills_-_AI_Coding_Agent_行为框架.md]:
| Scenario | Unguided Behavior | Guided Behavior |
|---|---|---|
| Clarification | Starts coding immediately based on assumptions. | Asquires about scope (e.g., one-time vs. subscription, MVP vs. full feature). |
| Scope of Change | Produces massive, hard-to-review diffs. | Produces small, focused diffs. |
| Refactoring | Randomly refactors adjacent files. | Modifies only necessary files. |
| Completion | Stops after saying "I implemented it". | Stops only after explicit verification that the fix works. |
驗證指標 (Success Indicators)¶
When these behavior patterns are effectively integrated into an agent's workflow, users should observe the following: - Improved Inquiry: The agent asks better clarifying questions up front^[001-TODO__Andrej_Karpathy_Skills_-AI_Coding_Agent_行为框架.md]. - Reduced Scope: Diffs become smaller and more focused^[001-TODO__Andrej_Karpathy_Skills-AI_Coding_Agent_行为框架.md]. - Discipline: The agent stops "cleaning up" unrelated code^[001-TODO__Andrej_Karpathy_Skills-AI_Coding_Agent_行为框架.md]. - Verification: The agent shifts from an "implementation mindset" to a "verification mindset"^[001-TODO__Andrej_Karpathy_Skills-_AI_Coding_Agent_行为框架.md].
相關連結¶
- [[提示工程]]
- [[整合開發環境]]
- [[軟體框架]]
Sources¶
001-TODO__Andrej_Karpathy_Skills_-_AI_Coding_Agent_行为框架.md