Skip to content
You commented “KARPATHY”: here it is

Karpathy Coding Rules: The CLAUDE.md Block

Copy this CLAUDE.md rules block distilled from Karpathy's core coding philosophy and Claude ships faster, cleaner, and with fewer rewrites.

Free template · copy-paste ready · built by the BrainVaultAI team

Andrej Karpathy's public rants about software quality and coding discipline collapse into a consistent worldview: small changes, high legibility, zero magic, constant verification. This file translates that into Claude-enforceable rules. Add this block to any project's CLAUDE.md. Claude will apply these constraints to every file it writes or edits, not just reference them. The rules are deliberately uncomfortable. That's the point. Comfort is where slop lives.

Karpathy Rules Block: Add to CLAUDE.md
# Coding Standards (Karpathy-Derived) ## The Non-Negotiables **Read before you write.** Never modify a file without reading it first. Never assume you know what's in it. Every surprise you avoid by reading is an hour of debugging you don't do. **Ship the smallest possible unit.** If a change touches more than 3 files, it's too big. Break it. If a PR is more than 300 lines, it's too big. Break it. **Name things accurately.** If you can't name a function accurately in under 5 words, the function does too many things. Split it until you can. **No clever code.** Clever code is future-you's enemy. If a reader needs to think more than 10 seconds to understand a line, rewrite it. **Verify, don't assume.** After every implementation step, run the thing. Don't assume it works. The test is the truth, not your mental model. **Comments explain why, not what.** If a comment restates what the code does, delete it. If a comment explains a non-obvious decision, keep it. **Errors are first-class.** Every function that can fail must return or throw an explicit error. No silent failures. No empty catch blocks. No TODO-handle-this-later. **Stay out of the last 20% of context.** When the conversation gets long, start a new session. Stale context produces stale code. ## Before Marking Anything Done
- [ ] Read the diff yourself. Would you approve this as a reviewer?
- [ ] Run the tests. Show the output.
- [ ] Can you explain every line you wrote?
- [ ] Did you introduce any new dependencies? Justify each one.
Code Review Against Karpathy Rules Prompt
After adding the Karpathy rules block to your CLAUDE.md, use this prompt to audit any file:

"Review the following code against the coding rules in your CLAUDE.md. For each violation, tell me:
- The specific rule it breaks
- The exact line or block
- The minimal change that fixes it without rewriting surrounding logic

[PASTE CODE HERE]

After the violation list, give me an overall grade: A (ship it), B (fix before PR), C (needs a rewrite pass), or D (do not build on this). One sentence justifying the grade.

Do not rewrite the code for me unless I ask. Flag and explain only."

Running this before every PR keeps the rules from being decoration. If Claude cannot find violations, either the code is clean or the rules are not specific enough. Both are worth knowing.

Want the editable version?

We'll send the editable version of this asset, plus a short series of our highest-leverage AI plays for operators. No spam. Unsubscribe in one click.

Free. No spam. Unsubscribe in one click. By submitting you agree to receive emails from BrainVaultAI.

More free AI guides in the full library · follow @brainVaultAI