Keep Agent Memory in the Repo
A private project disables Claude Code’s automatic memory and tells new sessions to read a repository-owned MEMORY.md. Its instructions define the file’s purpose: working conventions, corrections, tooling notes, and pointers. Tasks, research, and permanent rules have other homes.
That setup makes a useful distinction for projects handled across AI sessions. An agent can retain helpful information without making the surrounding tool’s memory feature the place where that information lives. The person can inspect the project files and decide what should persist.
This post describes the setup and its trade-offs. The private memory entries weren’t read for this article. The configuration and standing instructions establish the mechanism without exposing their contents.
Define What Memory Means Here
The harness is the application around the model: it supplies instructions, runs tools, and manages sessions. Some harnesses also maintain their own notes across sessions.
Repository memory is an ordinary file that the project explicitly asks the agent to maintain. Its name doesn’t give it special powers. A new tool needs instructions to load it, and the file still consumes context when read.
The source project separates several kinds of persistent information. Instructions and skills hold durable rules. Entity records hold facts about the project. The task board holds next actions. The memory file holds corrections and working notes that help later sessions use those other records correctly.
For example, a temporary workaround for a local tool might belong in memory while it remains relevant. A required command for every contributor belongs in the permanent instructions. The outcome of a completed task belongs in the task record or journal.
Without that distinction, MEMORY.md can become another project database, queue, and instruction file at once. Keeping it explicit helps only if it remains understandable.
Disable the Automatic Feature Explicitly
The source project’s .claude/settings.json contains this setting. This is a minimal excerpt, not a replacement for an existing settings file:
{
"autoMemoryEnabled": false
}
Claude Code documents this setting in its memory guide. Merge the property into existing configuration so unrelated permissions and settings survive. This setting is specific to Claude Code; other harnesses need their own supported configuration.
The configuration disables the automatic feature. The project instructions explain the intended replacement. Both matter because “don’t use memory” alone leaves the agent without a clear place to put a useful correction.
Disabling automatic memory doesn’t erase saved conversations, disable provider-side prompt caching, or create a privacy boundary for files supplied to a model. This is a choice about where project notes are maintained.
Make Loading Part of the Entry Point
The source project tells a fresh session to read a standing brief, its agent instructions, and the explicit memory file. Its Claude entry file imports the shared instructions. That gives the memory file a route into the workflow.
Here’s a synthetic instruction block for a project choosing the same approach:
## Project memory
Read MEMORY.md when starting work in this repository.
Use it for project-specific corrections, working notes, and pointers
that will help a later session.
Keep permanent rules in AGENTS.md or a skill.
Keep facts in their source records and next actions in the task board.
Link to those records instead of copying them into memory.
Update an existing entry when a correction supersedes it.
Do not store secrets, raw conversations, or personal speculation.
Do not use harness-managed automatic memory for this project.
The update instruction prevents a running list of contradictory corrections. A later session needs the current note, with enough explanation to understand it, rather than several competing versions.
For Claude Code, a CLAUDE.md file can import shared instructions with @AGENTS.md. Its documentation describes that bridge. The repository memory file is then read because the shared instructions request it. Don’t assume an arbitrary root-level filename loads automatically in every tool.
Verify the arrangement in a fresh session. Ask the agent to identify the files it loaded and explain where it would put a hypothetical correction. A well-written policy isn’t evidence that the intended entry point is active.
Write Notes That Can Be Corrected
A useful note should state something a later session can act on and, where needed, how to verify it. Avoid turning an impression from one conversation into a permanent claim about a person or project.
For example, this invented note is more useful than a vague warning that a dashboard is fragile:
## Dashboard updates
The summary table is generated from record files.
Edit the records, then run the documented generator.
See docs/dashboard.md for the current command.
The pointer avoids duplicating a command that might change. If this rule becomes central to routine work, promote it to the standing instructions and remove the memory entry.
Other notes may need a date or a condition for removal. A workaround can say which tool behavior prompted it and when to check again. A preference should reflect an explicit correction, with its scope preserved. “Use brief status updates for this workflow” is narrower than an invented claim that the person always wants short answers.
Memory is a proposal about what future sessions should carry. It deserves the same factual care as any other project document.
Use Git Where Sharing Is Appropriate
A repository-owned file can be reviewed, diffed, and reverted with the rest of the project. If it is committed and available in another checkout, another tool can use the same notes through its entry instructions.
That portability has limits. Uncommitted notes don’t automatically appear in another checkout. Two sessions can edit the same entry differently. A file copied to another environment may point to paths that don’t exist there.
Treat memory edits as ordinary project changes. Review the diff for scope and accuracy. Resolve conflicting notes by checking the underlying fact, rather than preserving both versions merely because both agents wrote them.
Version control also preserves history. Use repository memory only for information appropriate to that repository’s audience. Keep credentials and sensitive personal material out of shared project notes. A private project isn’t a reason to copy everything the agent has seen into a permanent file.
Keep the File Small Enough to Read
Making memory explicit doesn’t make it cheap. If each session reads a growing file, those notes become recurring input. Duplicated research can overwhelm the small corrections that justified the file.
Review entries when the project changes. Remove resolved workarounds, move established rules into instructions, and replace repeated facts with pointers. Put detailed research in its own record so the agent reads it when the task requires it.
There is no measured token saving in the source material reviewed for this article. A curated memory file may reduce repeated explanations. A large or stale one may add reading and correction work. Its size and usefulness need attention over time.
The session handoff serves a different timescale. It describes the next assignment. Repository memory describes selected knowledge that should remain useful across assignments. Keeping those purposes separate gives temporary state somewhere to expire.
What This Setup Changes
The source configuration turns off automatic memory, and the project instructions name an explicit replacement. Those choices make the intended location and reading procedure inspectable. They don’t prove perfect compliance or better recall.
The benefit is editorial control over persistent notes. The cost is maintaining the file, loading it through each tool’s entry point, and removing material that no longer belongs there.
For a project with little recurring context, ordinary instructions and source records may be enough. Add a separate memory file when there is a useful category of working knowledge that those documents aren’t already handling.
Lessons Learned
- Check the startup path in a fresh session before relying on a repository file to carry context.
- Preserve the scope of a correction instead of generalizing it into a permanent preference.
- Move established rules into maintained instructions and remove the duplicate note.
- Review persistent notes for both present usefulness and suitability for the repository’s audience.