Ada → Claude Code Context

Why Claude Code loses context between sessions

Every new session is a fresh inference. Without a structured persistence layer, Claude Code rebuilds its understanding from scratch each time — and the drift compounds.


The mechanism

Claude Code has no persistent memory. When a session ends, the context window clears. The next session starts fresh.

The only thing that carries over is what is explicitly written in files the model reads at session start. For Claude Code, that is primarily CLAUDE.md. Everything else — the decisions you made, the constraints you established, the architectural choices you explained — must be re-derived from whatever is in that file.

If CLAUDE.md is sparse, Claude Code fills the gaps with inference. The inference is usually close. Close is not right.

The problem is not that Claude Code is inconsistent. It is that it is consistently doing its best with whatever information it has. If that information changes between sessions — or was never fully specified — the output changes too.


Three ways context gets lost

01

Session reset

The most common case. You end a session. The next day, you start a new one. Claude Code has no memory of yesterday's decisions. If CLAUDE.md does not contain them explicitly, they are gone. The model re-infers from the current state of the codebase and whatever context you provide in the new session.

Over multiple sessions, each re-inference introduces small errors. The errors compound. By session five or ten, the codebase reflects layers of inference, not a single coherent intent.

02

Attention dilution in long sessions

Within a single long session, context does not disappear — but it deprioritizes. A context window that starts with your project definition and constraints gradually fills with code, tool outputs, and back-and-forth. Early instructions receive proportionally less attention as the window grows.

This is not forgetting. It is attention dilution. The constraint you stated at the beginning of a long session may receive a fraction of the attention weight at the end of that same session.

03

Subagent context gap

When Claude Code spawns a subagent for a specific task, that subagent does not automatically inherit the full context of the parent session. It receives what is explicitly passed to it. Constraints, architectural decisions, and domain knowledge that live only in the conversation are not passed.

The subagent builds against its limited context. Its output is coherent within that context and inconsistent with the broader project intent.


Why CLAUDE.md alone is not enough

The instinct is to put everything in CLAUDE.md. If context is lost between sessions, write more in CLAUDE.md.

This solves one problem and creates another. CLAUDE.md is in context on every turn, which means it has to be short enough to remain signal-dense. A bloated CLAUDE.md buries the constraints under noise. Research on context length shows model performance degrades as context grows — not always linearly, but reliably.

More critically: CLAUDE.md is advisory. It tells Claude Code what you want. It cannot prevent Claude Code from doing otherwise. If it decides a constraint does not apply to the current task, it will proceed anyway.

Without persistence layer
  • Session 1: infers intent from description
  • Session 2: re-infers from changed codebase
  • Session 5: builds against 5 layers of inference
  • Constraints are advisory — ignored when inconvenient
  • Subagents get no project context
  • Long sessions dilute early instructions
With three-layer architecture
  • Every session reads the same governed CLAUDE.md
  • Domain agents carry deep context into subagent spawns
  • Hooks enforce constraints at every tool boundary
  • Constraints are structural — cannot be bypassed
  • Context is consistent across sessions and agents
  • Long sessions maintain enforcement via hooks

The three-layer fix

Solving context loss requires three layers working together. Each layer addresses a different failure mode.

01

CLAUDE.md — session persistence

Addresses: session reset

The foundation. Read on every turn, every session. Contains what the project is, what it is not, architectural decisions, and scope boundaries — dense with signal, not with history. A well-structured CLAUDE.md means every session starts from the same governed understanding, not a fresh inference.

02

Agent files — domain context

Addresses: subagent context gap

Scoped context files for each domain area. An agent for the auth system knows auth entities, constraints, and state machines — and this context is available to subagents working in that domain. Domain depth without polluting the hot layer that every session reads.

03

Pre-tool hooks — structural enforcement

Addresses: attention dilution, advisory drift

Hook files that run before Claude Code takes any tool action. They enforce constraints at the boundary where decisions are made, not in the context window where attention fluctuates. A hook does not care how long the session has been running or how far down the context window the original constraint is. It runs on every tool call.

This is the architecture Ada compiles from structured intent. Read more about context engineering for Claude Code and why each layer exists.


Frequently asked questions

Why does Claude Code forget what I told it?

Claude Code has no persistent memory between sessions. Each new session starts with a fresh context window. The only information that carries over is what is explicitly written in files it reads at session start — primarily CLAUDE.md. If your project intent, constraints, and decisions are not in a file Claude Code reads on every turn, they are lost when the session ends.

Does Claude Code have persistent memory?

Not by default. CLAUDE.md is the closest native mechanism — it is read at the start of each session. But CLAUDE.md is advisory, not structural. Without agent files and hooks, every session is a fresh inference from whatever is in that file.

How do I make Claude Code remember between sessions?

Build a structured persistence layer: CLAUDE.md for what always applies, agent files for domain-specific depth, and hooks for structural enforcement. These three layers together mean every session starts from the same governed understanding. Ada compiles all three from structured intent.

Why does Claude Code behave differently in long sessions?

Attention dilution. As the context window fills with tool outputs and back-and-forth, early instructions receive proportionally less attention weight. This is why structural enforcement via hooks matters — hooks run at every tool boundary regardless of context window length.


$ git clone https://github.com/alexrozex/ada

Three-layer context architecture. Compiled from intent. No more session drift.

Get started →