Skip to content
Leverage AI

Free guide

CLAUDE.md: what to put in it, tested on one small app

CLAUDE.md is a plain text file of project instructions that Claude Code reads each session. Put your test commands, files to leave alone and project conventions in it so you don't have to repeat them. On our small task app, Claude kept an average of four of five house rules with no file, four with /init, and all five with a nine-line file we wrote. The only gain was using node --test instead of the equivalent npm test; both commands ran the same tests.

  • Three setups on the same app
  • A short file to copy
  • Check your own rules

Published · Updated

Start building

CLAUDE.md: what to put in it, tested on one small app

Where CLAUDE.md goes and when it loads

For most projects, put CLAUDE.md at the top of the repo, beside the README. Commit it so teammates get the same instructions. The memory docs, read on 24 November 2026, give these locations and loading rules:

  • Project instructions go in ./CLAUDE.md or ./.claude/CLAUDE.md.
  • Your personal rules for all projects go in ~/.claude/CLAUDE.md.
  • Private notes for one project go in CLAUDE.local.md at the project root. Add it to .gitignore.
  • Files in your starting folder and its parents load at launch. Subfolder files load as Claude works there. Their instructions add together.
  • Imports such as @docs/testing.md load extra text. Paths are relative to the importing file, with up to four nested hops. Imports that point outside the project show a one-time approval dialog.

That's enough to start. You don't need a separate file in every folder. Begin with one shared file and split out rules only when part of your app has a different need.

To make a first draft, open Claude Code in your project and use:

text
/init

We ran this in print mode for our test. It read the app and wrote a useful tour of the code, plus commands from the README. It also carried over a command that worked but didn't match the house rule for running tests. Read what it writes.

Before keeping a generated line, check it against the file or command it describes. Add preferences Claude can't infer from the code. In our demo, both test commands worked, but only one matched the house preference. That preference needed a person to supply it.

For your own project, update the README too when a command changes. Otherwise the next /init can pick up the old advice again. If an instruction needs a long explanation of why another document is wrong, fixing that document is usually less work.

The command reference lists /memory for opening and editing these files. Use /context all to check which memory files loaded.

What to put in it

Start with one thing you have had to correct twice. Write a specific instruction. A command, file name or example value is often enough.

For our app, we chose five house rules before asking Claude to change anything. Here is the whole nine-line file we tested. Copy it as a starting point, then replace the rules with yours:

markdown
# Small task list

Plain Node.js task library and CLI. Keep these house rules:

- Run tests with `node --test`. Do not use `npm test` or `npm run test`.
- Store date values as YYYY-MM-DD strings, or null when no date is set.
- Never edit `data/generated.json`.
- Every new exported function needs a direct call in a test file and passing tests.
- Every commit subject starts with a present-tense verb: Add, Fix, Update, Remove, Refactor, Test, Document, or Keep. Do not use a prefix such as feat:.

We chose the direct test command to check a house preference the README didn't give Claude. The README recommended npm instead.

For the other lines, name the choice rather than leaving it open. A date example such as 2026-12-01 tells Claude the form your app expects. Naming data/generated.json tells it exactly which file to leave alone. If a tool builds that file, name the source it should edit instead. That gives Claude a way to finish the job while keeping your rule.

We also asked for a test call for every new exported function, meaning a function other files can use. That's easy to inspect in a small app: find the new function, open its test and see what the call checks. The last line settles commit style. Your project might use feat: rather than our opening verbs; change the line to match.

If you're unsure what to add next, read your last few corrections to Claude. A note such as "keep the old field name because the mobile app still sends it" is useful context. "Use clear names" won't preserve that link between two apps. Save the reason when it helps Claude make the next choice, then stop there.

What to leave out

Cut sentences whose meaning you can't check. "Write good code" gives Claude no way to choose between two working answers. "Be careful" doesn't name the mistake you're trying to prevent. In our file, each line points to something we can inspect after a task.

You can also cut facts that are already easy to find. Our generated file described most of the app's functions and explained its folder layout. That was accurate. It tied with no file on our five checks. A description of the code can't supply a rule that nobody has written down.

Long procedures make the file harder for you to maintain. If a release takes a page of steps, keep those steps where you run releases. The current best-practices docs recommend short standing instructions, skills for procedures, and hooks for checks that have to run. They point to a target of under 200 lines per CLAUDE.md file.

Leave one-off task notes out too. If you're adding due dates today, put the feature request in chat. A settled choice such as "unset due dates are null" can stay in the file. That line still helps when you're fixing search or changing the display next month. Delete a rule once the project no longer uses it. Otherwise Claude keeps receiving an instruction that made sense for an earlier version of your app.

HumanLayer reports using a root file under sixty lines, with pointers to more detail. You can use the same approach when one part of your app needs detail that the rest doesn't.

When a hook or skill fits better

A line in CLAUDE.md asks Claude to follow a rule. Some rules need a check that runs even when Claude forgets the line. If the generated file must stay untouched, a file guard or build check can catch a change before it gets through review.

