Skill handoff pour Claude Code et Codex : HANDOFF.md avant l'épuisement du contexte
Dmitriy Solodukha, développeur de Caprock · Publié le
Testé le sur Claude Code et Codex
Skill de passation Claude et Codex : HANDOFF.md (but, état, échecs, suite) écrit avant épuisement du contexte, lu par la session suivante.
La skill handoff pour Claude Code (ainsi que Codex, OpenCode, Cursor) rédige un court HANDOFF.md avant que le contexte soit épuisé ou que vous vous arrêtiez : l'objectif, l'état d'avancement, les décisions et leurs raisons, les tentatives infructueuses, les questions ouvertes, les prochaines étapes exécutables et les fichiers modifiés. Dans la session suivante, « pick up where we left off » lui fait lire le fichier, le vérifier par rapport à git et commencer l'étape 1.
Installer la skill handoff
Une commande par agent. La skill se résume à un seul SKILL.md ; rien ne s'exécute à l'installation.
Les neuf skills dans un plugin. Saisissez ces commandes dans Claude Code :
Ou cette skill seule, depuis le dossier de votre projet dans un terminal :
Ajoutez -g pour l'installer pour tous les projets.
Depuis le dossier de votre projet, dans un terminal :
Ajoutez -g pour l'installer pour tous les projets.
Depuis le dossier de votre projet, dans un terminal :
Ajoutez -g pour l'installer pour tous les projets. Pas encore testée avec OpenCode : la skill contient de simples instructions au format ouvert, mais aucune exécution avec OpenCode n'a permis de la vérifier.
Depuis le dossier de votre projet, dans un terminal :
Ajoutez -g pour l'installer pour tous les projets. Pas encore testée avec Cursor : la skill contient de simples instructions au format ouvert, mais aucune exécution avec Cursor n'a permis de la vérifier.
Prompts utilisant la skill handoff
L'agent choisit la skill lorsque vos mots correspondent à sa description ; la nommer permet de s'en assurer. Cliquez sur un prompt pour le copier.
Ce que la skill handoff écrit pour Claude
Le fichier comporte des sections fixes : Goal, State (done, in progress, uncommitted, running), Decisions, Tried and failed, Open questions, Next steps, Files. Les règles qui le rendent utile à une session qui ne connaît rien de cette conversation :
- Les prochaines étapes sont exécutables : une commande à exécuter ou une fonction à modifier, plutôt que « continue the auth work ».
- Les échecs sont conservés, avec la ligne d'erreur exacte, pour ne pas retenter une impasse.
- Les décisions sont accompagnées de leur justification, pour que la session suivante puisse déterminer si l'une d'elles s'applique encore.
- Aucun secret : il indique où se trouve un token, jamais le token lui-même.
- La langue du dépôt, même si vous parlez à l'agent dans une autre langue.
Elle ne commite pas le fichier sauf si vous le demandez, et termine sa réponse par le chemin et la première étape, pour que le dernier message se suffise à lui-même.
Ce que nous avons exécuté et ce que les agents ont fait
Chaque skill a été exécutée le 29 novembre 2026 dans un dépôt jetable créé pour elle, avec la skill installée au niveau du projet. Un petit dépôt Python avec slug.py contenant une ébauche inachevée de slugify_unique, ainsi que ses tests.
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.
L'agent a invoqué handoff, écrit HANDOFF.md en respectant exactement la structure, demandé s'il fallait l'ajouter à un commit ou l'ignorer, et terminé par le bloc de trois lignes. Le fichier a été écrit en russe, la langue des réglages Claude Code du testeur ; c'est cette exécution qui explique pourquoi la skill demande désormais d'écrire dans la langue du dépôt.
Claude Code (claude -p --model sonnet)
Pick up where we left off.
L'agent a invoqué la skill en mode lecture, suivi la passation, écrit slugify_unique et cinq tests, puis mis à jour HANDOFF.md, en anglais cette fois. Il a clairement indiqué qu'il n'avait pas exécuté les tests : la commande de test nécessitait une autorisation dont l'exécution non interactive ne disposait pas.
Codex (0.163.0, codex exec -s workspace-write)
The same write prompt as above.
Codex a lu .agents/skills/handoff/SKILL.md, rédigé la passation en anglais et terminé comme le demande la skill (liens et citations affichés en texte brut) :
Handoff written to HANDOFF.md. Next session: "Read HANDOFF.md and continue." First step: implement the collision loop in `slug.py:8`.
Agents sur lesquels elle a été testée
- Claude Code : testé le 29 novembre 2026 avec
claude -p --model sonnet, la skill étant installée comme skill de projet dans.claude/skills/. - Codex : testé le 29 novembre 2026 avec Codex 0.163.0 (
codex exec), la skill étant dans.agents/skills/. - OpenCode et Cursor : non testés. La skill est constituée de simples instructions au format ouvert Agent Skills, mais aucune exécution sur l'un ou l'autre ne l'a vérifiée.
Limites
- Une passation ne vaut que par ce que la session peut vérifier : l'agent s'appuie sur git et la conversation pour rédiger, pas sur son souvenir des intentions.
- Elle n'écrit pas dans le 2nd Brain de Caprock : les outils MCP de Caprock sont en lecture seule.
- Le mode de lecture n'a été testé que sur Claude Code.
Avec et sans Caprock
Avec le serveur MCP de Caprock connecté, la rédaction d'une passation appelle current_decisions et search_memories pour que la note ne contredise pas une décision déjà en vigueur ; sa lecture peut se rabattre sur next_session_handoff, recent_sessions et session_summary en l'absence de fichier. Sans Caprock, elle utilise uniquement le dépôt et la conversation. Caprock est l'application gratuite et open source qui enregistre toutes les sessions d'agents de code sur votre ordinateur.
Le SKILL.md complet
Le fichier tel qu'il figure dans dspv/skills à la révision dfce799. Pour l'installer manuellement, enregistrez-le dans votre projet sous le nom .claude/skills/handoff/SKILL.md pour Claude Code ou .agents/skills/handoff/SKILL.md pour Codex.
--- 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.
Questions sur la skill handoff
- Qu'est-ce qu'une skill handoff pour Claude ?
- Une skill qui fait écrire à Claude Code une courte note avant l'arrêt du travail, avec l'objectif, l'état, les décisions, les échecs et les prochaines étapes, pour qu'une nouvelle session ou un autre agent puisse continuer sans que vous ayez à répéter quoi que ce soit.
- Où la skill handoff enregistre-t-elle la note ?
- `HANDOFF.md` à la racine du dépôt par défaut, ou à l'endroit où le dépôt conserve déjà les notes de passation, ou au chemin que vous indiquez. Elle demande s'il faut commiter le fichier ou l'ignorer.
- Comment la session suivante utilise-t-elle la passation ?
- Dites « Read HANDOFF.md and continue » ou « pick up where we left off ». La skill compare la branche, le commit et les fichiers non commités de la note avec git, signale ce qui a changé depuis et commence la première étape.
- La skill handoff fonctionne-t-elle dans Codex ?
- Oui. Codex 0.163.0 a lu la skill dans `.agents/skills/` et a rédigé la passation selon sa structure lors du test du 29 novembre 2026.