session-checkpoint

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Session Checkpoint

会话检查点

Commands

命令

  • Save:
    save checkpoint {name}
    ,
    save checkpoint
    (prompts for descriptive name)
  • Resume:
    continue
    ,
    continue {name}
    ,
    resume
    (auto-select if one checkpoint, list if many)
  • Cleanup:
    clear checkpoint {name}
    ,
    clear all checkpoints

  • 保存:
    save checkpoint {name}
    save checkpoint
    (会提示输入描述性名称)
  • 恢复:
    continue
    continue {name}
    resume
    (如果只有一个检查点则自动选择,多个则列出选项)
  • 清理:
    clear checkpoint {name}
    clear all checkpoints

Save Procedure

保存流程

1. Determine Name

1. 确定名称

If user gave a name, use it (lowercase, sanitize: replace
/
with
-
).
If no name given:
  • Pick a short name from the current work (2-4 words, e.g., "my-feature")
  • Confirm with
    AskUserQuestion
    , options:
    • "Use '{suggested-name}' (Recommended)"
    • "Provide different name" (user types via Other)
Sanitize final name: lowercase, replace spaces/
/
with
-
, strip leading
-
.
如果用户提供了名称,直接使用(转为小写,清理格式:将
/
替换为
-
)。
如果未提供名称:
  • 从当前工作内容中选取一个短名称(2-4个词,例如"my-feature")
  • 通过
    AskUserQuestion
    确认,选项如下:
    • "使用'{suggested-name}'(推荐)"
    • "提供其他名称"(用户通过“其他”输入)
最终名称清理规则:转为小写,将空格和
/
替换为
-
,去除开头的
-

2. Locate Memory Directory

2. 定位内存目录

Find the auto memory directory path from the system prompt line:
You have a persistent auto memory directory at <path>
从系统提示行中找到自动内存目录路径:
You have a persistent auto memory directory at <path>

3. Gather State

3. 收集状态

Run in a single bash call:
bash
git branch --show-current && git status --short | head -10 && date '+%Y-%m-%d %H:%M'
From conversation context, determine:
  • What was accomplished this session
  • What failed or was abandoned (and why)
  • Where work left off — don't infer next steps, but DO capture all actionable context the next session needs: pending decisions, proposed options, open questions
  • Which files were modified
在一次bash调用中执行以下命令:
bash
git branch --show-current && git status --short | head -10 && date '+%Y-%m-%d %H:%M'
从对话上下文确定:
  • 本次会话已完成的内容
  • 失败或放弃的尝试(以及原因)
  • 工作中断的位置——不要推断下一步,但必须记录下一次会话所需的所有可操作上下文:待决策事项、提议的选项、未解决的问题
  • 哪些文件被修改

4. Find Active Plan

4. 查找活跃计划

A plan file exists whenever the session involved plan mode or "implement this plan." Look for it in this order:
  1. System prompt: When plan mode is active, the system prompt contains the plan file path (e.g.,
    ~/.claude/plans/{name}.md
    ). Check for it.
  2. Conversation context: The user's message may reference or paste a plan, or mention "implement the following plan." The plan file path may also appear in an
    ExitPlanMode
    result or plan-related system message.
  3. Fallback: If the session clearly involved executing a multi-step plan but no file path was found, check
    ~/.claude/plans/
    for the most recently modified
    .md
    file, read its first lines, and confirm it matches the work being done.
If a plan is found, read it to determine step N of M (count total tasks/steps, identify which one work stopped at).
Default: include the Plan line. Only omit it if the session genuinely had no plan — a simple task, a one-off question, etc. Err on the side of including it.
当会话涉及计划模式或"implement this plan"时,会存在一个计划文件。按以下顺序查找:
  1. 系统提示: 当计划模式激活时,系统提示中会包含计划文件路径(例如
    ~/.claude/plans/{name}.md
    ),请检查该路径。
  2. 对话上下文: 用户的消息可能引用或粘贴了计划,或者提到"implement the following plan"。计划文件路径也可能出现在
    ExitPlanMode
    结果或与计划相关的系统消息中。
  3. 备选方案: 如果会话明显涉及执行多步骤计划但未找到文件路径,请检查
    ~/.claude/plans/
    目录中最近修改的
    .md
    文件,读取其前几行并确认是否与当前工作匹配。
