Skill de memória do Claude: salve decisões com o motivo e consulte antes de decidir

Dmitriy Solodukha, desenvolvedor do Caprock · Publicado em

Testado em no Claude Code e no Codex

Skill de memória do Claude para qualquer agente: uma decisão datada por entrada, com o motivo, salva no repositório e consultada antes de decidir de novo.

A skill memory é uma skill de memória do Claude que funciona da mesma forma no Claude Code, Codex, OpenCode e Cursor: salva uma decisão, um achado não óbvio ou uma preferência como uma entrada datada com seu motivo, em docs/memory/ ou em um MEMORY.md no repositório, e busca essas entradas antes de decidir algo que você talvez já tenha decidido. Uma memória é uma afirmação sobre o passado, então ela verifica cada uma com o código antes de segui-la.

Instale a skill memory

Um comando por agente. A skill é um único SKILL.md; nada é executado na instalação.

Todas as nove skills como plugin. Digite isto dentro do Claude Code:

Ou apenas esta skill, em um terminal na pasta do seu projeto:

Adicione -g para instalar em todos os projetos.

Prompts que usam a skill memory

O agente escolhe a skill quando suas palavras correspondem à descrição dela; citar seu nome garante isso. Clique em um prompt para copiá-lo.

Como a skill memory do Claude salva e recupera informações

  • Um fato por registro: um título com uma data absoluta, depois Decision, Finding ou Preference, o motivo (e quem o disse), onde se aplica e o que substitui. Uma entrada antiga é marcada como substituída, nunca excluída.
  • Onde: o local que o repositório já usa (docs/memory/, MEMORY.md, docs/adr/); se não houver, docs/memory/YYYY-MM-DD-short-title.md, um arquivo por entrada. Uma regra que toda sessão deve seguir também ganha uma linha em CLAUDE.md ou AGENTS.md.
  • Recupere antes de decidir: busque (com Caprock, current_decisions e search_memories; sem ele, nos arquivos de memória e em git log --grep), leia o resultado completo, confira com o código e então siga-o, sinalize uma contradição ou substitua-o quando você mudar de ideia.

Os arquivos de memória fazem parte do repositório: entram em commits, são revisados e ficam visíveis para todos que podem lê-lo.

O que executamos e o que os agentes fizeram

Cada skill foi executada em 29 de novembro de 2026 em um repositório descartável criado para ela, com a skill instalada como skill de projeto. Um pequeno repositório cujo store/db.py usa 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.

Invocou memory, criou docs/memory/2026-11-29-sqlite-store.md no formato da skill, conferiu com store/db.py e explicou que o 2nd Brain do Caprock é somente leitura via MCP e como importar a pasta para lá. Também escreveu na memória automática do próprio Claude Code, fora do repositório.

Codex (0.163.0, codex exec)

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

Leu a skill, chamou current_decisions e search_memories do Caprock, pesquisou os arquivos, encontrou a entrada, conferiu com o código e não criou uma duplicata.

Agentes em que foi testada

  • Claude Code: testado em 29 de novembro de 2026 com claude -p --model sonnet, com a skill instalada como skill de projeto em .claude/skills/.
  • Codex: testado em 29 de novembro de 2026 com Codex 0.163.0 (codex exec), a skill em .agents/skills/.
  • OpenCode e Cursor: não testado. A skill contém instruções simples no formato aberto Agent Skills, mas nenhuma execução em qualquer um dos dois a verificou.

Limites

  • Ela não pode salvar no 2nd Brain do Caprock: as ferramentas MCP do Caprock são somente leitura. Os arquivos que você importa ali só chegam aos agentes depois que você ativa isso.
  • Uma pasta de memória só é lida quando um agente consulta; regras para todas as sessões devem ficar em CLAUDE.md ou AGENTS.md.
  • Em um repositório público, os registros são públicos; a skill deixa de fora detalhes privados e informa isso.

Com e sem Caprock

Quando o servidor MCP do Caprock está conectado, a skill recupera informações por meio de current_decisions, search_memories, get_memory e next_session_handoff, que leem as decisões e descobertas do 2nd Brain do Caprock. Ela salva em arquivos em ambos os casos. O Caprock é o app gratuito e open source que registra cada sessão de agente de programação no seu computador.

Obtenha o Caprock →

O SKILL.md completo

O arquivo como está em dspv/skills na revisão dfce799. Para instalá-lo manualmente, salve como .claude/skills/memory/SKILL.md para Claude Code ou .agents/skills/memory/SKILL.md para Codex, no seu projeto.

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

Perguntas sobre a skill memory

O que é uma skill de memória do Claude?
Uma skill que diz ao Claude Code o que manter entre sessões e como: uma decisão ou descoberta datada por entrada, com o motivo, salva onde a próxima sessão vai procurar e consultada antes de decidir de novo.
Qual é a diferença entre esta skill de memória e o CLAUDE.md?
`CLAUDE.md` é carregado em toda sessão, então contém regras. A skill memory mantém decisões e descobertas como registros separados, pesquisados quando relevantes, e adiciona uma linha ao `CLAUDE.md` apenas para uma regra que toda sessão deve seguir.
A skill memory funciona no Codex?
Sim. O Codex 0.163.0 recuperou uma decisão salva por meio dela no teste de 29 de novembro de 2026 e não gravou uma duplicata.
Ela vai salvar segredos que eu colar?
Não. Tokens, senhas e dados pessoais de outras pessoas nunca são salvos, mesmo quando solicitado; a skill explica por quê.

Fontes

O app em si está em inglês.