Claude-memory-Skill: Entscheidungen samt Gründen speichern, vor Entscheidungen abrufen

Dmitriy Solodukha, Caprock-Entwickler · Veröffentlicht am

Am mit Claude Code und Codex getestet

Ein Claude-memory-Skill für jeden Agenten: eine datierte Entscheidung samt Grund pro Eintrag, im Repository gespeichert und vor neuen Entscheidungen durchsucht.

Der memory-Skill ist ein Claude-memory-Skill, der in Claude Code, Codex, OpenCode und Cursor gleich funktioniert: Er speichert eine Entscheidung, eine nicht offensichtliche Erkenntnis oder eine Präferenz als datierten Eintrag samt Grund in docs/memory/ oder einer MEMORY.md im Repository und durchsucht diese Einträge, bevor er etwas entscheidet, das du möglicherweise schon entschieden hast. Eine Erinnerung ist eine Aussage über die Vergangenheit; deshalb prüft er jede anhand des Codes, bevor er ihr folgt.

Installiere den memory-Skill

Ein Befehl pro Agent. Der Skill ist eine einzelne SKILL.md; bei der Installation wird nichts ausgeführt.

Alle neun Skills als Plugin. Gib dies in Claude Code ein:

Oder nur diesen Skill, im Projektordner in einem Terminal:

Füge -g hinzu, um ihn für jedes Projekt zu installieren.

Prompts für den memory-Skill

Der Agent wählt den Skill, wenn deine Worte zu dessen Beschreibung passen; mit dem Namen stellst du es sicher. Klicke auf einen Prompt, um ihn zu kopieren.

So speichert und erinnert sich der Claude-memory-Skill

  • Ein Fakt pro Eintrag: ein Titel mit einem absoluten Datum, dann Decision, Finding oder Preference, die Begründung (und wer es gesagt hat), der Geltungsbereich und was dadurch ersetzt wird. Ein alter Eintrag wird als ersetzt markiert, niemals gelöscht.
  • Wo: der bereits im Repository genutzte Ort (docs/memory/, MEMORY.md, docs/adr/); falls keiner vorhanden ist, docs/memory/YYYY-MM-DD-short-title.md, eine Datei pro Eintrag. Eine Regel für jede Session bekommt außerdem eine Zeile in CLAUDE.md oder AGENTS.md.
  • Vor Entscheidungen nachsehen: suchen (mit Caprock: current_decisions und search_memories; ohne: die Gedächtnisdateien und git log --grep), den Treffer vollständig lesen, am Code prüfen, dann befolgen, einen Widerspruch melden oder bei geänderter Meinung ersetzen.

Gedächtnisdateien gehören zum Repository: committet, geprüft und für alle sichtbar, die es lesen können.

Was wir ausgeführt haben und was die Agenten taten

Jeder Skill wurde am 29. November 2026 in einem eigens dafür angelegten Wegwerf-Repository ausgeführt und als Projekt-Skill installiert. Ein kleines Repository, dessen store/db.py sqlite3 nutzt.

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.

Rief memory auf, erstellte docs/memory/2026-11-29-sqlite-store.md im Skill-Format, prüfte sie anhand von store/db.py und erklärte, dass Caprocks 2nd Brain über MCP schreibgeschützt ist und wie man den Ordner dorthin importiert. Er schrieb außerdem in Claude Codes eigenes Auto-Memory außerhalb des Repositorys.

Codex (0.163.0, codex exec)

The same prompt, plus: "what did we already decide about the database?"

Las den Skill, rief Caprocks current_decisions und search_memories auf, durchsuchte die Dateien, fand den Eintrag, prüfte ihn anhand des Codes und schrieb kein Duplikat.

Agenten, mit denen er getestet wurde

  • Claude Code: am 29. November 2026 mit claude -p --model sonnet getestet, der Skill als Projekt-Skill in .claude/skills/ installiert.
  • Codex: am 29. November 2026 mit Codex 0.163.0 (codex exec) getestet, der Skill in .agents/skills/.
  • OpenCode und Cursor: nicht getestet. Der Skill besteht aus reinen Anweisungen im offenen Agent-Skills-Format, wurde aber mit keinem der beiden erprobt.

Grenzen

  • Er kann nicht in Caprocks 2nd Brain speichern: Caprocks MCP-Tools sind schreibgeschützt. Dort importierte Dateien erreichen Agenten erst, nachdem du das aktiviert hast.
  • Ein Gedächtnisordner wird nur gelesen, wenn ein Agent nachsieht; Regeln für jede Session gehören in CLAUDE.md oder AGENTS.md.
  • In einem öffentlichen Repository sind die Einträge öffentlich; der Skill lässt private Details weg und weist darauf hin.

Mit und ohne Caprock

Wenn der Caprock-MCP-Server verbunden ist, ruft der Skill Erinnerungen über current_decisions, search_memories, get_memory und next_session_handoff ab, die Caprocks 2nd Brain mit Entscheidungen und Erkenntnissen lesen. Er speichert in beiden Fällen in Dateien. Caprock ist die kostenlose Open-Source-App, die jede Coding-Agent-Session auf deinem Computer aufzeichnet.

Caprock holen →

Die vollständige SKILL.md

Die Datei aus dspv/skills in Revision dfce799. Zur manuellen Installation speicherst du sie in deinem Projekt als .claude/skills/memory/SKILL.md für Claude Code oder .agents/skills/memory/SKILL.md für Codex.

skills/memory/SKILL.md
---
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.
```

Fragen zum memory-Skill

Was ist ein Claude-memory-Skill?
Ein Skill, der Claude Code sagt, was zwischen Sessions erhalten bleiben soll und wie: eine datierte Entscheidung oder Erkenntnis samt Grund pro Eintrag, dort gespeichert, wo die nächste Session nachsieht, und vor neuen Entscheidungen durchsucht.
Wie unterscheidet sich dieser memory-Skill von CLAUDE.md?
`CLAUDE.md` wird in jede Session geladen und enthält deshalb Regeln. Der memory-Skill hält Entscheidungen und Erkenntnisse als separate Einträge fest, die bei Bedarf durchsucht werden, und ergänzt `CLAUDE.md` nur um eine Zeile für eine Regel, die jede Session befolgen muss.
Funktioniert der memory-Skill in Codex?
Ja. Codex 0.163.0 rief damit im Test vom 29. November 2026 eine gespeicherte Entscheidung ab und schrieb kein Duplikat.
Speichert er Geheimnisse, die ich einfüge?
Nein. Tokens, Passwörter und personenbezogene Daten anderer werden niemals gespeichert, auch nicht auf Bitte; der Skill erklärt, warum.

Quellen

Die App selbst ist auf Englisch.