
The 12 CLAUDE.md Rules That Make Claude Code Far More Reliable
One plain text file has become one of the most talked-about tricks for working with Claude. Developers who put the right rules inside it report far fewer mistakes from Claude Code, and the GitHub repo collecting those rules grew to well over 100,000 stars. In this post I break down what the file is, where the rules came from, all 12 of them in plain English, and a template you can copy.
The backstory
It started with Andrej Karpathy, one of the most respected AI researchers around and a co-founder of OpenAI, posting his frustrations with how Claude writes code. The complaints were specific: it made assumptions instead of asking, it overcomplicated simple things, and it touched code it wasn’t supposed to touch.
A developer named Forrest Chang turned those complaints into four rules, a cheat sheet for Claude, and published it on GitHub. It took off. Later, another engineer (who goes by Mnilax) extended the list to 12 rules aimed at how people use Claude today, including multi-agent workflows. That extended version is what went viral.
What is CLAUDE.md?
CLAUDE.md is a file you put in the root of your project. Claude Code reads it at the start of every session, before doing anything, and treats whatever is inside as ground rules. Think of it as an employee handbook that the employee rereads every morning before starting work.
Rules 1–4: the originals
1. Think before coding
No hidden assumptions. If Claude isn’t sure, it should ask, not guess. If there’s a trade-off, it should lay it out before choosing. Without this rule, Claude tends to guess and hope for the best.
2. Simplicity first
Write the smallest solution that works. No features nobody asked for, no elaborate systems for a one-off task.
3. Surgical changes
Only touch what the task requires. Don’t tidy nearby code, don’t reformat, don’t refactor things that aren’t broken. Do the task and stop.
4. Goal-driven execution
Instead of giving Claude step-by-step instructions, describe what success looks like and let it find the path.
Rules 5–12: the 2026 extensions
5. Use the model only for judgment calls
Claude shines at writing, summarizing, categorizing, and extracting meaning. For mechanical, predictable work like routing a request or handling an error code, use regular code. Don’t spend AI on something an if statement can do.
6. Treat the token budget as a hard limit
Keep a single task under about 4,000 tokens and a session under about 30,000. When it gets close, Claude should summarize and restart rather than silently blowing past the limit. This keeps it focused on long tasks.
7. When two patterns conflict, pick one and explain why
Blending two approaches is the worst outcome. Choose the newer or better-tested one, explain the choice, and flag the other for cleanup later.
8. Read before you write
Before editing a file, understand what depends on it: who calls this function, what this module exports. “Looks unrelated” is one of the most dangerous phrases in engineering.
9. Tests should verify intent, not just behavior
A test that only checks what the code does today doesn’t protect you. A good test fails when the business logic changes.
10. Checkpoint after every step
In multi-step work, Claude should summarize after each step: what it did, what it verified, and what’s left. If it can’t say that clearly, it should stop. This prevents it from confidently charging in the wrong direction.
11. Follow existing conventions
Use the project’s existing naming and patterns, even if Claude would prefer something else. Changing conventions is a separate conversation, not something to do quietly mid-task.
12. Fail loudly
My favorite. If a migration skipped 30 rows, don’t report it as complete. If a test was skipped, don’t say all tests passed. Claude should surface uncertainty instead of hiding it.
A CLAUDE.md template you can copy
Here’s a condensed version of all 12 rules. Save it as CLAUDE.md in your project root and edit it to fit your project:
# Working rules
1. Think before coding. Ask when unsure; state trade-offs before choosing.
2. Simplicity first. Smallest working solution; no unrequested features.
3. Surgical changes. Touch only what the task needs; no drive-by refactors.
4. Goal-driven. Work toward the stated success criteria.
5. Use AI judgment only where it adds value; use plain code for mechanical logic.
6. Respect token budgets: summarize and restart before context gets bloated.
7. If two patterns conflict, pick one, explain why, flag the other for cleanup.
8. Read before you write: check callers and dependencies first.
9. Tests must verify intended behavior, not just current behavior.
10. After each step: what I did, what I verified, what is left.
11. Follow the existing conventions of this codebase.
12. Fail loudly: report skipped work, failures, and uncertainty explicitly.Why this matters even if you don’t code
Strip away the developer language and these are just good principles for working with any AI: think before acting, keep it simple, stay in your lane, verify the work, and be honest about what you don’t know. They’re the same things you’d want from a capable, trustworthy assistant. The post went viral because people recognized the problems: AI tools tend to overcomplicate, assume, and sound confident when they shouldn’t.
You can apply the same ideas in ChatGPT custom instructions or a Claude Project’s instructions. My prompt engineering guide covers more of the basics.
One warning: more rules is not better
The original research behind this noted that compliance drops off sharply past about 14 rules. Twelve is already near the edge. Keep the file short and specific, and make every rule answer one question: what exact mistake does this prevent?
FAQ
Where do I put CLAUDE.md?
In the root folder of your project. Claude Code picks it up automatically at the start of each session.
Does CLAUDE.md work with other AI coding tools?
The file name is specific to Claude Code, but the rules themselves work in any agent’s instruction file or system prompt.