Claude memory skill: save decisions with their why, recall them before deciding
Dmitriy Solodukha, Caprock's developer · Published
Tested on Claude Code and Codex
A Claude memory skill that works in any agent: one dated decision per entry with its why, saved in the repository, and searched before deciding again.
The memory skill is a Claude memory skill that works the same in Claude Code, Codex, OpenCode and Cursor: it saves a decision, a non-obvious finding or a preference as one dated entry with its reason, in docs/memory/ or a MEMORY.md in the repository, and searches those entries before deciding anything you may already have decided. A memory is a claim about the past, so it checks each one against the code before following it.
Install the memory skill
One command per agent. The skill is a single SKILL.md; nothing runs on install.
All nine skills as a plugin. Type these inside Claude Code:
Or this skill alone, from your project's folder in a terminal:
Add -g to install it for every project.
From your project's folder, in a terminal:
Add -g to install it for every project.
From your project's folder, in a terminal:
Add -g to install it for every project. Not tested on OpenCode yet: the skill is plain instructions in the open format, but no run on OpenCode has checked it.
From your project's folder, in a terminal:
Add -g to install it for every project. Not tested on Cursor yet: the skill is plain instructions in the open format, but no run on Cursor has checked it.
Prompts that use the memory skill
The agent picks the skill when your words match its description; naming it makes sure. Click a prompt to copy it.
How the Claude memory skill saves and recalls
- One fact per entry: a title with an absolute date, then Decision, Finding or Preference, the why (and who said it), where it applies, and what it supersedes. An old entry is marked superseded, never deleted.
- Where: the place the repository already uses (
docs/memory/,MEMORY.md,docs/adr/); if none,docs/memory/YYYY-MM-DD-short-title.md, one file per entry. A rule every session must follow also gets one line inCLAUDE.mdorAGENTS.md. - Recall before deciding: search (with Caprock,
current_decisionsandsearch_memories; without, the memory files andgit log --grep), read the match in full, check it against the code, then follow it, flag a contradiction, or supersede it when you change your mind.
Memory files are part of the repository: committed, reviewed, visible to everyone who can read it.
What we ran, and what the agents did
Each skill was run on 2026-11-29 in a throwaway repository made for it, with the skill installed as a project skill. A small repository whose store/db.py uses sqlite3.
Claude Code (claude -p --model sonnet)
Remember this decision: the store stays on SQLite, not Postgres, because it's a single-user local app with no server. Save it so the next session knows.
Invoked memory, created docs/memory/2026-11-29-sqlite-store.md in the skill's format, checked it against store/db.py, and said that Caprock's 2nd Brain is read-only through MCP and how to import the folder there. It also wrote to Claude Code's own auto-memory, outside the repository.
Codex (0.163.0, codex exec)
The same prompt, plus: "what did we already decide about the database?"
Read the skill, called Caprock's current_decisions and search_memories, searched the files, found the entry, checked it against the code, and did not write a duplicate.
Agents it was tested on
- Claude Code: tested on 2026-11-29 with
claude -p --model sonnet, the skill installed as a project skill in.claude/skills/. - Codex: tested on 2026-11-29 with Codex 0.163.0 (
codex exec), the skill in.agents/skills/. - OpenCode and Cursor: not tested. The skill is plain instructions in the open Agent Skills format, but no run on either has checked it.
Limits
- It cannot save into Caprock's 2nd Brain: Caprock's MCP tools are read-only. Files you import there reach agents only after you turn that on.
- A memory folder is read only when an agent looks; rules for every session belong in
CLAUDE.mdorAGENTS.md. - In a public repository the entries are public; the skill leaves private details out and says so.
With Caprock, and without it
When the Caprock MCP server is connected, the skill recalls through current_decisions, search_memories, get_memory and next_session_handoff, which read Caprock's 2nd Brain of decisions and findings. It saves to files either way. Caprock is the free, open-source app that records every coding-agent session on your computer.
The full SKILL.md
The file as it is in dspv/skills at revision dfce799. To install it by hand, save it as .claude/skills/memory/SKILL.md for Claude Code or .agents/skills/memory/SKILL.md for Codex, in your project.
---
name: memory
description: >-
Keep decisions and findings across coding-agent sessions, and recall them before deciding again.
Use when the user says "remember this", "save this decision", "note that", "what did we decide
about X", "did we already try this", "why did we do it this way", or when a session settles a
decision, finds a non-obvious fact or hears a preference worth keeping. A claude memory skill
that works the same in Claude Code, Codex, OpenCode and Cursor: one dated fact per entry with
its why, stored in a docs/memory/ folder or a MEMORY.md in the repository, and read through
Caprock 2nd Brain's MCP tools (search_memories, get_memory, current_decisions) when present.
license: Apache-2.0
---
# Memory
Keep what a later session would otherwise have to rediscover or ask again, and look it up before
deciding anything the user may already have decided. A memory is a claim about the past: check it
against the code before relying on it.
## When to save
Save one entry when any of these happens:
- **A decision and its why.** "Use SQLite, not Postgres: one user, no server." The why is the part
that stops a later session from reopening it.
- **A non-obvious fact.** Something that cost time to learn and is not visible in the code: a
flaky test and its cause, an API quirk, a command that must run first, a dead end already tried.
- **A user preference.** How they want work done: "never commit to master", "short replies",
"ask before adding a dependency".
- **The user asks**: "remember", "save", "note that", "keep in mind".
Do not save:
- What the code, `git log` or the docs already say. Point to them instead.
- Secrets, tokens, passwords, personal data of other people. Never, even when asked; say why.
- Guesses, plans that were not agreed, or the step-by-step of the current task.
- Anything that holds only for this session.
## How to write an entry
One fact per entry, so it can be found, read and replaced on its own:
```markdown
## 2026-11-29: Use SQLite for the local store
- Decision: the local store is SQLite in `data/app.db`, not Postgres.
- Why: one user per install, no server to run; the user said so on 2026-11-29.
- Scope: `store/`. Revisit if the app gets a hosted multi-user mode.
- Supersedes: none.
```
Rules for every entry:
- **Absolute date** (`2026-11-29`), never "today" or "last week".
- **Kind** in the first word of the body: Decision, Finding or Preference.
- **Why**, and who said it when it came from the user.
- **Where it applies**: files, module or command, so a reader can check it.
- **Supersedes** when it replaces an older entry. Mark the old one
`Superseded by 2026-11-29: <title>`; do not delete it, the history is the why.
- Short: a title and two to five lines. A long story goes in the repository's docs, and the entry
links to it.
## Where to save
Pick the first that applies, and say which one you used:
1. **The place the repository already uses.** Look for `docs/memory/`, `MEMORY.md`,
`docs/decisions/`, `docs/adr/` or a decisions section in `CLAUDE.md` or `AGENTS.md`. Follow its
format, even when it differs from the one above.
2. **Nothing yet**: create `docs/memory/` with one file per entry, named
`YYYY-MM-DD-short-title.md` (for example `docs/memory/2026-11-29-sqlite-store.md`). One file per
entry keeps merges clean and lets each entry be replaced alone.
3. **A small repository, or the user prefers one file**: a `MEMORY.md` at the root, newest entry
first.
A rule that every session must follow (a preference like "never push to master") also gets one line
in the agent instruction file the repository uses (`CLAUDE.md`, `AGENTS.md`), because that file is
loaded into every session and a memory folder is read only when someone looks.
Memory files are part of the repository: they are committed, reviewed and visible to everyone who
can read it. Before writing to a public repository, leave out anything private and say so.
## Caprock 2nd Brain
When the Caprock MCP tools are available (a server named `caprock`), use them to recall. Caprock
(<https://caprock.dev>, free, open source, runs locally) records the agent sessions on the computer
and keeps a 2nd Brain of their decisions and findings.
Its MCP tools are read-only: an agent cannot save into 2nd Brain through them. Save to files as
above. 2nd Brain gets memories in its own ways: it builds them from finished sessions when the user
has switched that on, from lines the user drops in by hand, and from a Markdown folder imported on
its 2nd Brain screen (Import from Obsidian, which also takes a plain folder such as `docs/memory/`).
An imported folder reaches agents only after the user turns on "Let agents use these notes" for it.
Do not tell the user a file you wrote is in 2nd Brain unless one of those is true.
Tools to use, with their arguments:
- `current_decisions(project?, limit?)`: the decisions in force for a project, newest first, with
superseded ones left out. `project` is the repository folder's name; omitted, the repository the
server was started in.
- `search_memories(query, project?, limit?)`: ranked candidates with kind, date, project and a
summary. Titles may be in the user's language; keywords are English. Judge by meaning; if nothing
fits, retry with other words, fewer words or the component's name.
- `get_memory(id)`: one memory in full, with its links. A memory with `superseded_by` is no longer
current: read the one it names.
- `next_session_handoff(repo?)`: what Caprock hands a new session in this repository.
## Recall before deciding
Before choosing a library, changing an approach, reverting something or asking the user a question
they may have answered:
1. **Search.** With Caprock: `current_decisions` for the project, then `search_memories` with the
subject's words. Without it: search the memory files (`docs/memory/`, `MEMORY.md`, decision
records, `CLAUDE.md`, `AGENTS.md`) for the subject's words, and `git log --grep=<word>` for the
commit that made the change.
2. **Read the match in full** (`get_memory`, or open the file). Follow any supersedes link to the
newest entry.
3. **Check it against the code.** Memories go stale: the file moved, the dependency was swapped,
the flag was removed. Open the files the entry names and confirm it still holds.
4. **Act on what you found**:
- It holds: follow it, and say "Following the decision of 2026-11-29: ...".
- The code contradicts it: say so, follow the code for now, and ask whether to update the
memory. When the user agrees, write a new entry that supersedes the old one.
- The user wants to change it: do what they say, then write the new decision with
`Supersedes:` pointing at the old one.
- Nothing found: decide as usual. If it is worth keeping, save it.
Stop searching after two or three phrasings with no fitting result; say nothing was found rather
than stretching a weak match.
## Output
After saving, one or two lines:
```text
Saved to docs/memory/2026-11-29-sqlite-store.md: Decision, use SQLite for the local store
(why: one user, no server). Supersedes nothing.
```
After recalling, cite the source and its date, and whether it was checked:
```text
Found: Decision 2026-11-29, "Use SQLite for the local store" (docs/memory/2026-11-29-sqlite-store.md).
Checked: store/db.go still opens data/app.db. Following it.
```
Questions about the memory skill
- What is a Claude memory skill?
- A skill that tells Claude Code what to keep between sessions and how: one dated decision or finding per entry, with its reason, saved where the next session will look, and searched before deciding again.
- How is this memory skill different from CLAUDE.md?
- `CLAUDE.md` is loaded into every session, so it holds rules. The memory skill keeps decisions and findings as separate entries that are searched when relevant, and adds one line to `CLAUDE.md` only for a rule every session must follow.
- Does the memory skill work in Codex?
- Yes. Codex 0.163.0 recalled a saved decision through it in the test of 2026-11-29 and did not write a duplicate.
- Will it save secrets I paste?
- No. Tokens, passwords and other people's personal data are never saved, even when asked; the skill says why.