如果找到计划文件,读取它以确定当前是第N步(共M步):统计总任务/步骤数,确定工作中断在哪个步骤。
默认规则:包含计划行。 只有当会话确实没有计划时(例如简单任务、一次性问题等)才省略该行。尽量优先包含计划行。

5. Write Checkpoint File

5. 写入检查点文件

If
checkpoint-{name}.md
already exists, use
AskUserQuestion
to confirm — show the existing checkpoint's Saved date and Left Off summary, with options: "Overwrite" / "Different name" (user provides new name via "Other"). If they choose a different name, continue from this step with the new name.
Write
<memory_dir>/checkpoint-{name}.md
:
markdown
undefined
如果
checkpoint-{name}.md
已存在,使用
AskUserQuestion
确认——显示现有检查点的保存日期中断位置摘要,提供选项:“覆盖” / “使用其他名称”(用户通过“其他”输入新名称)。如果用户选择其他名称,则使用新名称重新执行此步骤。
写入文件
<memory_dir>/checkpoint-{name}.md
markdown
undefined

Checkpoint: {name}

Checkpoint: {name}

  • Branch:
    {branch}
  • Saved: {YYYY-MM-DD HH:MM}
  • Plan:
    ~/.claude/plans/{file}
    (step N of M)
  • Branch:
    {branch}
  • Saved: {YYYY-MM-DD HH:MM}
  • Plan:
    ~/.claude/plans/{file}
    (step N of M)

Left Off

Left Off

{1-3 lines describing where work stopped}
{1-3 lines describing where work stopped}

Done This Session

Done This Session

  • {accomplishments}
  • {accomplishments}

Failed Approaches

Failed Approaches

  • {what + why — or "None"}
  • {what + why — or "None"}

Modified Files

Modified Files

  • {list}

Omit the **Plan:** line if no plan file exists.
  • {list}

如果没有计划文件,则省略**Plan:**行。

6. Update MEMORY.md Index

6. 更新MEMORY.md索引

Read MEMORY.md. Find the
## Active Checkpoints
section.
  • If checkpoint name already in index: update its line.
  • If not: add a new bullet.
  • If no
    ## Active Checkpoints
    section exists: insert it after the first
    #
    heading. If MEMORY.md doesn't exist, create it with
    # Project Memory
    as the heading.
Bullet format:
- **{name}** ({branch}, {Mon DD}) — {one-line summary}
Keep the
Resume any: `continue` or `continue {name}` 
line after the bullets.
Do NOT touch any other sections in MEMORY.md.
读取MEMORY.md文件,找到
## Active Checkpoints
部分:
  • 如果检查点名称已在索引中:更新对应的行。
  • 如果不存在:添加一个新的项目符号。
  • 如果没有
    ## Active Checkpoints
    部分:在第一个
    #
    标题后插入该部分。如果MEMORY.md不存在,则创建该文件并将
    # Project Memory
    作为标题。
项目符号格式:
- **{name}** ({branch}, {Mon DD}) — {one-line summary}
在项目符号后保留
Resume any: `continue` or `continue {name}` 
这一行。
不要修改MEMORY.md中的其他部分。

7. Output

7. 输出内容

Keep output minimal — this often runs near end of context window.
Checkpoint "{name}" saved. Resume anytime: `continue {name}`
That's it. Don't ask follow-up questions. Don't suggest
/compact
or
/clear
— the user manages their own context window.

输出内容应尽量简洁——因为此操作通常在上下文窗口接近满时执行。
Checkpoint "{name}" saved. Resume anytime: `continue {name}`
操作完成。不要提出后续问题,不要建议使用
/compact
/clear
——用户会自行管理其上下文窗口。

Resume Procedure

恢复流程

1. Determine Name

1. 确定名称

