Claudeメモリスキル:決定と理由を保存し、判断前に参照

Dmitriy Solodukha、Caprock開発者 · 公開日

にClaude CodeとCodexでテスト済み

各エージェントで使えるClaudeメモリスキル。理由付きの決定を日付付きで1件ずつリポジトリに保存し、再び判断する前に検索します。

memoryはClaude Code、Codex、OpenCode、Cursorで同じように動くClaude向けメモリスキルです。決定、明らかではない発見、好みを、日付と理由付きの1件の記録として、リポジトリのdocs/memory/またはMEMORY.mdに保存します。既に決めたかもしれないことを決める前に、これらを検索します。メモリは過去についての主張なので、従う前にそれぞれコードと照合します。

memoryスキルをインストールする

エージェントごとに1コマンド。スキルはSKILL.md 1ファイルで、インストール時に何も実行しません。

9スキルをプラグインとして導入します。Claude Code内で次を入力してください:

このスキルだけを導入する場合は、プロジェクトのフォルダーで次を実行します:

全プロジェクトに導入するには -g を追加します。

memoryスキルを使うプロンプト

依頼の内容が説明と合うと、エージェントがスキルを選びます。名前を指定すると確実です。プロンプトをクリックしてコピーできます。

Claudeメモリスキルの保存・参照方法

  • 1記録に1つの事実:絶対日付付きのタイトル、Decision・Finding・Preferenceのいずれか、理由と発言者、適用範囲、置き換える記録を記します。古い記録は削除せず、置き換え済みと明記します。
  • 保存先:リポジトリで既に使っている場所(docs/memory/、MEMORY.md、docs/adr/)に保存します。なければdocs/memory/YYYY-MM-DD-short-title.mdに、1件につき1ファイルで保存します。毎セッション守るルールはCLAUDE.mdまたはAGENTS.mdにも1行追加します。
  • 判断の前に参照:Caprockがあればcurrent_decisionsとsearch_memories、なければメモリファイルとgit log --grepで検索します。一致した記録を全文読み、コードと照合してから従うか、矛盾を示すか、ユーザーの考えが変わった場合は新しい決定で置き換えます。

メモリファイルはリポジトリの一部です。commit・レビューの対象となり、リポジトリを読める全員が参照できます。

実行したテストとエージェントの動作

各スキルは2026年11月29日に、専用の使い捨てリポジトリへプロジェクトスキルとしてインストールして実行しました。store/db.pyが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.

memoryを呼び、スキルの書式でdocs/memory/2026-11-29-sqlite-store.mdを作成してstore/db.pyと照合しました。Caprockの2nd BrainはMCP経由では読み取り専用であることと、フォルダーの取り込み方法を説明しました。リポジトリ外のClaude Code自身のauto-memoryにも書き込みました。

Codex (0.163.0, codex exec)

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

スキルを読み、Caprockのcurrent_decisionsとsearch_memoriesを呼び出してファイルを検索し、該当する記録を見つけてコードと照合しました。重複は書き込みませんでした。

検証したエージェント

  • Claude Code:2026年11月29日に、.claude/skills/にプロジェクトスキルとしてインストールし、claude -p --model sonnetで検証しました。
  • Codex:2026年11月29日にCodex 0.163.0(codex exec)、.agents/skills/内のスキルで検証しました。
  • OpenCodeとCursor:未検証です。オープンなAgent Skills形式の通常の指示ですが、どちらでも実行して確認していません。

制限

  • Caprockの2nd Brainには保存できません。MCPツールは読み取り専用です。インポートしたファイルをエージェントに渡すには、別途有効化が必要です。
  • メモリフォルダーはエージェントが見に行ったときだけ読まれます。毎セッションのルールはCLAUDE.mdまたはAGENTS.mdに置きます。
  • 公開リポジトリでは記録も公開されます。個人的な情報は省き、その旨を伝えます。

Caprockがある場合とない場合

Caprock MCPサーバーに接続している場合、スキルはcurrent_decisions、search_memories、get_memory、next_session_handoffで、決定や発見を保存したCaprockの2nd Brainを読み返します。保存先は、接続の有無にかかわらずファイルです。Caprockは、コンピューター上の全コーディングエージェントのセッションを記録する無料のオープンソースアプリです。

Caprockを入手 →

SKILL.md全文

dspv/skillsのリビジョンdfce799にあるファイルそのものです。手動で導入する場合、プロジェクト内の、Claude Codeは.claude/skills/memory/SKILL.md、Codexは.agents/skills/memory/SKILL.mdに保存してください。

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.
```

memoryスキルについての質問

Claudeメモリスキルとは?
セッション間で何をどう残すかをClaude Codeに指示するスキルです。決定や発見を日付・理由付きで1件ずつ次のセッションが読む場所に保存し、再判断の前に検索します。
このmemoryスキルとCLAUDE.mdの違いは?
`CLAUDE.md`は全セッションで読み込む規則用です。memoryスキルは決定や発見を別々の記録に残し、必要時に検索します。全セッション向けの規則だけ`CLAUDE.md`に1行追加します。
memoryスキルはCodexでも使えますか?
使えます。Codex 0.163.0が2026年11月29日のテストで保存済みの決定を参照し、重複した記録を書きませんでした。
貼り付けた秘密情報も保存しますか?
保存しません。トークン、パスワード、他人の個人情報は、依頼されても保存せず理由を説明します。

出典

アプリ本体の表示言語は英語です。