# Agent memory

> Canonical: https://skillalmanac.com/glossary/agent-memory | Last verified: 2026-11-25 | Index status: index-eligible

Agent memory is information retained for use across turns or sessions. Applications may store files, conversation state or database records and retrieve relevant material into context. This application-managed state is distinct from knowledge learned in model parameters.

Also called: AI agent memory, memory in AI agents, long-term memory AI agent, agent long-term memory, Claude Code memory.

## In plain language

An AI agent does not remember yesterday by default. Each session in Claude Code, for example, begins with a fresh context window, which is the amount of text the model can consider at once. In Claude Code's documented file mechanisms, memory can include notes loaded at startup or read when needed, such as a file of project rules you write, or notes the agent writes about your corrections. Think of leaving a sticky note on the door for your future self. Other agent systems can use databases and retrieval-backed memory. A limit of the file-note approach is that notes are context the model reads, so it may not follow them, and long notes crowd out room for the actual work. Never store secrets in them.

## Technical definition

Anthropic's Claude Code documentation describes two mechanisms. CLAUDE.md files hold instructions you write and load into every session. Auto memory holds notes Claude writes itself; when it is on, the first 200 lines or 25KB of a MEMORY.md file, whichever comes first, load at session start. Separate topic files are read on demand, not all loaded at startup. The documentation says both are treated as context, not enforced configuration, and recommends a PreToolUse hook to block an action regardless of what Claude decides. Anthropic's Building effective agents post describes memory as one of three augmentations, with retrieval and tools, of the augmented LLM, in which the model can decide what information to retain.

## How it shows up when you use agents

The Claude Code mechanisms described here use files. You write instructions in a CLAUDE.md file, and with auto memory on, Claude also saves notes of its own. Applicable instruction files and the bounded MEMORY.md index can enter the [context window](/glossary/context-window) at startup; topic files are read on demand. Loading also depends on scope and settings. Retained text competes with the task for space. Anthropic's documentation advises keeping each CLAUDE.md file short and specific, because longer files consume more context and reduce adherence.

What breaks when it is misunderstood:

- **Expecting recall.** People assume the agent "learned" something permanently, when recall instead depends on supplied context, accessible stores/tools and the model's previously learned parameters. Saving a note does not by itself retrain the model.
- **Treating notes as rules.** The documentation says these files are context, not enforced configuration. To block an action every time, use a hook or a permission rule.
- **Stale notes.** An old note about a file layout can mislead the next session.

Next actions: run `/memory` to see what is loaded, trim lines that are not project-specific, and write a [handoff note](/skills/skill-almanac/session-handoff-notes) when you stop mid-task. For the design of what to load and when, see [context engineering](/glossary/context-engineering). Do not put credentials in memory files.

## Common confusions

- **Agent memory versus the context window.** The context window is what the model sees right now. Memory is what is stored so it can be loaded into a later window.
- **Agent memory versus retrieval.** Memory can itself use retrieval: LangGraph documents stores with semantic search and filtering. File-index loading is one mechanism, while [retrieval-augmented generation](/glossary/retrieval-augmented-generation) can fetch relevant external passages, including stored memories.
- **CLAUDE.md versus auto memory.** You write the first; Claude writes the second.
- **Myth.** The model is retrained by your corrections. Memory changes what is in the prompt, not the model's weights.

## Worked examples in this catalogue

### [session-handoff-notes](https://skillalmanac.com/skills/skill-almanac/session-handoff-notes)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: A handoff note that the next coding-agent session can act on, checked for evidence, paths and vague items.

Why it exercises the concept: It is memory written by hand for one purpose: carrying the state of unfinished work from one session to the next.

### [agent-instruction-files](https://skillalmanac.com/skills/skill-almanac/agent-instruction-files)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Instruction files where every line is project-specific, verified against the repo, and worth loading on every session.

Why it exercises the concept: Instruction files such as CLAUDE.md are the main kind of persistent memory in Claude Code, and this skill addresses what belongs in them.

### [caveman-compress](https://skillalmanac.com/skills/juliusbrussee/caveman-compress)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Rewrites memory and instruction files in compact language to save input tokens.

Why it exercises the concept: This pinned skill proposes compact rewrites of natural-language memory files, sends the full file text to its configured model provider and keeps an out-of-tree backup. Review meaning and instructions after compression; token savings and faithful preservation are not guaranteed here. Illustrative, not executed.

### [Claude Code](https://skillalmanac.com/tools/claude-code)

```
/memory
```

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: Claude Code lets you browse and open memory files from within a session and toggle auto memory.

Why it exercises the concept: It is the direct way to see what the agent will carry into its next session.

## Related terms

- [AI agent](https://skillalmanac.com/glossary/ai-agent.md)
- [Context window](https://skillalmanac.com/glossary/context-window.md)
- [Agent harness](https://skillalmanac.com/glossary/agent-harness.md)
- [Agent skill](https://skillalmanac.com/glossary/agent-skill.md)
- [Retrieval-augmented generation (RAG)](https://skillalmanac.com/glossary/retrieval-augmented-generation.md)
- [Context engineering](https://skillalmanac.com/glossary/context-engineering.md)
- [Memory (chat assistant feature)](https://skillalmanac.com/glossary/memory-feature.md)
- [Letta (MemGPT)](https://skillalmanac.com/glossary/letta.md)
- [Mem0](https://skillalmanac.com/glossary/mem0.md)

## Sources

- [How Claude remembers your project](https://code.claude.com/docs/en/memory), Anthropic (Claude Code Docs) (accessed 2026-11-23)
- [Building effective agents](https://www.anthropic.com/engineering/building-effective-agents), Anthropic (accessed 2026-11-23)
- [Memory overview: stores, retrieval and thread state](https://docs.langchain.com/oss/python/concepts/memory), LangChain documentation (accessed 2026-11-25)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-25. [Glossary index](https://skillalmanac.com/glossary.md).
