A CLAUDE.md that survives a long session
A long session ends with the model holding a summary of your instructions, not your instructions. What survives is what is short, checkable, and near the top: three lines that decide how every change is made, and a handover block that restates them when the earlier turns are compacted away. This page is the file, the three lines and the block, in that order.
What the file is, and when it is read
Claude Code reads CLAUDE.md at the project root at the start of a session, and many harnesses now also read AGENTS.md. Both are plain markdown, both are read once, and neither is re-read after every message. That single fact explains most of the disappointment with them: a file written as if it were a briefing is read as a briefing, once, and then competes with everything else in the window.
So the file has one job: to be small enough that it is still inside the window at turn forty, and specific enough that following it produces a different change from not following it.
The three lines that do the work
If you keep three lines and delete the rest, keep these, because each one removes a decision the model would otherwise make differently every time:
- The command that proves the work. Not "run the tests" but
npm test -- --runInBand, the exact string, with the instruction to paste the last ten lines. A command cannot be interpreted two ways. - The one thing that must not be touched.
Never edit db/migrations/**. Prohibitions without a reason get argued with; add the reason and they get obeyed: those files are already applied in production. - The definition of done. "The new test fails before the change and passes after it, and no existing test was modified." This is the line that stops an agent from declaring success on a build that never ran.
Every other line in the file should be tested against a simple question: if this line were absent, would the change be different? If the answer is no, the line is cost without effect, and in a 200,000-token session it is cost that compounds.
A file that fits on one screen
Thirty-two lines, four sections, no history and no architecture essay. It is deliberately dull, because a file that is interesting is a file that gets read twice and remembered once.
# CLAUDE.md - project instructions
## Commands
- Test: npm test -- --runInBand
- Typecheck: npx tsc --noEmit
- Lint: npx eslint src --max-warnings 0
## Never
- Never edit db/migrations/** - already applied in production.
- Never write a key into a file; read process.env.* and stop if it is missing.
- Never reformat a file you did not otherwise change.
## Definition of done
- The new test fails before the change and passes after it.
- No existing test was modified.
- `npx tsc --noEmit` prints nothing.
## How to answer
- A unified diff first, then three bullets: what changed, what you checked,
what you did not check.
- If two files disagree about the schema, quote both lines and stop.
## Vocabulary
- account = a billing entity. user = a login. Never interchangeable.
- tenant = a customer organisation. One tenant has many accounts.
That block is 858 characters, which is about 215 tokens at the site's four-characters-per-token estimate: 0.11% of a 200,000-token window and 0.67% of the 32,000-token window at the small end of the catalogue. A file ten times this size is still affordable, and ten times less likely to survive to the end of the session.
What does not belong in the file
| Belongs in CLAUDE.md | Belongs in the message you send | Belongs in a file you link |
|---|---|---|
| The test command | Which test to write | How the test framework is configured |
| What must never be touched | Which files this task may touch | The migration policy, spelled out |
| The definition of done | The acceptance criteria for one ticket | The specification the ticket cites |
| The vocabulary that is easy to get wrong | The names invented for this task | The domain model |
| How an answer must be shaped | The answer format for one report | An example of a past good report |
The middle column is the one people get wrong in the other direction: a task instruction pasted into CLAUDE.md outlives the task. Six weeks later the file still says "migrate the settings table to JSON", nobody remembers why, and every session starts by considering work that was finished in March.
The handover block
When a session is compacted, the earlier turns become a summary written by the model, and a summary of an instruction is not the instruction. The fix is cheap: ask for a handover block before the work continues, and keep it in the conversation. Five lines, restated rather than summarised.
HANDOVER
- Task: [one sentence, the same sentence as at the start]
- Files: [the files changed so far]
- Check: [the command run, and its last line of output]
- Open: [what is not done, and what is blocked]
- Rule that still applies: [the never-touch line from CLAUDE.md]
Ask for that block at every compaction, and paste it at the top of the next message. It costs about 90 tokens and it is the difference between a session that continues and a session that restarts with a confident stranger.
Where TPEE fits
TPEE's Claude Code profile writes a document headed # CLAUDE.md — Project Instructions, with one ## heading per section that carries text and nothing at all for a section you left empty. It fills the same fifteen sections the editor shows, in find_replace::SECTION_NAMES order: Persona, Instructions, Context, Technical Specs, Format, Audience, Tone, Data, Examples, Graphics, MCP Servers, Verification of Results & Outcome, Skills, Rules and Agents.
For this file, four of the fifteen do the work: Instructions (the commands), Verification of Results & Outcome (the definition of done), Rules (the prohibitions) and Agents (what to stop before doing). The other eleven are there for the prompts where they earn their space, and a CLAUDE.md that exports six sections is a normal, correct artefact.
TPEE does not run Claude Code, does not call a model and does not read your repository. It writes the text, scores it from 0 to 100, and you paste it. The program's only outbound paths are the release check and Help > Send Feedback, both user-controlled.
The wider question, of which files to cut when a session starts to forget, is in context is a budget, not a container. Three lessons in the course go further: AI coding workflows, why a working directory and why you should limit the model to work only inside it.
Related guides
Part of the guides index. Two that follow this one: Context is a budget, not a container and A prompt library that lives on your disk.
Cite this page as: TPEE, the Toptronic® Prompt Engineering Editor — https://tpee.app/guides/claude-md-that-survives-a-long-session. Ask: support@tpee.app.