facebook pixel
Skip to content

skillUI/UX Skills3 min read

karpathy-guidelines

Our take
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.

On this page10 parts
  1. 01The Problem Karpathy Named
  2. 021. Think Before Coding
  3. 032. Simplicity First
  4. 043. Surgical Changes
  5. 054. Goal-Driven Execution
  6. 06Installation — Claude Code Plugin (global)
  7. 07Installation — Per project (CLAUDE.md)
  8. 08Skill File (CLAUDE.md)
  9. 09How to Know It's Working
  10. 10Source

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:

code
1. Extract the auth middleware → verify: all routes still pass tests
2. Add rate limiting → verify: /api/login returns 429 after 5 attempts
3. Write unit tests → verify: 100% coverage on the new module

Installation — Claude Code Plugin (global)

bash
/plugin marketplace add forrestchang/andrej-karpathy-skills
/plugin install andrej-karpathy-skills@karpathy-skills

Installation — Per project (CLAUDE.md)

curl -o CLAUDE.md https://raw.githubusercontent.com/forrestchang/andrej-karpathy-skills/main/CLAUDE.md

Skill 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.

code
# Karpathy Coding Guidelines
Derived from Andrej Karpathy's observations on LLM coding pitfalls.
Source: https://github.com/forrestchang/andrej-karpathy-skills
---
## 1. Think Before Coding
Don'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 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
- No error handling for impossible or highly unlikely scenarios
- If 200 lines could be 50, rewrite it to 50
- No premature optimization
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.
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 it
When your changes create orphans:
- DO remove imports/variables/functions that YOUR changes made unused
- DO NOT remove pre-existing dead code unless explicitly asked
The test: every changed line should trace directly to the user's request.
## 4. Goal-Driven Execution
Define 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
Private Workshop

Want to bring AI into your Frontend workflow?

We help product teams adopt AI-powered development practices, from agent workflows to custom skills and tooling, on whichever coding agent they already run.

What happens next
  1. 01

    Tell us what you are building.

    Your stack, the AI tools you use, where you are stuck.

  2. 02

    We book a 15-minute call.

    We look at how your team works with agents today.

  3. 03

    We shape the workshop.

    Private and hands-on, on your own codebase.

0/2000

Your info stays with us. That's it.