karpathy-guidelines
forrestchang/andrej-karpathy-skills
Behavioral guidelines to reduce common LLM coding mistakes through explicit assumptions, simplicity, surgical changes, and verifiable success criteria.
What is karpathy-guidelines?
A set of four core principles for writing better code with LLMs: think before coding by surfacing assumptions and tradeoffs, prioritize simplicity over speculative features, make surgical edits that touch only what's necessary, and define verifiable success criteria for each task. Use when writing, reviewing, or refactoring code to avoid overcomplication and miscommunication.
- Surface assumptions and tradeoffs before implementing to avoid silent misinterpretations
- Enforce simplicity by removing speculative features, unnecessary abstractions, and over-engineered error handling
- Make surgical edits that touch only required code and match existing style without refactoring unrelated sections
- Define verifiable success criteria and loop-based execution plans to enable independent task completion
How to install karpathy-guidelines
npx skills add https://github.com/forrestchang/andrej-karpathy-skills --skill karpathy-guidelinesHow to use karpathy-guidelines
- 1.Before writing code, explicitly state your assumptions and ask for clarification if multiple interpretations exist
- 2.Write the minimum code that solves the stated problem—remove speculative features, unnecessary abstractions, and over-engineered error handling
- 3.When editing existing code, match the existing style and only remove code your changes made unused; do not refactor unrelated sections
- 4.Define verifiable success criteria for the task (e.g., 'write tests for invalid inputs, then make them pass') and loop until verified
Use cases
- Code review: catch overcomplicated implementations and unnecessary abstractions before merge
- Refactoring: ensure changes are minimal and focused, with clear before/after verification
- Bug fixes: transform vague problems into reproducible test cases with passing criteria
- Feature implementation: prevent scope creep by explicitly stating what is and isn't being built
- Software engineers using LLMs for code generation or refactoring
- Code reviewers working with AI-assisted development
- Teams seeking to reduce miscommunication and rework in LLM-assisted workflows
- Developers who want to enforce disciplined, minimal-change coding practices
karpathy-guidelines FAQ
For trivial tasks where speed matters more than precision, use judgment. These guidelines bias toward caution and are most valuable for complex changes, reviews, and multi-step tasks.
Mention them to the user but don't delete or fix them unless they're a direct result of your changes. Keep edits surgical and focused on the stated request.
Transform vague goals into testable outcomes: 'Add validation' becomes 'Write tests for invalid inputs, then make them pass.' Strong criteria let you verify completion independently without constant clarification.
No. Match existing style and only touch what's necessary for your change. If you notice unrelated improvements, mention them but don't implement unless explicitly asked.
State a brief plan with each step and its verification check, e.g., '1. [Step] → verify: [check]'. This ensures clarity and lets you loop independently through completion.
Full instructions (SKILL.md)
Source of truth, from forrestchang/andrej-karpathy-skills.
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
Karpathy Guidelines
Behavioral guidelines to reduce common LLM coding mistakes, derived from Andrej Karpathy's observations 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.
4. Goal-Driven Execution
Define success criteria. Loop until verified.
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"
For multi-step tasks, state a brief plan:
1. [Step] → verify: [check]
2. [Step] → verify: [check]
3. [Step] → verify: [check]
Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
Related skills
More from forrestchang/andrej-karpathy-skills and the wider catalog.
find-skills
Discover and install agent skills to extend your coding agent's capabilities on demand
frontend-design
Build visually distinctive UI with opinionated aesthetic direction, typography, and layout choices that avoid templated defaults.
vercel-react-best-practices
70 React/Next.js performance rules from Vercel Engineering, prioritized by impact for writing, reviewing, and refactoring code.
agent-browser
Fast browser automation CLI for AI agents — navigate, click, scrape, screenshot, and test via Chrome CDP
web-design-guidelines
Review UI code against Web Interface Guidelines for accessibility, UX, and design best practices
finetuning
Fine-tune models on Azure AI Foundry with SFT, DPO, or RFT training methods.