skillUI/UX Skills3 min read
karpathy-guidelines
A single file that makes your coding agent think before it codes — distilled from Andrej Karpathy's observations on LLM pitfalls.
Four battle-tested principles (Think Before Coding, Simplicity First, Surgical Changes, Goal-Driven Execution) packed into one CLAUDE.md file. 93k+ GitHub stars.
The Problem Karpathy Named
Andrej Karpathy — former Director of AI at Tesla, co-founder of OpenAI — posted a thread on X about the failure modes of LLM coding agents. Someone turned it into a single CLAUDE.md file. It now has 93k+ stars.
In his words: "The models make wrong assumptions on your behalf and just run along with them without checking. They don't manage their confusion, don't seek clarifications, don't surface inconsistencies, don't present tradeoffs, don't push back when they should." They overcomplicate code, bloat abstractions, and "implement a bloated construction over 1000 lines when 100 would do."
These aren't edge cases — they're the default behavior of every coding LLM when you don't give it structure. The fix isn't a better model, it's a better contract. That's what this file does.
1. Think Before Coding
Don't assume. Don't hide confusion. Surface tradeoffs.
- State assumptions explicitly — if uncertain, ask rather than guess
- Present multiple interpretations when ambiguity exists
- Push back when a simpler approach exists — say so before implementing
- Stop when confused — name exactly what's unclear
2. Simplicity First
Minimum code that solves the problem. Nothing speculative.
- No features beyond what was explicitly asked
- No abstractions for single-use code
- No "flexibility" or "extensibility" that wasn't requested
- If 200 lines could be 50, rewrite it to 50
The test: would a senior engineer call this overcomplicated? If yes, simplify.
3. Surgical Changes
Touch only what you must. Clean up only your own mess.
- Don't "improve" adjacent code you weren't asked to touch
- Don't refactor things that aren't broken
- Match existing style, even if you'd do it differently
- Remove only imports/functions YOUR changes made unused — not pre-existing dead code
The test: every changed line should trace directly to the user's request.
4. Goal-Driven Execution
Define success criteria. Loop until verified.
LLMs are exceptionally good at looping until they meet specific goals. Don't give them instructions — give them success criteria. The agent loops until each criterion is met. Example plan format:
1. Extract the auth middleware → verify: all routes still pass tests2. Add rate limiting → verify: /api/login returns 429 after 5 attempts3. Write unit tests → verify: 100% coverage on the new moduleInstallation — Claude Code Plugin (global)
/plugin marketplace add forrestchang/andrej-karpathy-skills/plugin install andrej-karpathy-skills@karpathy-skillsInstallation — Per project (CLAUDE.md)
curl -o CLAUDE.md https://raw.githubusercontent.com/forrestchang/andrej-karpathy-skills/main/CLAUDE.mdSkill File (CLAUDE.md)
Our version of the Karpathy guidelines with minor additions for clarity. Drop it in your project root, or merge with your existing CLAUDE.md if you have one.
# Karpathy Coding GuidelinesDerived from Andrej Karpathy's observations on LLM coding pitfalls.Source: https://github.com/forrestchang/andrej-karpathy-skills---## 1. Think Before CodingDon't assume. Don't hide confusion. Surface tradeoffs.Before writing any code:- State your assumptions explicitly — if uncertain, ASK rather than guess- Present multiple interpretations when ambiguity exists — don't pick silently- Push back when a simpler approach exists — say so before implementing- Stop when confused — name exactly what's unclear and ask for clarification- Never silently adopt an interpretation and run with it## 2. Simplicity FirstMinimum code that solves the problem. Nothing speculative.- No features beyond what was explicitly asked- No abstractions for single-use code- No "flexibility" or "extensibility" that wasn't requested- No error handling for impossible or highly unlikely scenarios- If 200 lines could be 50, rewrite it to 50- No premature optimizationThe test: would a senior engineer call this overcomplicated? If yes, simplify.## 3. Surgical ChangesTouch only what you must. Clean up only your own mess.When editing existing code:- DO NOT "improve" adjacent code, comments, or formatting you weren't asked to change- DO NOT refactor things that aren't broken- Match the existing style and conventions, even if you'd do it differently- If you notice unrelated dead code, MENTION it — don't silently delete itWhen your changes create orphans:- DO remove imports/variables/functions that YOUR changes made unused- DO NOT remove pre-existing dead code unless explicitly askedThe test: every changed line should trace directly to the user's request.## 4. Goal-Driven ExecutionDefine success criteria. Loop until verified.For multi-step tasks, state a brief plan first:1. [Step] → verify: [specific check]2. [Step] → verify: [specific check]3. [Step] → verify: [specific check]Strong, specific success criteria let you loop independently until each criterion is met.How to Know It's Working
- Cleaner diffs— only the lines you requested show up changed; no drive-by reformatting
- Simpler first pass— concise from the start, no 400-line solutions to 20-line problems
- Questions before mistakes— clarifying questions come before implementation, not after a wrong path
- Self-verifying outputs— the agent loops against success criteria and tells you when something can't be verified
More in UI/UX Skills
- 1 min readweb-design-guidelinesVercel's UI rulebook, applied as a lint pass on your code.Read
- 1 min readcanvas-designTreats visual design as fine art — develops an aesthetic philosophy before pushing pixels.Read
- 1 min readtheme-factoryTen curated themes plus on-demand theme generation — stop hand-tuning palettes.Read
