CLAUDE.md: The File That Makes Claude Actually Know Your Project
I use Claude Code every single day. It sits in my terminal, reads my files, runs my tests, pushes commits. By now, it has touched almost every file in my codebase.
Except it doesnât remember any of it. Not automatically.
Every time I start a new Claude Code session, Claude starts fresh. No memory of yesterdayâs conversation. No awareness that this is a TypeScript project with strict null checks. No knowledge that we use Zod for validation, avoid class components, or that the legacy/ folder is a minefield I havenât had time to refactor.
Unless I tell it. And thatâs what CLAUDE.md is for.
The File That Hit 100K Stars
In April 2026, a 65-line markdown file became the second most-starred repository on GitHub in a single day.
The file was a CLAUDE.md template inspired by Andrej Karpathy â developer Forrest Chang built the actual repo after a Karpathy post on LLM coding failure modes, and developers recognized it instantly for what it was: the thing theyâd been missing.
Within a week, the repo crossed 100K stars. People werenât starring a file â they were voting for a concept.
The concept: stop re-explaining your project to Claude every session. Write it down once. Let Claude read it every time.
What CLAUDE.md Actually Is
CLAUDE.md is a plain markdown file you place at the root of your repository. When you launch Claude Code, it reads this file before doing anything else and uses it as persistent context for the entire session.
Thatâs it. No special syntax. No configuration UI. No API calls. Just a markdown file that Claude reads before starting work.
But the simplicity is what makes it powerful:
- It lives in your repo â itâs version-controlled alongside your code
- Itâs committed to git â every teammate gets the same context automatically
- Itâs plain text â you can update it in thirty seconds when conventions change
- Itâs transparent â what Claude knows is exactly whatâs written there, nothing hidden
The official Claude Code docs call it âa persistent system prompt you control.â Iâd add one thing: itâs the system prompt your whole team writes together, and it gets better over time.
The Four Rules That Went Viral
Karpathyâs template is tight. Under 200 lines. Four principles, no filler. Hereâs what it actually says â and more importantly, why it resonated.
1. No Silent Assumptions
State your assumptions explicitly before coding. If there are multiple valid interpretations, present them. If something is unclear, halt and ask.
This one rule eliminates the most common Claude failure mode. Claudeâs default behavior when it hits ambiguity is to pick an interpretation and execute it with full confidence. A silent wrong assumption at step one means three minutes of watching Claude confidently build the wrong thing â and another ten minutes untangling the diff.
The fix is obvious in hindsight: make Claude ask. But Claude doesnât ask by default because asking can feel like failure. This rule gives it explicit permission, and makes verification a first-class part of the workflow rather than an afterthought.
2. Simplicity First
Prefer the simplest implementation that works. No abstractions for single-use code. No error handling for scenarios that cannot happen.
Claude loves to over-engineer. Ask it to add a configuration option and it builds a plugin system. Ask it to add a log line and it proposes a structured logging framework with log levels, rotation, and a metrics adapter. Ask it to write a helper function and it adds an interface, a factory, and an abstract base class.
None of that is wrong â itâs just not what you asked for. This rule is a budget constraint: spend complexity only where complexity is needed. Everything else stays flat.
3. Surgical Changes
Complete only the requested task. Do not improve adjacent code unless explicitly asked. Do not refactor while fixing a bug.
The silent refactor is Claudeâs second most destructive default behavior. You ask it to fix a null pointer exception in getUserById, and it returns a diff that also âcleans upâ the surrounding module, renames three variables, and adds early returns throughout the file. The bug is fixed but now the PR is unsalvageable.
This rule creates an explicit contract: the scope of a task is the scope of the change. Everything else waits until you ask for it separately.
4. Goal-Driven Execution
Convert every task into a measurable objective with explicit verification steps before starting.
The difference between these two prompts is enormous:
- âAdd a login form.â
- âAdd a login form â success when: renders at /login, accepts valid credentials, shows error state on invalid credentials, passes the existing auth test suite.â
The second gives Claude a finish line. Without one, agents loop â making more changes, running more commands, increasingly uncertain about what âdoneâ looks like. A measurable goal is how Claude knows when to stop.
Writing Your Own CLAUDE.md
Karpathyâs template is a universal starting point. But a CLAUDE.md that actually works for your project has your projectâs specifics in it. Hereâs the structure Iâve converged on after months of daily use.
Section 1: Project Context
One paragraph. What is this? Whatâs the stack?
## Project
An Astro blog with TypeScript and Tailwind, deployed to Cloudflare Pages.
Content lives in `src/content/blog/` as Markdown files with Zod-validated frontmatter.
Supports English and Vietnamese via Astro's built-in i18n.
Sounds obvious. But this single paragraph stops Claude from suggesting patterns that donât fit (like proposing a webpack config in an Astro project) and saves you from answering âwhat framework are you using?â every session.
Section 2: Key Directories
Not a full file tree â just the parts Claude needs to navigate without getting lost.
## Key Directories
- `src/content/blog/en/` â English posts (Markdown)
- `src/content/blog/vi/` â Vietnamese posts (Markdown)
- `src/components/` â Astro components
- `src/layouts/` â Page layouts
- `public/assets/` â Static images and media
Section 3: Commands
The exact commands to run. Claude uses these when you ask it to build, test, or lint. Precision matters.
## Commands
- `npm run dev` â Start dev server (port 4321)
- `npm run build` â Production build
- `npx astro check` â TypeScript check
- `npm run lint` â ESLint
This section alone recovers real time per session. Without it, Claude guesses the commands. It guesses yarn when you use pnpm. It guesses npm test when you use vitest run. Small errors, but they break flow when you hit them five times a day.
Section 4: Conventions
The decisions that arenât obvious from reading the code.
## Conventions
- Blog post filenames: `YYYY-MM-DD-slug.md`
- Categories: ai, android, ios, fe, javascript, personal, til
- Use Unsplash URLs for images: `https://images.unsplash.com/photo-XXX?w=1200&auto=format&fit=crop`
- Always include `toc: true` and `comments: true` in frontmatter
- Inline images use `<img src="..." alt="..."/>` tags, not Markdown syntax
These live in your head but not in the code. Claude has no way to know them unless you write them down.
Section 5: Avoid
Explicit prohibitions. The things Claude does by default that you donât want.
## Avoid
- Do not use class components â functional only
- Do not commit `console.log` debug statements
- Do not modify `legacy/` files without explicit instruction
- Do not install new packages without asking first
The last one matters most for projects with strict dependency audits or locked package.json files.
Section 6: Behavior Rules
Karpathyâs four rules, verbatim.
## Rules
1. Before coding: state assumptions explicitly. If ambiguous, ask.
2. Prefer the simplest working implementation.
3. Change only what's needed. No adjacent refactors.
4. Define a measurable success condition before starting.
SKILL.md: Taking It Further
Once you have a CLAUDE.md, the next level is SKILL.md files.
Skills live in .claude/skills/ and give Claude reusable, documented workflows. Instead of re-explaining a multi-step process every session, you define it once and invoke it with a slash command.
Hereâs a skill I use on this blog:
# new-post
Create a new blog post.
## Steps
1. Check the latest file in `src/content/blog/en/ai/` to confirm date and naming conventions
2. Create a new file at `src/content/blog/en/{category}/YYYY-MM-DD-{slug}.md`
3. Use this frontmatter: title, date, categories, tags, summary, toc: true, comments: true, image (Unsplash URL)
4. Write at least 800 words. Include one inline image between major sections.
5. Run `npx astro check` to verify TypeScript is clean
After writing this skill, instead of walking Claude through the process every time, I just say: âWrite a new post about X using the new-post skill.â The instruction budget gets spent on the content, not the setup.
What Goes Wrong Without It
I ran without a proper CLAUDE.md for about two months after I started using Claude Code daily. The problems were predictable in hindsight:
Repeated explanations. Every new session started with the same paragraph: âThis is a TypeScript project, we use Zod, content lives in Astro collections, follow this frontmatter formatâŚâ Minutes per session, compounding into real time per week.
Silent tech stack mismatches. Claude suggested Vue patterns in an Astro project. React idioms in a vanilla TypeScript file. Not because Claude was confused â because I hadnât told it the stack. My fault, not Claudeâs.
The creeping refactor. Asked for a small bug fix, got a diff three times larger than it shouldâve been. Claude was âhelping.â I started every session with âdo not refactor anything not directly related to the taskâ â waste of tokens, and Iâd sometimes forget. CLAUDE.md handles this once.
Wrong commands. âRun the testsâ produced npm test when I use vitest run. Small friction, but friction you hit constantly is the kind that makes a tool feel worse over time.
All four disappear with a properly written CLAUDE.md. Not because Claude gets smarter â because youâve given it what it needs.
The Budget Constraint
One warning: keep it short.
Claudeâs effective instruction budget for a session is roughly 150â200 lines before compliance starts degrading. The Claude Code system prompt already uses about 50 of those. If your CLAUDE.md runs to 400 lines, critical rules near the end get silently deprioritized.
Karpathyâs template respects this constraint. Under 200 lines, everything essential, nothing decorative. Testing across real codebases showed a CLAUDE.md under that limit cuts Claudeâs error rate dramatically â one study cited a drop from 41% to 3% over six weeks.
My pruning rule: if a section hasnât visibly influenced Claudeâs behavior in the past two weeks, it doesnât earn its lines. Delete it. A tight file Claude follows is worth more than a comprehensive one it partially ignores.
Why 100K Stars Makes Sense
The reason Karpathyâs template went viral isnât the four rules themselves. Experienced developers know these things already â donât assume, stay simple, stay focused, verify your work. We tell junior engineers the same things in code reviews.
The reason it hit 100K stars is that it took something developers had been doing informally â re-explaining context every session, fighting Claudeâs default over-engineering, losing to the silent refactor â and turned it into a file.
Files are tools. Files can be version-controlled, shared, improved, iterated. Files donât forget between sessions.
A conversation forgets. A CLAUDE.md doesnât.
If you use Claude Code and donât have one yet: create it today. Start with ten lines. Write down your project, your commands, and the three most common things Claude does wrong. Thatâs a complete first version.
If you already have one: look at it now. Is it under 150 lines? Does it list your actual commands? Does it have explicit prohibitions? Trim what isnât earning its place, add whatâs missing, commit it.
The investment is an hour. The return is every Claude session you run from here on being faster, more accurate, and less in need of correction.
Thatâs the trade Iâd take every time.
What do you put in yours? Drop a comment â Iâm always looking for sections I havenât thought of.