Guides
Claude Code memory across sessions: setup and a fresh-session check
Set up Claude Code memory with Cairn.ink Memory, save a harmless preference, and verify its ID and source in a fresh session.
For Claude Code memory across sessions, run npx @cairn-ink/memory setup and choose Cloud for automatic capture and prompt recall through Cairn.ink Memory. Save one harmless preference, then retrieve it in a fresh session and compare its identifier and source. Choose Local for automatic conversation saving on one computer without an account.
How do I set up automatic memory for Claude Code?
Start with one preference you repeatedly explain, such as how you want a review to begin. Keep the first test small enough to recognize when it comes back. The released installer documentation provides the main setup path:
npx @cairn-ink/memory setup
Choose Cloud at the location question. The installer detects Claude Code and Codex, asks about new connections and updates existing connections. Approve the tools you want to use. For a first paired installation, fully close both tools, wait for background work to finish, and complete the displayed browser sign-in and one-time code. One browser grant connects both clients, and the installer's memory ID connects the same project across them.
Setup installs the Claude Code plugin. Reopen Claude Code after it finishes. The plugin recalls relevant Memories before prompts and captures conversation context after turns. A Memory is a private, user-owned preference, decision or other useful context. A Source Receipt is the source excerpt and client metadata explaining why that Memory exists.
If the browser cannot open on this machine, follow the installer's documented alternative:
npx @cairn-ink/memory setup --no-browser --no-clipboard
Use the displayed device page on another device. The release README also documents manual hosted MCP connections for explicit tools; use those when you specifically want a manual connection.
What should I ask it to remember first?
Use a synthetic example with a distinctive subject. In the first Claude Code session, ask:
Use remember_memory to save this privately in personal scope:
For the fictional Harbor demo, run the existing focused test before a broad refactor and explain what it covers.
Show the saved Memory ID and Source Receipt.
Look at the actual remember_memory result. Keep its identifier and source excerpt in a temporary note for your own comparison. Personal scope follows your account across projects, which makes it useful for a first test that is independent of project identity.
Automatic capture is useful during ordinary work, while an explicit save gives this initial check a clear starting point. Use a short preference rather than an entire project transcript. Include the condition that makes it relevant: here, a broad refactor. That wording gives a later query a concrete subject to search for.
For a project-private Memory, use the opaque project identity supplied by the supported setup. The installer links the identity across Claude Code and Codex. Keep folder names and repository labels as descriptive text; use the configured identity for scope.
How do I verify it survives a fresh session?
End the first conversation and start a genuinely new one. Leave the saved answer in your comparison note, outside the new prompt. Ask:
Use recall_memory to find my focused-test preference for the fictional Harbor demo.
Show the Memory ID, wording and Source Receipt returned by the tool.
Compare the response with the original save. The identifier should identify the saved Memory, and the wording and receipt should match the preference you intended to keep. Read the receipt before acting on a remembered instruction. This establishes a clear path from one save to one later retrieval.
Then check automatic behavior separately. Mention another harmless preference in ordinary conversation, let the turn and background work finish, and ask about it in a fresh session. Inspect which context was actually captured and recalled. Keeping the explicit test and automatic test separate helps locate a problem: storage, retrieval, or automatic integration.
Run the local setup report as an additional diagnostic:
npx @cairn-ink/memory status
Inside Claude Code, the plugin also provides:
/cairn-memory:status
Record the selected mode and connected clients alongside the save-and-recall result. If you use Codex too, review its four Cairn hooks in /hooks after setup and run the same retrieval there.
What belongs in native instructions instead?
The Claude Code memory documentation, accessed 2026-11-12, distinguishes instructions you maintain from auto memory written by Claude. Project CLAUDE.md instructions suit team conventions. Personal ~/.claude/CLAUDE.md instructions can carry your Claude Code preferences across projects. Native auto memory keeps repository learning and is shared across that repository's worktrees.
Give each recurring fact a clear home. A personal testing preference can be useful private context; the runtime version and actual test command belong in package.json or maintained CI configuration. A team decision belongs in the reviewed project record or the intended collection's Knowledge Cards. Saving a private Memory keeps it within its owner's Memory lifecycle.
For example, the Harbor preference says to start with a focused test. When work begins, read the current repository to choose that test and determine the correct command. Review the current code before deciding whether the preference fits this change.
How can I choose Local or pause cloud capture?
Choose Local during initial setup for free, no-account use on one computer:
npx @cairn-ink/memory setup --local
Local registers cairn-local and uses a shared database and owner for Claude Code and Codex, normally at ~/.cairn-memory/data/memory.sqlite. Local is free and needs no account: it automatically saves Claude Code conversations on Linux/WSL/macOS and Codex conversations on Linux/WSL as plaintext on this computer, without cross-computer sync; memory saves and recall are on request. Capture can be disabled. If the local server can see an OPENAI_API_KEY, memories and search text go to OpenAI. Saving and inspecting need no model key; semantic recall uses a configured model provider. To check local persistence first, save a harmless record and use inspect_memory from a fresh session to inspect it.
For Cloud, review the privacy controls. The plugin can capture ordinary conversation text, including pasted terminal output or file contents. For a paired installation, these commands pause and resume capture; a Claude-only installation prints the relevant plugin command:
npx @cairn-ink/memory pause
npx @cairn-ink/memory resume
What should I check before relying on the result?
Recall can miss a relevant Memory, so check the account, connection, query and scope when a test returns nothing. status reads local state and does not verify remote service or hooks. A Source Receipt explains origin rather than current correctness; compare technical claims with maintained files. Keep secrets and private conversation dumps out of connected chats because local masking is best-effort.
Set up your chosen path with the connection guide.
Frequently asked questions
- How do I start automatic Claude Code memory?
- Run npx @cairn-ink/memory setup, choose Cloud, approve the connection and sign in through the browser. Reopen Claude Code after setup.
- Can I use memory without a Cairn account?
- Choose Local for automatic conversation saving on one computer, with memory saves and recall on request. Both supported clients share a database and owner; semantic recall needs a configured model key.
- What should I compare in a fresh session?
- Compare the actual tool result with the saved Memory ID, wording and Source Receipt. Keep the saved answer out of the retrieval prompt.
- Where should project rules live?
- Use maintained repository instructions for team rules and package or CI configuration for current technical facts. Use private Memory for reusable personal context.