The memory layer
The context window is small and forgets everything when it resets — memory is every trick for making an agent remember across turns, sessions, and projects.
Why it's needed
The context window is a fixed budget. When a session ends, it wipes. Anything the agent should still know tomorrow has to live somewhere durable and be loaded back in at the start of the next session. That's the memory layer: a hierarchy from always-in-context rules down to an external service it queries on demand.
Without deliberate memory architecture, every session starts from zero — no knowledge of your codebase conventions, your preferences, or what happened last time. The agent isn't forgetful by design; it's forgetful by default. Memory is the fix.
The memory hierarchy
Think of it as a temperature gradient: hot at the top where thinking happens, cold at the bottom where facts are stored permanently. Recall pulls lower layers up into context; write-back pushes new facts down to persist.
Hot, small, and forgetful at the top; cold, vast, and permanent at the bottom.
The built-in layer
Claude Code ships with CLAUDE.md as its native memory primitive. It's
a Markdown file that gets loaded into context at the start of every session — no configuration
required. The hierarchy is:
- 1
Enterprise policy
Injected at the platform level — the outermost ring, overrides everything below it.
- 2
~/.claude/CLAUDE.md— user-levelYour personal rules across all projects. Coding style, preferences, things you never want the agent to do.
- 3
./CLAUDE.md— project-levelPer-repo conventions, architecture notes, the commands that matter. Committed alongside the code.
- 4
@pathimports — composable includesAny
CLAUDE.mdcan pull in other files with@path/to/file. Lets you split rules into focused modules without duplicating them.
# Project rules
@.claude/architecture.md
@.claude/conventions.md
# Quick capture — appended by /remember
Always use pnpm, never npm.
Prefer explicit types over inference in public APIs.
The quick-capture flow — a /remember-style command — appends a
new fact to the file in-session. The agent writes its own rules.
Cheap-and-static vs rich-and-learned
Two strategies coexist; knowing when to use each one matters.
Written rules
CLAUDE.md — hand-authored, always in context, zero dependencies.
You maintain it; it never surprises you. The ceiling is your own effort: if you don't write
it, it doesn't know it. Static by design.
Learned memory
An external service like Honcho observes your sessions, stores conclusions about you, and recalls only what's relevant. It evolves on its own, works cross-project, and effectively has no size limit — at the cost of a dependency and less direct control over what it retains.
Both can coexist — written rules for invariants you'll never want to change, learned memory for the living context that shifts as you and your projects evolve.
How I actually use it
My setup
I run three tiers. CLAUDE.md holds the hard rules — the things that never change, the conventions I've decided on. Per-project memory files track the state of a given codebase: what's been built, what's in-flight, the architecture decisions that would otherwise evaporate at session end. And Honcho carries who I am across every project — my preferences, my patterns, the context about me that I should never have to repeat. The three tiers don't compete; they stack. Each layer handles what the one above it can't.
Sources
- primary Claude Code — Memory (CLAUDE.md) The built-in layer: project + user memory files, imports, hierarchy.
- reading Anthropic — Context engineering for agents Why the context window is a budget, and memory is how you spend less.
- repo Honcho (plastic-labs) An external memory service: facts about the user, recalled on demand.