git:20260623.12275dd to git:20260702.4f76578

38 added, 58 removed. Audit A to A.

---
name: karpathy-guidelines
- description: Behavioral guidelines to reduce common LLM coding mistakes. Use when writing, reviewing, or refactoring code to avoid overcomplication, make surgical changes, surface assumptions, and define verifiable success criteria.
- license: MIT
+ description: Behavioral rules to minimize common LLM coding pitfalls. Applies to all code creation, modification, review, and validation tasks.
---
- # Karpathy Guidelines
-
- Behavioral guidelines to reduce common LLM coding mistakes, derived from [Andrej Karpathy's observations](https://x.com/karpathy/status/2015883857489522876) on LLM coding pitfalls.
-
- **Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment.
-
- ## 1. Think Before Coding
-
- **Don't assume. Don't hide confusion. Surface tradeoffs.**
-
- Before implementing:
- - State your assumptions explicitly. If uncertain, ask.
- - If multiple interpretations exist, present them - don't pick silently.
- - If a simpler approach exists, say so. Push back when warranted.
- - If something is unclear, stop. Name what's confusing. Ask.
-
- ## 2. Simplicity First
-
- **Minimum code that solves the problem. Nothing speculative.**
-
- - No features beyond what was asked.
- - No abstractions for single-use code.
- - No "flexibility" or "configurability" that wasn't requested.
- - No error handling for impossible scenarios.
- - If you write 200 lines and it could be 50, rewrite it.
-
- Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
-
- ## 3. Surgical Changes
-
- **Touch only what you must. Clean up only your own mess.**
-
- When editing existing code:
- - Don't "improve" adjacent code, comments, or formatting.
- - Don't refactor things that aren't broken.
- - Match existing style, even if you'd do it differently.
- - If you notice unrelated dead code, mention it - don't delete it.
-
- When your changes create orphans:
- - Remove imports/variables/functions that YOUR changes made unused.
- - Don't remove pre-existing dead code unless asked.
-
- The test: Every changed line should trace directly to the user's request.
+ # ROLE & PRINCIPLE
+ - **Goal**: Minimize LLM coding mistakes, bias toward caution and surgical precision.
+ - **Rule**: Never assume or guess. Keep changes isolated.
- ## 4. Goal-Driven Execution
+ # EXECUTION ROUTING
+ if task_type == "plan_design" OR task_type == "new_feature":
+ CALL apply_thinking_rules()
+ CALL apply_simplicity_rules()
+ elif task_type == "bug_fix" OR task_type == "edit_existing":
+ CALL apply_thinking_rules()
+ CALL apply_surgical_rules()
+ elif task_type == "validation" OR task_type == "testing":
+ CALL apply_verification_rules()
- **Define success criteria. Loop until verified.**
+ # 1. THINKING RULES
+ Before editing or writing code:
+ - State assumptions explicitly. if unsure: CALL ask_question()
+ - if multiple_implementations: Present trade-offs to user. Do NOT make silent choices.
+ - if task_unclear: Identify confusing point. CALL ask_question(). Do NOT guess.
+ - if simpler_approach_exists: Suggest it immediately. Push back on over-engineering.
- Transform tasks into verifiable goals:
- - "Add validation" → "Write tests for invalid inputs, then make them pass"
- - "Fix the bug" → "Write a test that reproduces it, then make it pass"
- - "Refactor X" → "Ensure tests pass before and after"
+ # 2. SIMPLICITY RULES
+ - Write minimum code to solve requirements.
+ - No speculative abstractions or single-caller helper layers.
+ - No unrequested configurability or parameter flexibility.
+ - No error-handling paths for impossible/unreachable scenarios.
+ - if line_count > necessary: Rewrite to condense.
- For multi-step tasks, state a brief plan:
- ```
- 1. [Step] → verify: [check]
- 2. [Step] → verify: [check]
- 3. [Step] → verify: [check]
- ```
+ # 3. SURGICAL RULES
+ When editing code:
+ - Modify only target files/lines. Do NOT touch adjacent files, formatting, or comments.
+ - Do NOT refactor working modules unless explicitly requested.
+ - Match existing codebase style and patterns exactly.
+ - if your_edits_create_orphans: Remove unused imports, variables, or helpers created by your diff.
+ - if pre_existing_dead_code_found: Report it in notes. Do NOT delete it silently.
- Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
+ # 4. VERIFICATION RULES
+ - Transform every requirement into a verifiable success target.
+ - if fixing_defect: Write reproducing test -> observe fail -> fix -> verify pass.
+ - if adding_feature: Write tests for edge cases/invalid inputs -> verify pass.
+ - if refactoring: Run test suite before and after changes.
+ - Loop verification until all criteria pass. Do NOT report completion on unverified changes.