← Practical guides to AI coding memory

Guides

How does memory work for AI coding assistants?

Understand context windows, CLAUDE.md, AGENTS.md, Cursor rules, native memories and external retrieval, including where saved context comes from.

By: Cairn

Updated:

Published:

AI coding assistants remember by bringing saved context into a later model request. Instructions supply maintained rules, native memory features save selected learning, and external stores retrieve relevant records. The context window holds the material available right now; a larger window increases working capacity, while durable storage and loading or retrieval provide continuity across conversations.

What is inside the context window?

The context window is the material the model can work with for a request. In a coding assistant, that can include your messages, file contents, command output, instructions and retrieved records. The Claude Code architecture guide, accessed 2026-11-12, explains how these inputs participate in its working context and how long conversations are compacted.

A bigger window lets the assistant consider more code or discussion together. Persistent memory answers a different question: which useful information survives and how will a future request receive it? Imagine a large desk and a filing cabinet. More desk space helps with today's task; a cabinet and a way to find the right folder support next week's task.

For example, you tell an assistant that the fictional Harbor prototype needs an offline demo. During the current conversation it can use that message directly. In a new conversation, it needs a saved instruction, note, retrieved record or other supplied source to recover that constraint.

Which kinds of saved context should I distinguish?

LayerWhere context comes fromHow it reaches a later request
Instruction filesRules maintained by peopleClient discovers and loads applicable files
Native memorySelected learning saved by the assistant's featureClient loads notes or injects relevant saved context
External memoryExplicit saves or integration-submitted contextTool retrieval or an automatic recall integration
Maintained project sourcesCode, manifests and decision documentsAssistant reads the relevant current source

These layers can work together. Put the rule for finding a test in instructions, the test command in maintained configuration, and a private preference about how results should be explained in personal memory. Give each important fact a clear home so it stays easy to update.

What do CLAUDE.md, AGENTS.md and Cursor rules do?

Instruction files are durable text the client brings into working context. They suit expectations such as “read the contribution guide before changing persistence” or “use the focused test for the changed component.” Keeping them in version control lets contributors review the same rule.

Claude Code's memory guide documents CLAUDE.md, organized rules and imports, including an @AGENTS.md import when needed. OpenAI's AGENTS.md guide describes Codex discovering global guidance and project instructions down to its working directory. Both were accessed on 2026-11-12.

Cursor's rules documentation, accessed the same day, describes user, project and team rules and the simpler AGENTS.md option. Project rules use .mdc files under .cursor/rules; their metadata controls when they apply. Use each client's documented loading mechanism and ask it to identify the rule relevant to your current task.

For a beginner, start with a short repository instruction file and links to maintained documents. Write down decisions that everyone should follow, and keep the volatile details in the actual source files. That gives a new assistant a useful entry point without filling every prompt with the entire project manual.

How do native memory features learn from previous work?

Claude Code distinguishes instructions you maintain from auto memory it writes. Auto memory uses local Markdown notes, including MEMORY.md and topic files. Its /memory panel gives you a way to inspect that saved context. This is a useful fit for learning that stays within Claude Code's documented repository and machine boundary. The source is the official memory guide.

Codex also has documented local memories, accessed 2026-11-12. They are off by default; after enabling them, eligible prior chats can become generated local memory files. Processing happens in the background after suitable idle time. In an interactive CLI session, /memories controls whether the chat uses existing memories or contributes to future ones.

For Cursor, use current rules as the maintained native path. Its 1.2 release announcement also records a Memories feature and user approvals for background-generated memories. Version-specific availability belongs in the checks below.

Native memory is convenient when one client's storage and controls meet your need. Inspect what it actually saved, especially after you correct a recurring assumption. A useful note includes its subject, scope and enough reason to distinguish an accepted decision from a suggestion.

How do external stores save and return context?

An external store separates the saved record from the assistant's current chat. With explicit saving, you request a preference or decision be kept. With automatic capture, an integration submits eligible conversation content and the memory system selects durable information. The chosen service defines scopes, record fields and retention.

Retrieval starts with a question or other task context. A search operation finds candidate records, and the returned text enters the model's working context. Some systems use keyword matching; others use semantic search or additional model processing. MCP, accessed 2026-11-12, is one standard through which assistants can access external tools and data.

For private continuity between Claude Code and Codex, Cairn.ink Memory starts with:

npx @cairn-ink/memory setup

Choose Cloud for automatic capture and prompt recall. Approve both detected CLIs, close them and finish background work before confirming sharing; one browser sign-in connects the first paired installation. Choose Local for free, no-account explicit tools on one computer. The released installer guide describes the two modes; reopen the clients afterward and review Codex's four entries in /hooks for Cloud.

Its private Memories have Source Receipts with excerpts and client metadata. Shared Knowledge Cards follow a separate review and human-authorized publication process, as described in the release documentation. This fits personal context you want to inspect and retrieve while switching supported assistants.

What should I check when a memory seems missing or wrong?

Cursor's historical Memories announcement and today's Rules page do not establish that the old Memories controls are available in every current installation. Local storage can still use external processing, including Cairn.ink Memory's model-guided semantic recall. Retrieved memories can be stale, so compare technical decisions with current maintained sources.

To diagnose a missing preference, trace the full path: the original statement, the saved record, the retrieval operation and the context actually returned. Check the correct account and scope. Save a harmless fictional preference, then retrieve it in a fresh conversation without supplying the answer. This separates a working persistence path from a plausible response based on the current prompt.

Use the connection guide when you need private memory across supported assistants.

Frequently asked questions

Is a bigger context window the same as memory?
A bigger window holds more material during the current interaction. Persistent memory also requires a durable record and a mechanism that loads or retrieves it in a later conversation.
Who writes instruction files and memories?
People usually maintain project instructions. Native memory features can generate notes from eligible interactions; external stores can accept explicit saves or context submitted by capture integrations.
What should I keep in repository files?
Maintain team rules, current build instructions and accepted architectural decisions beside the code. Personal context that follows you between assistants can use a private memory store.
How does old context return?
The client loads an instruction or memory file, retrieves a relevant record through a tool, or receives context from a prompt hook. The returned text becomes part of the current model input.

Sources