handoff
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHandoff
Handoff
Generate a structured file that gives a fresh Claude session everything it needs to continue this work without dragging the current degraded context forward.
HANDOFF.mdclaude-mem already injects recent observations into every new session, so the fresh agent starts with a timeline of what happened. The handoff adds what that timeline cannot: the goal, the failed attempts and why they failed, the current theory, and exact next steps, plus pointers into memory for deeper recall.
生成一份结构化的 文件,让新的 Claude 会话获得继续当前工作所需的全部信息,同时不必让当前已经退化的上下文继续拖累后续处理。
HANDOFF.mdclaude-mem 已经会在每个新会话中注入近期 observations,因此新的 Agent 会从一份事件时间线开始。Handoff 补充时间线无法提供的信息:目标、失败尝试及其失败原因、当前判断,以及准确的后续步骤,还会提供指向 memory 的指针,以便进行更深入的追溯。
When to Use
何时使用
- The session is long and Claude feels confused or repetitive
- Claude keeps trying the same failing solution over and over
- The user wants to step away and resume later
- ran but Claude still lacks clear direction
/compact - The user says "handoff", "generate a handoff", "I want to start fresh", or "write a handoff doc"
- 会话很长,Claude 感到困惑或开始重复
- Claude 不断尝试同一个失败方案
- 用户希望暂时离开并稍后继续
- 已运行,但 Claude 仍缺乏清晰方向
/compact - 用户说出“handoff”“generate a handoff”“I want to start fresh”或“write a handoff doc”
What to Capture
需要记录的内容
Think hard about the full arc of this conversation before writing. The handoff must be useful to a Claude instance that has never seen this conversation.
写入之前,请认真思考本次对话的完整过程。Handoff 必须对从未见过这段对话的 Claude 实例有用。
Required Sections
必需部分
-
Goal — One paragraph. What is the user actually trying to accomplish? State the end state, not the current sub-task. Be specific enough that a fresh agent can orient immediately.
-
Current State — What is working right now? What is broken? What is the exact symptom of the problem? Include error messages verbatim if relevant.
-
Files in Play — List every file that has been read, edited, or created during this session that is relevant to the current task. Use absolute or repo-relative paths. Include a one-line note on why each file matters.
-
What Has Been Tried (and Why It Failed) — This is the most important section. List every approach attempted that did not work, and explain WHY it failed (not just that it failed). A fresh agent that skips this section will repeat the same mistakes.
-
Current Best Theory — What do you currently believe is the right path forward, even if you haven't proven it yet? Include any evidence or reasoning that supports it.
-
Next Steps — Concrete, ordered actions for the fresh agent to take. Be specific: file paths, function names, commands to run. The fresh agent should be able to start on step 1 immediately.
-
Key Constraints and Context — Any non-obvious constraints: environment specifics, user preferences expressed during this session, things the user explicitly said NOT to do, external dependencies, performance requirements, etc.
-
Memory Pointers — If claude-mem's search tools are available, runfor this task's key terms and list the few observation IDs that matter most (a decision, the root cause, a failed approach), so the fresh agent can pull full details with
search. Also list one or twoget_observationsqueries worth re-running. Skip this section if the tools are not available.search
-
目标——用一个段落说明。用户真正想实现什么?陈述最终状态,而不是当前子任务。要足够具体,让新的 Agent 能立即了解方向。
-
当前状态——目前哪些内容可以正常工作?哪些内容出现了问题?问题的准确症状是什么?如果相关,请原样包含错误消息。
-
涉及的文件——列出本次会话中读取、编辑或创建且与当前任务相关的所有文件。使用绝对路径或仓库相对路径,并用一行说明每个文件为何重要。
-
已尝试内容(以及失败原因)——这是最重要的部分。列出每一种未能奏效的尝试方案,并解释为什么失败,而不只是说明它失败了。跳过本部分的新 Agent 将会重复之前的错误。
-
当前最佳判断——即使尚未得到验证,目前你认为正确的推进路径是什么?列出支持该判断的证据或推理。
-
后续步骤——为新 Agent 列出具体、有顺序的行动。务必明确:文件路径、函数名称、需要运行的命令。新 Agent 应该能够立即从第 1 步开始执行。
-
关键约束与上下文——记录所有不明显的约束:环境细节、本次会话中表达的用户偏好、用户明确要求不要做的事情、外部依赖、性能要求等。
-
记忆指针——如果 claude-mem 的工具可用,请使用本任务的关键术语运行
search,并列出最重要的几个 observation ID,例如某项决策、根因或失败尝试,以便新 Agent 使用search获取完整细节。同时列出一到两个值得重新运行的get_observations查询。如果工具不可用,则跳过此部分。search
Writing Rules
编写规则
- Write the handoff for a fresh Claude, not for the user. The user knows what happened; the fresh Claude does not.
- Be ruthlessly specific. Vague next steps are useless. "Fix the auth" is bad. "In , the token expiry check uses
src/auth/middleware.ts:47but should useDate.now()— change the comparison on line 52" is good.req.timestamp - Include exact error messages, stack traces, or test output that captures the failure mode.
- Do not pad. Every sentence should be load-bearing information for the fresh agent.
- Do not write the handoff from the user's perspective. Write it as a briefing document addressed to the incoming agent.
- Handoff 是为新的 Claude 而写,不是为用户而写。用户知道发生了什么,而新的 Claude 不知道。
- 务必写得极其具体。模糊的后续步骤毫无用处。“修复 auth”很糟糕;“在 中,token 过期检查使用了
src/auth/middleware.ts:47,但应当使用Date.now()——修改第 52 行的比较逻辑”则很好。req.timestamp - 包含准确描述故障模式:错误消息、stack trace 或测试输出。
- 不要填充废话。每一句都应为新 Agent 提供承重信息。
- 不要以用户的视角编写。应将其写成一份面向接手 Agent 的简报。
Output
输出
Write the handoff to in the current working directory (the project root).
HANDOFF.mdUse this structure:
markdown
undefined将 Handoff 写入当前工作目录(项目根目录)中的 。
HANDOFF.md使用以下结构:
markdown
undefinedHandoff
Handoff
Generated: [timestamp]
Project: [project name or directory]
Session summary: [one sentence describing what this session was about]
Generated: [timestamp]
Project: [project name or directory]
Session summary: [one sentence describing what this session was about]
Goal
Goal
[What the user is trying to accomplish — the actual end state]
[What the user is trying to accomplish — the actual end state]
Current State
Current State
Working:
- [list what is confirmed working]
Broken:
- [exact symptom, error message, or failure mode]
Working:
- [list what is confirmed working]
Broken:
- [exact symptom, error message, or failure mode]
Files in Play
Files in Play
| File | Why It Matters |
|---|---|
| [one line] |
| File | Why It Matters |
|---|---|
| [one line] |
What Has Been Tried (and Why It Failed)
What Has Been Tried (and Why It Failed)
Attempt 1: [short name]
Attempt 1: [short name]
- What: [what was done]
- Why it failed: [root cause, not just "it didn't work"]
- What: [what was done]
- Why it failed: [root cause, not just "it didn't work"]
Attempt 2: [short name]
Attempt 2: [short name]
...
...
Current Best Theory
Current Best Theory
[What you currently believe is the correct approach and why]
[What you currently believe is the correct approach and why]
Next Steps
Next Steps
- [Specific, actionable step with file path or command]
- [Next step]
- ...
- [Specific, actionable step with file path or command]
- [Next step]
- ...
Key Constraints
Key Constraints
- [Non-obvious constraint or preference the user expressed]
- [Things explicitly ruled out]
- [Non-obvious constraint or preference the user expressed]
- [Things explicitly ruled out]
Memory Pointers
Memory Pointers
- Observations: [#ID — one line on why it matters]
- Searches worth re-running: [query]
search
undefined- Observations: [#ID — one line on why it matters]
- Searches worth re-running: [query]
search
undefinedAfter Writing
写入后
Tell the user:
- That has been written
HANDOFF.md - To run or start a new Claude Code session
/clear - To open the new session and say: "Read HANDOFF.md and continue from where we left off."
- That claude-mem gives the fresh agent the recent timeline automatically, and is its precise briefing on top of that
HANDOFF.md - That is a scratch file: don't commit it (delete it once the new session has picked up, or add it to
HANDOFF.md).gitignore
Keep the message short. The user is ready to move — don't make them read a wall of text.
告诉用户:
- 已经写入
HANDOFF.md - 运行 或启动新的 Claude Code 会话
/clear - 打开新会话并说:“读取 HANDOFF.md,从我们上次离开的位置继续。”
- claude-mem 会自动向新 Agent 提供近期时间线,而 则在此基础上提供精确简报
HANDOFF.md - 是一个临时文件:不要提交它(待新会话接手后将其删除,或把它添加到
HANDOFF.md).gitignore
信息要简短。用户已经准备继续行动,不要让用户阅读大段文字。