Skill handoff para Claude Code e Codex: HANDOFF.md antes de o contexto acabar

Dmitriy Solodukha, desenvolvedor do Caprock · Publicado em

Testado em no Claude Code e no Codex

Skill de handoff para Claude e Codex: escreve HANDOFF.md (objetivo, estado, falhas, próximos passos) antes de acabar o contexto; a próxima sessão lê.

A skill de handoff para Claude Code (e Codex, OpenCode, Cursor) escreve um HANDOFF.md curto antes que o contexto acabe ou você pare: o objetivo, o estado atual, decisões com seus motivos, tentativas que falharam, questões em aberto, próximos passos executáveis e os arquivos alterados. Na próxima sessão, "pick up where we left off" faz com que ela leia o arquivo, confira com o git e inicie o passo 1.

Instale a skill handoff

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 handoff

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

O que a skill handoff escreve para o Claude

O arquivo tem seções fixas: Goal, State (done, in progress, uncommitted, running), Decisions, Tried and failed, Open questions, Next steps, Files. As regras que o tornam útil para uma sessão sem acesso a esta conversa:

  • As próximas etapas são executáveis: um comando para executar ou uma função para alterar, não “continue the auth work”.
  • As falhas são mantidas, com a linha exata do erro, para que um caminho sem saída não seja tentado novamente.
  • Decisões incluem o motivo, para que a próxima sessão possa dizer se alguma ainda se aplica.
  • Sem segredos: informa onde um token fica, nunca o token.
  • O idioma do repositório, mesmo quando você conversa com o agente em outro.

Ela não faz commit do arquivo a menos que você peça e termina a resposta com o caminho e a primeira etapa, para que a última mensagem faça sentido por si só.

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 Python com slug.py contendo um esboço inacabado de slugify_unique e seus testes.

Claude Code (claude -p --model sonnet)

I'm about to run out of context. Write a handoff for the next session: I was adding slugify_unique to slug.py (append -2, -3 when the slug is taken); I decided not to use a global set because tests must stay independent. Tried python-slugify, dropped it: no new dependencies.

Invocou handoff, escreveu HANDOFF.md na estrutura exata, perguntou se deveria fazer commit ou ignorá-lo e terminou com o bloco de três linhas. Escreveu o arquivo em russo, o idioma das configurações do Claude Code do próprio testador; essa execução é o motivo pelo qual a skill agora diz para escrever no idioma do repositório.

Claude Code (claude -p --model sonnet)

Pick up where we left off.

Invocou a skill no modo de leitura, seguiu o handoff, escreveu slugify_unique e cinco testes e atualizou HANDOFF.md, desta vez em inglês. Disse claramente que não havia executado os testes: o comando de teste precisava de uma permissão que a execução não interativa não tinha.

Codex (0.163.0, codex exec -s workspace-write)

The same write prompt as above.

Leu .agents/skills/handoff/SKILL.md, escreveu o handoff em inglês e terminou como a skill pede (links e citações exibidos como texto simples):

Handoff written to HANDOFF.md.
Next session: "Read HANDOFF.md and continue."
First step: implement the collision loop in `slug.py:8`.

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

  • Um handoff só é tão bom quanto o que a sessão consegue verificar: o agente escreve a partir do git e da conversa, não da memória da intenção.
  • Ela não grava no 2nd Brain do Caprock: as ferramentas MCP do Caprock são somente leitura.
  • O modo de leitura foi testado apenas no Claude Code.

Com e sem Caprock

Com o servidor MCP do Caprock conectado, escrever um handoff chama current_decisions e search_memories para que a nota não contradiga uma decisão já em vigor; ler um pode recorrer a next_session_handoff, recent_sessions e session_summary quando não há arquivo. Sem Caprock, usa apenas o repositório e a conversa. Caprock é o app gratuito e open source que registra todas as sessões de agentes 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/handoff/SKILL.md para Claude Code ou .agents/skills/handoff/SKILL.md para Codex, no seu projeto.

skills/handoff/SKILL.md
---
name: handoff
description: >
  Write a handoff for the next session or another agent before the context runs out or work
  stops: the goal, where things stand, decisions and why, what was tried and failed, open
  questions, exact next steps and the files touched, saved where the next session will find it
  (HANDOFF.md in the repository by default). Also reads the last handoff when a session starts.
  Use when the user says "write a handoff", "handoff skill claude", "hand this off", "save
  context for the next session", "I'm out of context", "wrap up for today", "pick up where we
  left off", "resume from the handoff" or "what was the last session doing".
license: Apache-2.0
---

# Handoff

A handoff is a short note that lets a fresh session, with none of this conversation, continue
the work without asking the user to repeat anything. Write it from facts you can check (the
repository, the commands you ran, what the user said), not from memory of what you meant to do.

Two modes. Pick by what the user asked:

- **Write**: the user wants to stop, the context is nearly full, or work moves to another
  agent. Go to "Writing a handoff".
- **Read**: a session starts and the user says "continue", "pick up where we left off" or
  points at a handoff. Go to "Reading a handoff".

## Writing a handoff

### 1. Collect the facts

Run these in the repository root and keep the output in mind (do not paste it whole):

```bash
git status --short
git branch --show-current
git log --oneline -10
git diff --stat
git stash list
```

Also note: commands you ran that passed or failed (tests, builds, checks) and their last result;
any background process still running (a dev server, a watcher) and how it was started; anything
the user decided or asked for in this conversation, in their words.