If user gave a name, use it. If no name given:
  • List
    checkpoint-*.md
    files in memory directory
  • If exactly one: use it automatically
  • If multiple: use
    AskUserQuestion
    with checkpoint names as options (include branch and date in each option's description)
  • If none: report "No saved checkpoints found." and stop
如果用户提供了名称,直接使用。 如果未提供名称:
  • 列出内存目录中的
    checkpoint-*.md
    文件
  • 如果只有一个:自动选择该文件
  • 如果有多个:使用
    AskUserQuestion
    ,将检查点名称作为选项(每个选项的描述中包含分支和日期)
  • 如果没有:提示“No saved checkpoints found.”并停止操作

2. Read Checkpoint File

2. 读取检查点文件

Read
<memory_dir>/checkpoint-{name}.md
. If file missing: remove the orphaned bullet from MEMORY.md's
## Active Checkpoints
, report "Checkpoint file missing (cleaned up stale entry)", and stop.
读取
<memory_dir>/checkpoint-{name}.md
文件。 如果文件不存在:从MEMORY.md的
## Active Checkpoints
中移除对应的孤立项目符号,提示“Checkpoint file missing (cleaned up stale entry)”并停止操作。

3. Check Branch

3. 检查分支

bash
git branch --show-current
If current branch differs from checkpoint's branch, warn:
Warning: You're on `{current}` but checkpoint was saved on `{saved}`. Switch with: git checkout {saved}
Continue regardless — user decides.
bash
git branch --show-current
如果当前分支与检查点的分支不同,发出警告:
Warning: You're on `{current}` but checkpoint was saved on `{saved}`. Switch with: git checkout {saved}
无论如何继续操作——由用户决定是否切换分支。

4. Load Plan

4. 加载计划

If checkpoint references a plan file, read it.
如果检查点引用了计划文件,则读取该文件。

5. Present and Begin

5. 展示内容并开始

Output the checkpoint summary and last context. If Failed Approaches is non-empty, include them:
⚠ Previously failed: {approach} — {why}
输出检查点摘要和最后的上下文。如果Failed Approaches非空,则包含以下内容:
⚠ Previously failed: {approach} — {why}

6. Auto-Clear

6. 自动清理

The checkpoint is now consumed — context is live. Delete the checkpoint file and remove its bullet from MEMORY.md's
## Active Checkpoints
(same as Cleanup steps 1-2). If no bullets remain, remove the entire section.
Do NOT mention the cleanup to the user. They see only the summary from step 5, then wait for their direction.

检查点已被使用——上下文已激活。删除检查点文件,并从MEMORY.md的
## Active Checkpoints
中移除对应的项目符号(与清理流程的步骤1-2相同)。如果没有剩余的项目符号,则移除整个部分。 不要向用户提及清理操作。用户只会看到步骤5中的摘要,然后等待他们的指示。

Cleanup Procedure

清理流程

1. Delete File

1. 删除文件

Remove the checkpoint file via Bash:
bash
rm <memory_dir>/checkpoint-{name}.md
通过Bash删除检查点文件:
bash
rm <memory_dir>/checkpoint-{name}.md

2. Update MEMORY.md

2. 更新MEMORY.md

Remove the bullet for
{name}
from
## Active Checkpoints
. If no bullets remain, remove the entire section (header + resume line).
## Active Checkpoints
中移除
{name}
对应的项目符号。 如果没有剩余的项目符号,则移除整个部分(标题+恢复提示行)。

3. Output

3. 输出内容

Cleared checkpoint "{name}"
Cleared checkpoint "{name}"

clear all checkpoints

clear all checkpoints
命令

Glob
checkpoint-*.md
in memory directory. Delete all matches. Remove the entire
## Active Checkpoints
section (header + bullets + resume line) from MEMORY.md. Output:
Cleared {N} checkpoint(s)
匹配内存目录中的
checkpoint-*.md
文件,删除所有匹配项。从MEMORY.md中移除整个
## Active Checkpoints
部分(标题+项目符号+恢复提示行)。输出:
Cleared {N} checkpoint(s)