Context Budgets for Long Projects: What to Persist, What to Hand Off, What to Let Go
24 November 2026 · Updated 28 November 2026 · 12 min read · by Yang Kai
For projects that run for weeks: a context-budget system covering what to persist in memory files, how to write a session handoff, and what to deliberately let compaction take.
Template inside: Project memory and session handoff template
Contents
- The three timescales of project memory
- The fourth layer: auto memory, and its limits
- What to persist: a decision rule
- The handoff: the highest-value habit in this article
- Memory and handoff templates
- Decisions (date, decision, one-line reason)
- Constraints that are not obvious from the code
- Conventions worth stating once
- Verified done
- Done but NOT verified
- Next, in order
- Traps and dead ends (do not retry without a new idea)
- Open questions for the human
- Starting a session from the files
- What compaction keeps, and what it loses
- Budgeting across weeks, practically
- How we researched this
- Over to you
A two-hour project lives comfortably inside one session. A six-week project does not — and the difference is not just length. Across weeks, the expensive failures change shape: an agent that re-litigates a decision settled last Tuesday, a session that starts by re-reading files a previous session already understood, a compaction that summarises away the one constraint that mattered.
Long projects need a memory system, and memory systems need a budget. This article sets out the layers: what deserves to persist for the whole project, what belongs in a handoff rewritten each session, what Claude Code now remembers on its own (and why that does not replace the rest), and what to deliberately let go.
The mechanics — auto memory, compaction, what loads at session start — are checked against Anthropic’s Claude Code documentation, November 2026. The templates are the artefact; copy them and adjust the headings.
This builds directly on the context budget audit — that piece is about what loads every request and what it costs you. Here the question is temporal: across dozens of sessions, what deserves to survive, in what form, and what should expire?
The short version:
| Layer | Holds | Lives in | Update rhythm |
|---|---|---|---|
| Permanent memory | Decisions, reasons, non-obvious constraints | CLAUDE.md or a committed decisions file | Rarely; edit when a decision changes |
| Working memory | This week’s state: done, unverified, next, traps | A handoff file | Rewritten at the end of every session |
| Auto memory | Claude’s own notes from your corrections | ~/.claude/projects/<project>/memory/ |
Written by Claude; reviewed by you occasionally |
| Session memory | Exploration, dead ends, file contents | The transcript | Never; let it expire |
The three timescales of project memory
Permanent memory: what stays true
Permanent memory is what is true for the whole project: architecture decisions and their reasons, conventions, external constraints, the definition of done. It changes rarely and earns its place in CLAUDE.md or a decisions file the agent reads at session start.
Keep it ruthlessly current. A stale decision recorded confidently is worse than no record, because the agent will defend it against your new instructions — the file says the project uses one approach, you ask for another, and the agent splits the difference.
The classic case: the permanent layer says the project deploys one way, the team switched deploy targets in week three, and nobody edited the file. Every session after that opens with the agent preparing work for a platform the project no longer uses, and the human paying a correction tax at the start of each task. Decisions carry dates in the template below for exactly this reason — a dated decision can be argued with; an undated one reads as eternal truth.
Working memory: what is true this week
Working memory is the current task’s state: what is half-finished, what is blocked and on whom, the last thing that failed and why. This is the layer most projects lack entirely, and its absence is why Monday’s session spends twenty minutes reconstructing Friday’s.
Working memory belongs in a handoff file that is rewritten — not appended to — at the end of each session. The handoff gets its own section below; it is the highest-value habit in this article.
Session memory: what should expire
Session memory is everything else: the exploration, the dead ends, the file contents the agent read along the way. Let it go.
Compaction and fresh sessions are not the enemy of long projects; they are how the project stays affordable and focused. The mistake is letting session memory be the only copy of something that belonged in one of the other layers.
The fourth layer: auto memory, and its limits
Claude Code now writes notes of its own. Per Anthropic’s memory documentation, auto memory records learnings from your corrections and preferences in ~/.claude/projects/<project>/memory/, and the first 200 lines or 25KB of its MEMORY.md index load at the start of every session.
Used well, it is genuinely helpful — the agent remembers that you corrected its test command twice and stops getting it wrong. But three properties keep it from replacing the layers above:
- It is machine-local. The memory directory sits outside your repo, keyed to the repository path and shared across its worktrees. It is not in version control, so a teammate’s agent — or your own laptop — never sees it.
- It records what Claude noticed, not what the team decided. A decision with a reason and a date belongs in a committed file where humans can review it, argue with it, and change it deliberately.
- It drifts like any unaudited file. Notes accumulate; some go stale. Open it with
/memorynow and then, delete what is wrong, and promote anything that has hardened into a project rule into CLAUDE.md.
The broader patterns — what coding agents remember well and what they mangle — are covered in agent memory patterns. The short version: agents handle facts, decisions, and checklists well; they handle narrative badly. Persist accordingly.
What to persist: a decision rule
When something feels worth saving, ask three questions:
- Will a future session need this to avoid redoing work or repeating a mistake?
- Can it be stated in one or two sentences without the surrounding story?
- Is it still going to be true next week?
Three yeses: persist it, in the right layer. A “no” on the last question puts it in the handoff file with a date on it. A “no” on the first means it is a diary entry, and diaries are for humans — agents drown in them.
The handoff: the highest-value habit in this article
End every significant session by writing the handoff before you close the terminal. Five minutes, fixed structure, written for a reader with no memory of today — because that reader is Thursday’s agent, and it genuinely has none.
A good handoff names the state of the work, not the story of the work: what is done and verified, what is done and not verified, what is next in order, and the traps — the approach that already failed, the file that looks wrong but is deliberately so.
Have the agent draft it, then correct it yourself. The drafting forces the agent to reconcile its own claims (“the build passes” — did it run the build?), and your corrections catch exactly the overstatements that would otherwise become next session’s false facts.
Loading the handoff at session start can be automated — a SessionStart hook that injects a short handoff note is one of the patterns in the hooks deep dive — but even pasting it manually beats reconstructing state from git logs and guesswork. When a session goes wrong mid-task, the same state-not-story discipline is what debugging agent loops uses to brief a fresh session.
Memory and handoff templates
# PROJECT MEMORY — [project name] (permanent layer; edit rarely)
## Decisions (date, decision, one-line reason)
- 2026-11-03 — Content lives in Markdown collections, not a CMS.
Reason: agent edits files directly; no API layer to maintain.
## Constraints that are not obvious from the code
- Deploy target rejects functions over [limit]; keep routes static.
## Conventions worth stating once
- [3–6 bullets maximum; if it is in CLAUDE.md, do not repeat it here]
---
# HANDOFF — [date] (working layer; REWRITE each session, never append)
## Verified done
- [thing] — verified by [build/test/eyeball], at [time]
## Done but NOT verified
- [thing] — needs [specific check] before it counts
## Next, in order
1. [next task, with the file or command it starts from]
2. [following task]
## Traps and dead ends (do not retry without a new idea)
- [approach] failed because [reason]
- [file] looks [wrong] but is deliberate because [reason]
## Open questions for the human
- [question, and what is blocked on it — or "none"]
Two structural choices matter. “Done but NOT verified” is its own section because conflating it with “done” is how unverified work calcifies into assumed fact across sessions. And the handoff is rewritten rather than appended: an appended log grows until nobody — human or agent — reads past the first screen, which recreates the original problem with extra steps.
Starting a session from the files
The layers only pay off if a fresh session actually reads them in the right order. The startup ritual is short enough to keep as a checklist:
- Read the handoff first. It names the state of the work and the next task, in order.
- Check the decisions. Skim the permanent layer for anything the handoff touches — a constraint, a convention, a definition of done.
- Confirm what loaded.
/context alllists the memory files Claude Code picked up, under Memory files; if the project file is missing from the list, nothing else in the ritual matters until that is fixed. - Start the first handoff task. Not a re-exploration of the repo — the handoff exists so the first useful action happens in minutes.
Two minutes when it goes well. When it takes twenty, one of the layers is carrying the wrong material, and the monthly re-audit is where that gets fixed.
What compaction keeps, and what it loses
Long sessions eventually meet compaction, and long projects meet it often. Per Anthropic’s documentation, Claude Code first clears older tool outputs, then summarises the conversation if it still needs room. The summary keeps your requests and key code snippets — but detailed instructions given early in the conversation may be lost.
Three controls keep that from hurting:
- Steer it in advance. A “Compact Instructions” section in CLAUDE.md tells the summariser what to preserve, and
/compactaccepts a focus directly, such as/compact focus on the API changes. - Summarise partially on purpose.
/rewindlets you summarise only part of a conversation — from a chosen message, or up to one — instead of taking the automatic pass over everything. - Keep survivors in files. Anything that must outlive compaction belongs in the permanent or working layer, not in the transcript. Compaction can only lose what exists nowhere else.
One failure mode is worth knowing: if a single huge file or tool output refills the window immediately after each summary, Claude Code stops auto-compacting after a few attempts and shows an error rather than looping. The fix is to clear or shrink the offending input, not to keep retrying.
Budgeting across weeks, practically
Re-audit monthly. Read the permanent layer and delete anything the project has outgrown; re-run the question “would a fresh agent need this in its first session?” The context budget audit is the full procedure.
For big efforts, this discipline pairs with delegation: long projects are where breaking work across subagents pays off, but only if each subagent inherits the memory files rather than a chat-history summary — files are inspectable, summaries are not. Writing subagent briefs that get used covers the brief format that carries the handoff into a delegated task.
Finally, keep one honest metric: how long does a fresh session take to become useful? Time it occasionally. If that number grows week over week, your memory system is failing no matter how tidy the files look. If it stays at a few minutes — read the handoff, check the decisions, start the next task — the budget is working, and the project can run as long as it needs to.
How we researched this
Desk research, checked November 2026. The auto memory location and loading limit, the CLAUDE.md scopes, and the compaction behaviour — including the tool-output clearing order and the stop-after-repeated-refills guard — come from Anthropic’s Claude Code documentation (the memory page and “How Claude Code works”). The layer model and templates are this site’s own framework, built to sit on top of those mechanics; no project results are claimed for them.
Over to you
The principle to remember: a long project does not need a bigger context window; it needs fewer, better files. Decisions in the permanent layer, state in a rewritten handoff, Claude’s own notes reviewed like any other file, and everything else allowed to expire.
Start at the end of your next session: five minutes, the handoff template above, state not story. Then read the context budget audit and price what your setup loads every day — the two habits together are the whole system.
Learn more:
FAQ
What should I write in a session handoff for Claude Code? Five things: what is verified done and how, what is done but unverified, what comes next in order, the traps and dead ends, and any open questions for you. Rewrite it each session rather than appending to it.
What belongs in permanent project memory versus the handoff? Permanent memory holds decisions, their reasons, and non-obvious constraints — things true for the whole project. The handoff holds this week’s working state. Exploration and narrative belong in neither; let them expire with the session.
Where should the handoff file live? In the repo, committed, next to the project memory file. A handoff on one machine’s desktop has the same weakness as auto memory — nobody else’s agent can read it — with none of auto memory’s convenience. Committed, it survives machine changes, and its history shows how the project’s state evolved.
Does auto memory replace a handoff file? No. Auto memory is Claude’s own notes, stored on one machine outside your repo; it captures corrections and preferences, not project state. It cannot tell Thursday’s session what is verified done — that is the handoff’s job.
What happens to my instructions when Claude Code compacts the conversation? The summary keeps your requests and key code snippets, but detailed instructions from early in the conversation may be lost. Persistent rules belong in CLAUDE.md, and a “Compact Instructions” section there steers what the summary preserves.
How do I know my context system is failing on a long project? Time how long a fresh session takes to become useful. If that grows week over week, sessions are re-deriving state your files should have carried.
Category: Claude Code & Context Engineering · Tags: #claude-code #context-engineering #tutorial
Next step: this article is part of Claude Code guides, which covers the full topic from first setup to advanced use.