handoff

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Handoff

Handoff

Generate a structured
HANDOFF.md
file that gives a fresh Claude session everything it needs to continue this work without dragging the current degraded context forward.
claude-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.
生成一份结构化的
HANDOFF.md
文件,让新的 Claude 会话获得继续当前工作所需的全部信息,同时不必让当前已经退化的上下文继续拖累后续处理。
claude-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
  • /compact
    ran but Claude still lacks clear direction
  • The user says "handoff", "generate a handoff", "I want to start fresh", or "write a handoff doc"
  • 会话很长,Claude 感到困惑或开始重复
  • Claude 不断尝试同一个失败方案
  • 用户希望暂时离开并稍后继续
  • /compact
    已运行,但 Claude 仍缺乏清晰方向
  • 用户说出“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

必需部分

  1. 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.
  2. Current State — What is working right now? What is broken? What is the exact symptom of the problem? Include error messages verbatim if relevant.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. Memory Pointers — If claude-mem's search tools are available, run
    search
    for 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
    get_observations
    . Also list one or two
    search
    queries worth re-running. Skip this section if the tools are not available.
  1. 目标——用一个段落说明。用户真正想实现什么?陈述最终状态,而不是当前子任务。要足够具体,让新的 Agent 能立即了解方向。
  2. 当前状态——目前哪些内容可以正常工作?哪些内容出现了问题?问题的准确症状是什么?如果相关,请原样包含错误消息。
  3. 涉及的文件——列出本次会话中读取、编辑或创建且与当前任务相关的所有文件。使用绝对路径或仓库相对路径,并用一行说明每个文件为何重要。
  4. 已尝试内容(以及失败原因)——这是最重要的部分。列出每一种未能奏效的尝试方案,并解释为什么失败,而不只是说明它失败了。跳过本部分的新 Agent 将会重复之前的错误。
  5. 当前最佳判断——即使尚未得到验证,目前你认为正确的推进路径是什么?列出支持该判断的证据或推理。
  6. 后续步骤——为新 Agent 列出具体、有顺序的行动。务必明确:文件路径、函数名称、需要运行的命令。新 Agent 应该能够立即从第 1 步开始执行。
  7. 关键约束与上下文——记录所有不明显的约束:环境细节、本次会话中表达的用户偏好、用户明确要求不要做的事情、外部依赖、性能要求等。
  8. 记忆指针——如果 claude-mem 的
    search
    工具可用,请使用本任务的关键术语运行
    search
    ,并列出最重要的几个 observation ID,例如某项决策、根因或失败尝试,以便新 Agent 使用
    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
    src/auth/middleware.ts:47
    , the token expiry check uses
    Date.now()
    but should use
    req.timestamp
    — change the comparison on line 52" is good.
  • 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”很糟糕;“在
    src/auth/middleware.ts:47
    中,token 过期检查使用了
    Date.now()
    ,但应当使用
    req.timestamp
    ——修改第 52 行的比较逻辑”则很好。
  • 包含准确描述故障模式:错误消息、stack trace 或测试输出。
  • 不要填充废话。每一句都应为新 Agent 提供承重信息。
  • 不要以用户的视角编写。应将其写成一份面向接手 Agent 的简报。

Output

输出

Write the handoff to
HANDOFF.md
in the current working directory (the project root).
Use this structure:
markdown
undefined
将 Handoff 写入当前工作目录(项目根目录)中的
HANDOFF.md
。
使用以下结构:
markdown
undefined

Handoff

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

FileWhy It Matters
path/to/file.ts
[one line]
FileWhy It Matters
path/to/file.ts
[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

  1. [Specific, actionable step with file path or command]
  2. [Next step]
  3. ...
  1. [Specific, actionable step with file path or command]
  2. [Next step]
  3. ...

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: [
    search
    query]
undefined
  • Observations: [#ID — one line on why it matters]
  • Searches worth re-running: [
    search
    query]
undefined

After Writing

写入后

Tell the user:
  1. That
    HANDOFF.md
    has been written
  2. To run
    /clear
    or start a new Claude Code session
  3. To open the new session and say: "Read HANDOFF.md and continue from where we left off."
  4. That claude-mem gives the fresh agent the recent timeline automatically, and
    HANDOFF.md
    is its precise briefing on top of that
  5. That
    HANDOFF.md
    is a scratch file: don't commit it (delete it once the new session has picked up, or add it to
    .gitignore
    )
Keep the message short. The user is ready to move — don't make them read a wall of text.
告诉用户:
  1. HANDOFF.md
    已经写入
  2. 运行
    /clear
    或启动新的 Claude Code 会话
  3. 打开新会话并说:“读取 HANDOFF.md,从我们上次离开的位置继续。”
  4. claude-mem 会自动向新 Agent 提供近期时间线,而
    HANDOFF.md
    则在此基础上提供精确简报
  5. HANDOFF.md
    是一个临时文件:不要提交它(待新会话接手后将其删除,或把它添加到
    .gitignore
    )
信息要简短。用户已经准备继续行动,不要让用户阅读大段文字。