How to stop re-explaining your project to Claude Code every session

RoutineCode Team·2026-11-22·

Put your project's memory in a file the agent reads at the start of every session, and keep only three things in it: the rules, the decisions (with their reasons), and the causes of past failures.

In Claude Code, that file is CLAUDE.md at the root of your repository, and it's loaded automatically when a session starts. Anything you find yourself re-typing — conventions, constraints, “we tried that, it broke” — belongs there. If it isn't written down, the next session won't have it.

The rest of this post covers why the forgetting happens, what's worth keeping, what isn't, and how to set it up today with any agent.

The problem, in other people's words

This isn't a niche complaint. A few recent LinkedIn posts put it plainly:

  • Rohit T: “Your AI agent is smart. But why does it keep forgetting everything?” — 428 reactions, 28 comments.
  • Raj Shekhar Yadav: “Every time you switch agents, you have to explain the task again” — 342 reactions, 59 comments.
  • Raj Shekhar Yadav again, days later: “They forget everything when a new session starts” — 293 reactions, 62 comments.

And from the company side, Y Combinator announced FlashDrive (YC F26), described as a “shared drive for teams and all their AI agents.” That post drew 1,456 reactions and 167 comments.

Read together, these describe two versions of one problem:

  1. Across sessions. You close the terminal, open a new session tomorrow, and the agent has no idea what you decided yesterday.
  2. Across agents. You move a task from one agent to another and spend the first ten messages rebuilding context.

Both come from the same place. Fix it once and you fix it for both.

Why it happens

The model doesn't learn from your session.

When a session starts, the agent works from whatever is in its context: its instructions, the files it has read, and your messages. When the session ends, that context is gone. The model's weights didn't change because you corrected it three times about your test runner.

So when an agent seems to “remember” something, it's because some text was read back into the context. There is no other mechanism.

That reframes the question. It isn't “how do I make the agent remember?” It's two questions:

  • What should be written down?
  • What should be read back, and when?

Getting the first one wrong is the common failure. There are two ways to get it wrong.

Writing too much. Dumping the whole chat transcript into a notes file feels thorough. But a transcript mixes failed attempts with the final answer, and the next session can't tell which is current. Long, unsorted memory dilutes the parts that matter.

Writing the wrong kind of thing. Notes like “auth module is done” or “tests pass” go stale quickly. A future session reads them as fact, skips the check, and builds on something that may no longer be true.

That second failure is worse than having no memory at all. An agent with no memory asks. An agent with stale memory guesses, confidently. Memory is data, and like any data it's only useful if it's grounded and current.

What memory should keep

A useful rule: the code already says what. Memory should say why and what not to do.

That leaves three categories worth writing down.

1. Rules

The conventions a new session would otherwise break. Examples (illustrative):

  • Package manager, build command, how to run tests.
  • Naming and file-layout conventions that aren't obvious from one file.
  • Hard constraints: “never edit generated files,” “migrations are append-only.”

If you've corrected the agent on something twice, it's a rule. Write it down.

2. Decisions, with reasons

Not just what you chose, but why, and what you rejected. A decision without a reason gets undone by the next session that finds a “cleaner” approach. A short entry is enough:

Decision: Dates are stored as UTC timestamps, converted only at display. Why: Mixed time zones caused off-by-one-day bugs in reports. Rejected: Storing local time with an offset field.

The “Rejected” line is what stops the agent from proposing the same alternative next week.

3. Failures and their root causes

The expensive lessons. When something broke and you found out why, record the symptom, the cause, and how to detect it next time:

Symptom: Integration tests pass locally, fail in CI. Cause: Tests depended on file ordering, which differs across filesystems. Check: Run the suite with randomized order before pushing.

This is the category people skip, and it's the one that saves the most repeated work.

What memory should not keep

Just as important:

  • Chat transcripts. Too long, and they don't separate what worked from what didn't.
  • Anything the code already states. Function signatures, file lists, dependency versions. The agent can read those directly, and a copy in memory will drift.
  • Status claims without evidence. “Done” and “working” are not memory. If something is done, record how it was verified — the command, the test — so the next session can re-run it instead of trusting it.
  • Secrets. Keys, tokens, credentials. A memory file is plain text that gets read into context and often committed to git.

How to set it up today

This works with any agent that can read a file at session start. Claude Code does it for you with CLAUDE.md. Other tools have their own equivalent, and for those you can always point the agent at the file in your first message.

Step 1: Create one file at the repository root. In Claude Code, /init will generate a starting CLAUDE.md from your codebase. Treat that as a draft, not the finished thing.

Step 2: Give it three sections.

## Rules
- ...

## Decisions
- Decision / Why / Rejected

## Failures
- Symptom / Cause / Check

Step 3: Write to it at the end of a session, not the start. Before you close a session, ask the agent: “What did we decide or learn today that a new session would need? Add only that to the memory file, in the right section.” Then read the diff.

Step 4: Review it like code. Keep the file in git. A memory change is a change to how every future session behaves, so it deserves a look before it's committed.

Step 5: Prune. When a rule becomes enforced by a linter or a test, delete it from memory, because the tooling now carries it. When a decision is reversed, replace it rather than adding a contradicting line. Short and current beats long and complete.

Step 6: Use the same file for every agent. This is the fix for the “switching agents” version of the problem. If the knowledge lives in the repository and not in one tool's chat history, any agent you hand the task to starts from the same place.

Step 7: Tie “done” to evidence. Ask the agent to run the build and tests before it says a task is finished, and to note the command that proved it. Next session, “done” means “here is how to check,” not “someone said so.”

None of this requires a new tool. It's a file, three headings, and a habit.

RoutineCode works on the same principle

As one example of putting this into a tool: RoutineCode, the Claude Code plugin we build, is designed around the same ideas. It records project rules, decisions, and the causes of failures as work happens, keeps them after the session ends, and brings them back in the next session. Before it declares a task complete, it runs the build and tests and treats the result as the evidence. It also routes repetitive steps to smaller models and saves the deeper review for changes that carry real risk. It installs with npm install -g @routinecrew/routinecode --@routinecrew:registry=https://registry.npmjs.org. You don't need it to apply anything above; the manual setup works on its own.

What changes, and how to check it

We won't promise a number. These are the effects you can verify yourself in a week:

  • The first message of a new session gets shorter. Notice whether you're still pasting a project briefing. If you are, whatever you're pasting belongs in the file.
  • The same correction stops recurring. If you've written a rule and the agent still breaks it, the entry is unclear or buried. Rewrite it, don't repeat it in chat.
  • Known failures don't come back unnoticed. Each entry in the Failures section has a check. Whether those checks catch anything is something you can see directly.
  • Handing a task to another agent costs less. Point the second agent at the same file and see how much you still need to explain.
  • The memory itself is reviewable. Because it's a file in git, you can see exactly what every session was told and when it changed.

If none of these move, the file is probably too long or full of things the code already says. Cut it down to rules, decisions, and failures, and try again.

Agents don't forget because they're weak. They forget because nothing was written down for them to read. Give them less to read, and make all of it true.

#AIAgents #ClaudeCode #SoftwareEngineering #DeveloperTools #LLM

#aiagents#claudecode#softwareengineering#developertools#llm

Want posts like this weekly?

Subscribe for AI dev-workflow insights.