If the Caprock MCP tools are available (server `caprock`), call `current_decisions` for this
project and `search_memories` with the task's main words. Use them to check the handoff does
not contradict a decision already in force, and to link a decision instead of retelling it.
Caprock (<https://caprock.dev>, free, open source, runs locally) provides these tools; without
them, rely on the repository and this conversation.

### 2. Write the file

Default location: `HANDOFF.md` in the repository root. Use another place only if the user names
one or the repository already keeps handoffs elsewhere (look for `HANDOFF.md`, `docs/handoff*`,
`.handoff/`). If a `HANDOFF.md` exists, read it first: replace it with the new one, and carry
over anything from it that is still open.

Use exactly this structure. Leave a section out only when it would be empty, and say "none"
for open questions rather than dropping the heading.

```markdown
# Handoff: <task in a few words>

Written <YYYY-MM-DD HH:MM, timezone> by <agent and model, if known>. Branch `<branch>`,
last commit `<short sha> <subject>`.

## Goal
<One or two sentences: what the user wants and what "done" looks like.>

## State
- Done: <what is finished and verified, with how it was verified>
- In progress: <what is half-done, where exactly it stops>
- Uncommitted: <files changed but not committed, or "nothing">
- Running: <background processes and how to stop them, or "nothing">

## Decisions
- <decision>: <why>. <who decided: the user, or you with the reason>

## Tried and failed
- <approach>: <what happened, the error or the reason it was dropped>

## Open questions
- <question> (who can answer: the user, a doc, a test)

## Next steps
1. <first concrete action: a command to run or a file and function to change>
2. <...>

## Files
- `<path>`: <what changed or why it matters>
```

Rules for the content:

- **Next steps are executable.** "Run `npm test -- auth` and fix the two failures in
  `src/auth/session.ts`" is a step; "continue the auth work" is not. The first step is the one
  the next session does in its first minute.
- **Failures are kept.** A dead end not written down gets tried again. Include the exact error
  line when there is one.
- **Decisions carry the reason.** Without the reason the next session cannot tell whether it
  still applies.
- **Absolute dates and exact names.** "2026-12-01", a branch name, a file path, a command; never
  "tomorrow" or "the config file".
- **No secrets.** Never copy a token, password, key or private URL into the handoff. Name where
  it lives (an environment variable, a keychain entry) instead.
- **The repository's language.** Write the handoff in the language the repository's docs and
  commits use, even when you talk to the user in another; the next session may be another agent.
- **Short.** Aim for a page. A long log or diff stays in git; the handoff points at it.

### 3. Tell the user

Do not commit the handoff unless the user asks. Ask once whether `HANDOFF.md` should be
committed or added to `.gitignore` if the repository has neither. End your reply with:

```text
Handoff written to <path>.
Next session: "Read <path> and continue."
First step: <step 1 from the file>
```

Also print the Goal, State and Next steps sections in that final reply. Some tools (Caprock's
`next_session_handoff`, when the user has it switched on) hand a new session the last passage
the previous session wrote, so the final message should stand on its own.

## Reading a handoff

### 1. Find it

Look in this order and use the first that exists:

1. a path the user gave;
2. `HANDOFF.md` in the repository root, then `docs/handoff*` and `.handoff/`;
3. with the Caprock MCP tools: `next_session_handoff` (the memories and current decisions a new
   session in this repository gets, and when the last session left off), then
   `recent_sessions` and `session_summary` on the newest session for its files and branch.

If nothing is found, say so in one line and ask what to work on. Do not invent a previous state.

### 2. Check it against the repository

A handoff can be stale. Before acting on it:

- compare its branch and last commit with `git branch --show-current` and `git log --oneline -5`;
- check that "Uncommitted" matches `git status --short`;
- note how old it is from its date.

If anything disagrees (new commits, a different branch, the files already committed), trust the
repository and say what changed since the handoff.

### 3. Report and start

Reply with, in this order:

```text
Handoff from <date>: <goal in one line>.
Since then: <"nothing changed" or what differs in git>.
Open questions: <list, or "none">.
Starting with: <step 1>.
```

If an open question blocks step 1, ask it and wait. Otherwise do step 1. When the task is
finished, delete `HANDOFF.md` or replace it with a new handoff, so the next session does not
pick up work that is already done.

## Stop conditions

- The handoff is written and the user has the path and the first step: stop writing.
- The handoff names a step that needs the user (a decision, a credential, a review): ask, do not
  guess.
- The repository disagrees with the handoff on what is committed: follow the repository and say
  so before doing anything else.

Perguntas sobre a skill handoff

O que é uma skill handoff para Claude?
Uma skill que faz o Claude Code escrever uma nota curta antes de parar o trabalho, com objetivo, estado, decisões, falhas e próximos passos, para uma nova sessão ou outro agente continuar sem você repetir nada.
Onde a skill handoff salva a nota?
`HANDOFF.md` na raiz do repositório por padrão, ou onde o repositório já guarda handoffs, ou em um caminho que você indicar. Ela pergunta se deve fazer commit do arquivo ou ignorá-lo.
Como a próxima sessão usa o handoff?
Diga “Read HANDOFF.md and continue” ou “pick up where we left off”. A skill compara a branch, o commit e os arquivos sem commit da nota com git, informa o que mudou desde então e inicia a primeira etapa.
A skill handoff funciona no Codex?
Sim. O Codex 0.163.0 leu a skill de `.agents/skills/` e escreveu o handoff na estrutura dela no teste de 29 de novembro de 2026.

Fontes

O app em si está em inglês.