A hook runs at a set point in Claude Code's work, such as before a tool call. Use one to run a check at the moment an edit or command needs it.

A skill holds instructions for a task, such as writing release notes. Use it when Claude needs the steps for that job, and keep the project file for rules that apply across jobs. A job you repeat each week is a good candidate: the steps stay together, and you can call them when you need them.

You can use both. A short standing rule can say where a procedure lives, while a check verifies the output. You don't need to paste the whole procedure into every session.

What happened on the small app

Our demo was a plain Node task list. It could add, finish, remove and list tasks, with five passing tests. We gave it a sample export that wasn't meant to change. Before the first run, we wrote the five house rules and a script to check them.

We tried three versions: no project file, the untouched file from /init, and our short file above. We didn't tell /init our house rules. It had to work from the same code and README available to Claude in the other versions.

Then we sent two requests a person might type:

text
Add a due date to each task and commit the change.
text
Add a function that counts overdue tasks and commit it.

Each request ran five times per version. Every run started a fresh conversation from the same saved code, so the second request didn't inherit a due-date feature from the first.

Project instructionsAverage rules held, out of five
No CLAUDE.md4
File from /init4
Short file with five rules5

No file and /init tied. All ten runs in each version used npm test, as the README suggested. All ten with the short file used node --test. In two of those ten, Claude also changed the README's test command to match the rule without being asked, so expect your README to change too. Stored dates stayed in the allowed form, nobody changed the sample export, tests called the new exported functions, and commit subjects began with an allowed verb in every version.

We checked the files, test calls, shell commands and commit subjects after each run. All thirty final test suites passed. Simple feature checks passed for all thirty saved changes. The original tests, rerun unchanged, passed for twenty-nine. The score includes rules kept without a difficult choice, such as leaving the sample export alone.

One no-file run gave tasks a due date a week ahead by default. That changed the displayed text, so an old assertion failed; Claude had updated the assertion in its own tests. For a task like this, decide whether an unset date should stay blank or get a default. If it gets a default, decide which date it starts from. Put a one-off choice in the request; put a lasting project choice in CLAUDE.md.

Check your own file in five minutes

Pick one small change that will exercise a rule you care about. If the rule concerns tests, choose a change that needs a test. If it concerns a file, choose work near that file. A task that never gets close to the rule tells you little.

Save your work first. In a spare copy or branch, start a fresh session with your current file and ask for the change in your usual words. Don't remind Claude of the rule in the request; you're checking whether the file carries it.

Afterwards, inspect the evidence. For a date rule, read a value the app saved. For tests, look at the command that ran and the assertions added. For a protected file, check the diff. Read a new test's expected answer too. If Claude changes an old assertion, check whether your request called for the new behaviour, as our due-date example did. Claude's final message is a useful pointer, but the work itself settles the check.

Now restore the same starting code, sharpen the one rule, and try the same request in a fresh session. Keep the edit that fixes the miss. If both versions work, write down the tie; there's no reason to claim the new wording helped.

One attempt each is a quick check. Repeat it when the rule matters, because Claude can make different choices on the same request. Our five repeats helped show whether a result kept happening.

If a rule still gets missed, first check that the file loaded. Then look for another file giving a different instruction, or an old README command competing with the new one. If the action must be blocked every time, add a check that can block it.

Test details and cost

We used Claude Code with Sonnet 5.5 on 24 November 2026, through an existing subscription. The guide and demo are free; Claude Code access is separate. No paid API key was used.

That was thirty task runs, plus one to generate the starter file. We ran all tasks with permission prompts bypassed so approval dialogs wouldn't decide whether a house rule held. Auto memory was off, and no extra instruction files or custom hooks supplied the house rules. Our checker ran outside Claude's working folder. It checked the final tests, stored date values, the sample export, new function references in tests and commit subjects.

Our local test tools were Node.js (MIT), Git (GPLv2) and Python (PSF); Claude Code is proprietary.

For checks that run at set points, read Claude Code hooks.

For steps Claude loads for a particular job, read the best Claude Code skills.

Questions people ask

What should I put in CLAUDE.md?

Put in commands and rules Claude can't work out from the code: how your team runs tests, which file must stay untouched, or your chosen date format. Write each line so you can check whether it was followed.

Where does CLAUDE.md go?

Put a shared project file at the top of the repo as CLAUDE.md, or use .claude/CLAUDE.md. Personal rules for all projects go in ~/.claude/CLAUDE.md.

Is the CLAUDE.md from /init enough?

It is a useful first draft. In our test it tied with no file at four of five house rules. Writing the five rules plainly raised that to five; the gain came from following our preferred test command.

Can CLAUDE.md force Claude to follow a rule?

It can guide Claude, but it can't guarantee a rule holds. Check the work after a task. Use a hook or another enforced check when an action must be blocked or a check must always run.

Save it for later

Get this guide by email

Doing this on your computer later? We send you this page's link and its main prompt, then one short AI email a week. Unsubscribe any time.

Follow on Instagram@leverageai_io, where our Reels and code words are.
CLAUDE.md: what to put in it, tested on one small app | Leverage AI