Skill handoff para Claude Code y Codex: HANDOFF.md antes de que se agote el contexto
Dmitriy Solodukha, desarrollador de Caprock · Publicado el
Probado el en Claude Code y Codex
Skill de traspaso para Claude y Codex: guarda objetivo, estado, fallos y próximos pasos en HANDOFF.md antes de agotar contexto; la siguiente sesión lo lee.
La skill handoff para Claude Code (y Codex, OpenCode, Cursor) escribe un breve HANDOFF.md antes de que se agote el contexto o te detengas: el objetivo, el estado actual, las decisiones con sus motivos, lo que se intentó y falló, las preguntas pendientes, los siguientes pasos ejecutables y los archivos modificados. En la siguiente sesión, “pick up where we left off” hace que lea el archivo, lo contraste con git y empiece por el paso 1.
Instala la skill handoff
Un comando por agente. La skill es un único SKILL.md; no se ejecuta nada al instalarla.
Las nueve skills como plugin. Escribe esto dentro de Claude Code:
O solo esta skill, desde la carpeta de tu proyecto en una terminal:
Añade -g para instalarla en todos los proyectos.
Desde la carpeta de tu proyecto, en una terminal:
Añade -g para instalarla en todos los proyectos.
Desde la carpeta de tu proyecto, en una terminal:
Añade -g para instalarla en todos los proyectos. Aún no se ha probado en OpenCode: la skill contiene instrucciones sencillas en el formato abierto, pero ninguna ejecución en OpenCode la ha verificado.
Desde la carpeta de tu proyecto, en una terminal:
Añade -g para instalarla en todos los proyectos. Aún no se ha probado en Cursor: la skill contiene instrucciones sencillas en el formato abierto, pero ninguna ejecución en Cursor la ha verificado.
Prompts que usan la skill handoff
El agente elige la skill cuando tus palabras coinciden con su descripción; nombrarla lo asegura. Haz clic en un prompt para copiarlo.
Qué escribe la skill handoff para Claude
El archivo tiene secciones fijas: Goal, State (done, in progress, uncommitted, running), Decisions, Tried and failed, Open questions, Next steps, Files. Las reglas que lo hacen útil para una sesión que no tiene nada de esta conversación:
- Los siguientes pasos se pueden ejecutar: un comando que ejecutar o una función que modificar, no "continue the auth work".
- Se conservan los intentos fallidos, con la línea exacta del error, para no volver a intentar una vía sin salida.
- Las decisiones incluyen el motivo, para que la siguiente sesión pueda determinar si alguna sigue siendo aplicable.
- Sin secretos: indica dónde se guarda un token, nunca el token.
- El idioma del repositorio, incluso cuando hablas con el agente en otro.
No hace commit del archivo a menos que lo pidas, y termina su respuesta con la ruta y el primer paso, para que el último mensaje se entienda por sí solo.
Qué ejecutamos y qué hicieron los agentes
Cada skill se ejecutó el 29 de noviembre de 2026 en un repositorio desechable creado para ella, con la skill instalada como skill del proyecto. Un pequeño repositorio de Python con un esbozo inacabado de slugify_unique en slug.py, y sus pruebas.
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.
Invocó handoff, escribió HANDOFF.md con la estructura exacta, preguntó si debía hacer commit del archivo o ignorarlo y terminó con el bloque de tres líneas. Escribió el archivo en ruso, el idioma de la configuración de Claude Code de quien hizo la prueba; esa ejecución es la razón por la que la skill ahora indica que se escriba en el idioma del repositorio.
Claude Code (claude -p --model sonnet)
Pick up where we left off.
Invocó la skill en modo de lectura, siguió el traspaso, escribió slugify_unique y cinco pruebas, y actualizó HANDOFF.md, esta vez en inglés. Indicó claramente que no había ejecutado las pruebas: el comando de pruebas necesitaba un permiso que la ejecución no interactiva no tenía.
Codex (0.163.0, codex exec -s workspace-write)
The same write prompt as above.
Leyó .agents/skills/handoff/SKILL.md, escribió el traspaso en inglés y terminó como pide la skill (enlaces y citas en texto plano):
Handoff written to HANDOFF.md. Next session: "Read HANDOFF.md and continue." First step: implement the collision loop in `slug.py:8`.
Agentes en los que se probó
- Claude Code: probado el 29 de noviembre de 2026 con
claude -p --model sonnet, con la skill instalada como skill de proyecto en.claude/skills/. - Codex: probado el 29 de noviembre de 2026 con Codex 0.163.0 (
codex exec), con la skill en.agents/skills/. - OpenCode y Cursor: sin probar. La skill consiste en instrucciones en el formato abierto Agent Skills, pero ninguna ejecución en ninguno de los dos la ha verificado.
Límites
- Un traspaso solo es tan bueno como lo que la sesión puede comprobar: el agente escribe a partir de git y la conversación, no del recuerdo de la intención.
- No escribe en 2nd Brain de Caprock: las herramientas MCP de Caprock son de solo lectura.
- El modo de lectura solo se probó en Claude Code.
Con Caprock y sin él
Con el servidor MCP de Caprock conectado, escribir un traspaso llama a current_decisions y search_memories para que la nota no contradiga una decisión ya vigente; leer uno puede recurrir a next_session_handoff, recent_sessions y session_summary cuando no hay archivo. Sin Caprock, solo usa el repositorio y la conversación. Caprock es la app gratis y de código abierto que registra cada sesión de agentes de programación en tu computadora.
El SKILL.md completo
El archivo tal como está en dspv/skills en la revisión dfce799. Para instalarlo manualmente, guárdalo como .claude/skills/handoff/SKILL.md para Claude Code o .agents/skills/handoff/SKILL.md para Codex en tu proyecto.
--- 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.
Preguntas sobre la skill handoff
- ¿Qué es una skill de traspaso para Claude?
- Una skill que hace que Claude Code escriba una nota breve antes de detener el trabajo, con el objetivo, el estado, las decisiones, los fallos y los próximos pasos, para que una nueva sesión u otro agente puedan continuar sin que repitas nada.
- ¿Dónde guarda la nota la skill handoff?
- `HANDOFF.md` en la raíz del repositorio de forma predeterminada, o donde el repositorio ya guarde los traspasos, o en una ruta que indiques. Pregunta si debe hacer commit del archivo o ignorarlo.
- ¿Cómo usa la siguiente sesión el traspaso?
- Di “Read HANDOFF.md and continue” o “pick up where we left off”. La skill comprueba la rama, el commit y los archivos sin commit de la nota con git, informa de lo que ha cambiado desde entonces e inicia el primer paso.
- ¿Funciona en Codex la skill handoff?
- Sí. Codex 0.163.0 leyó la skill de `.agents/skills/` y escribió el traspaso siguiendo su estructura en la prueba del 29 de noviembre de 2026.