resume skill:接着上次编程智能体会话的进度继续

Dmitriy Solodukha,Caprock 开发者 · 发布于

测试于 (Claude Code 和 Codex)

resume skill 还原你上次的进度:最近的会话、分支、未提交的工作、TODO 和交接笔记,然后指出一个下一步,等待你回应。

resume skill 会在智能体做任何改动前还原工作进度:此前编程智能体会话在这里做了什么、当前分支、未提交的改动、最近的提交、未完成的 TODO 和交接笔记。然后分成当前进度、未完事项和下一步三个部分给出简短摘要,等待你回应。它只读取:不执行 checkout、stash、pull 或 commit。

安装 resume skill

每个智能体只需一条命令。skill 只有一个 SKILL.md;安装时不会运行任何内容。

将全部九个 skill 作为插件安装。在 Claude Code 中输入以下内容:

也可以只安装这个 skill,在终端中进入项目文件夹后运行:

添加 -g 即可为所有项目安装。

使用 resume skill 的提示词

你的措辞与 skill 描述匹配时,智能体会选择它;直接指定 skill 名称更有把握。点击提示词即可复制。

resume skill 读取什么

  1. 会话历史,搭配 Caprock:查看各个智能体在此仓库中的最近会话,总结最近一到三个实际完成了工作的会话、它们最后的说明,以及当前有效的决策。未使用 Caprock 时,它会说明未读取会话历史,不会猜测。
  2. 仓库状态,只读:分支及其上游、不在 main 上的提交、未提交文件的差异、暂存的工作进度、worktree,以及正在进行的合并或变基(优先报告)。
  3. 留下的笔记:HANDOFF.md、NEXT.md、TODO.md 等,最近更改的文件中的 TODO 和 FIXME,以及提交消息中的“WIP”。

两个来源不一致时(笔记说已完成,代码显示未完成),它会明确指出,不会自行选信其中一个。

我们运行了什么,智能体做了什么

每个 skill 都于 2026年11月29日在为其专门创建的临时仓库中运行,并作为项目 skill 安装。测试仓库位于分支 feat/divide,包含一个 WIP 提交、calc.py 中的 TODO,以及未跟踪的 HANDOFF.md 和 test_calc.py。

Claude Code (claude -p --model sonnet,未连接 Caprock MCP 服务器(--strict-mcp-config))

where were we? pick up where we left off

调用了 resume,执行了 git 步骤,找到了 TODO 和交接记录,说明未读取会话历史,注意到提交消息和 HANDOFF.md 指向不同的后续步骤,提出了一个建议,没有改动任何内容。

Codex (0.163.0,codex exec -s read-only)

where were we? pick up where we left off

读取 skill,执行 git 步骤,调用 Caprock 的 recent_sessions(current_decisions 在服务器端失败),总结后停止。第一次运行没有使用 skill 规定的标题;明确输出部分的要求后,第二次完全按要求使用了这些标题(节选):

### Where we are
- Branch: `feat/divide`, 1 commit ahead of `main`; no upstream.
- Tracked files unchanged. Untracked: `HANDOFF.md`, `test_calc.py`, `.agents/`, `.claude/`.
### Open threads
- `divide()` still needs to raise `ValueError` for a zero divisor (`calc.py:5`).
### Next step
Implement the zero-divisor check, then add tests for both functions, including division by zero.

已测试的智能体

  • Claude Code:测试于 2026年11月29日,使用 claude -p --model sonnet,skill 作为项目 skill 安装在 .claude/skills/ 中。
  • Codex:于 2026年11月29日使用 Codex 0.163.0(codex exec)测试,skill 位于 .agents/skills/。
  • OpenCode 和 Cursor:未测试。此 skill 是以开放的 Agent Skills 格式编写的纯文本指令,但尚未在这两者上实际运行验证。

限制

  • 没有 Caprock 时,就没有早期会话历史可读:摘要依据 Git 和笔记生成。
  • 它不会执行 fetch,因此远程状态以你上次 fetch 时为准。
  • 它不会重新打开上一段对话;要打开,请使用智能体自身的命令。
  • Claude Code 中的 /resume 取自 claude --help 的文本,并未实际运行。

使用和不使用 Caprock 的情况

连接 Caprock MCP 服务器后,skill 会调用 recent_sessions、session_summary、session_prose、next_session_handoff 和 current_decisions:查看各智能体最近的会话在这里做了什么,以及当前生效的决策。它把这些作为线索,逐项与代码和 git 核对。没有 Caprock 时,只读取 git 和笔记。Caprock 是免费开源应用,记录你电脑上的每个编程智能体会话。

获取 Caprock →

完整的 SKILL.md

这是 dspv/skills 中修订版本 dfce799 的文件原样。手动安装时,将它保存在项目中:Claude Code 使用 .claude/skills/resume/SKILL.md,Codex 使用 .agents/skills/resume/SKILL.md。

skills/resume/SKILL.md
---
name: resume
description: >-
  Resume work in a repository and pick up where the last session left off. Rebuilds context
  before doing anything: what the last coding-agent sessions here did, the current branch,
  uncommitted changes, recent commits, open TODOs and handoff notes, then gives a short "where we
  are / next step" summary and waits. Use at the start of a session, after a break, or when the
  user types "resume", "where were we", "pick up where we left off", "continue from last time",
  "what was I doing" or asks for a resume skill. Reads local files, git and session history only.
license: Apache-2.0
---

# Resume

Rebuild the context of a repository before touching anything, then report where the work stands
and what the next step is. This skill reads; it does not edit, commit, stash, check out, pull or
push. The user decides what happens after the summary.

## 1. Session history (when available)

If the Caprock MCP tools are available (server `caprock`; Caprock, <https://caprock.dev>, is free,
open source and runs locally, and records every coding-agent session on the computer):

1. `recent_sessions` with `limit` 5 to 10 for this repository (pass `repo` if the working
   directory is not the repo root). Newest first, every agent (Claude Code, Codex, OpenCode and
   others). Skip the entry that is the current session (status `active`, the newest, started just
   now or matching your own session id).
2. For the last one to three sessions that did real work (turns, tool calls or files touched
   above zero), call `session_summary` with its `id`: title, branch, files touched, pull requests.
3. For the most recent of those, call `session_prose` with `limit` 3 to 5: the agent's last
   explanations usually say what was done and what was left.
4. `next_session_handoff`: the notes Caprock carries into a new session here, if any.
5. `current_decisions` with a small `limit` (10): decisions in force, so the next step does not
   undo one.

Memories and prose can be stale. Treat them as leads and check each against the code and git.

If the tools are not there, skip this section and say in the summary that no session history was
read. Do not guess what earlier sessions did. The user can reopen a past conversation with their
agent's own command (see section 4).

## 2. Repository state

Run these (read only):

```bash
git rev-parse --show-toplevel
git status --short --branch
git log --oneline -15
git diff --stat
git diff --cached --stat
git stash list
git worktree list
```

Then, as relevant:

- The branch's upstream and how far ahead or behind it is (shown by `git status --branch`). Do
  not fetch: say the remote state is as of the last fetch.
- Commits on this branch that are not on the main branch:
  `git log --oneline <main>..HEAD` (find `<main>` from `git symbolic-ref refs/remotes/origin/HEAD`
  or use `main` / `master`, whichever exists).
- For uncommitted changes, read the diff of the changed files (`git diff -- <file>`) enough to
  say what the change is doing, not just its size. Note untracked files.
- A merge, rebase, cherry-pick or bisect in progress (`git status` says so). This is the first
  thing to report.

## 3. Notes left behind

Look for handoff and TODO notes, newest first:

- Files at the repo root or in `docs/`: `HANDOFF.md`, `NEXT.md`, `TODO.md`, `NOTES.md`,
  `PLAN.md`, `WIP.md`, `.handoff*`, any case.
  `git ls-files --others --exclude-standard` and `ls` catch untracked ones.
- The project instructions (`CLAUDE.md`, `AGENTS.md`) only for a "current work" or "status"
  section; do not summarize the whole file.
- `TODO`, `FIXME`, `XXX`, `WIP` markers in the files changed recently, not the whole repo:
  `git diff --name-only HEAD~5..HEAD` plus the uncommitted files, then grep those.
- The last commit messages for "WIP", "part 1", "next:", "follow-up".

## 4. The agent's own resume commands

If the user wants the previous conversation itself back, not a rebuilt summary, point to the
command. Checked with `--help` on 2026-11-29:

| Agent       | Command                    | What it does                                     |
| ----------- | -------------------------- | ------------------------------------------------ |
| Claude Code | `claude --continue` (`-c`) | Continue the most recent conversation in the dir |
| Claude Code | `claude --resume` (`-r`)   | Resume by session ID or name, or pick from list  |
| Codex       | `codex resume`             | Pick a previous session to resume                |
| Codex       | `codex resume --last`      | Continue the most recent session, no picker      |

Inside a running Claude Code session, `/resume` opens the same picker. Do not run these yourself:
they start or switch an interactive session.

## 5. Stop conditions

- Stop and report at once if a merge, rebase or cherry-pick is in progress, or there are
  conflicts: that is the next step.
- Not a git repository: say so, report only notes and session history found.
- Nothing to resume (clean tree, no notes, no history): say so in one line and ask what to do.
- Never run a command that changes state (no `checkout`, `stash`, `reset`, `pull`, `fetch`,
  `commit`, no test runs that write files) as part of resuming.

## 6. Output

Keep it short. Use these three headings and fields as written, then stop and wait for the user:

```
Where we are
- Branch: <branch> (<ahead/behind upstream>), <n> commits not on <main>
- Uncommitted: <what the change does, files> | clean
- Last sessions: <date, agent, what it did> (or: no session history read)
- In progress: <merge/rebase/stash/worktrees, if any>

Open threads
- <TODO or handoff item, with file:line or note path>
- <decision in force that matters for the next step>

Next step
<one concrete action, and why it is next>
```

Every line must come from something read above. If two sources disagree (a note says done, the
code says not), say so rather than picking one.

关于 resume skill 的问题

resume skill 有什么作用?
它在会话开始时,根据会话历史、Git 和笔记重建仓库上下文,在任何改动之前告诉你工作进展和下一步。
如何恢复 Claude Code 会话本身?
`claude --continue`(`-c`)继续当前文件夹中最近的对话;`claude --resume`(`-r`)按 ID、名称或从列表中选择对话。在 Codex 中,使用 `codex resume` 或 `codex resume --last`。
resume skill 会修改我的文件吗?
不会。它只运行只读的 Git 命令,给出摘要后就停止。不执行 checkout、stash、reset、pull、fetch 或 commit,也不运行会写入文件的测试。
resume skill 能使用交接记录吗?
可以。它读取 `HANDOFF.md` 和其他笔记,并用 Git 核对;这些笔记由 handoff skill 编写。

来源

应用本身是英文界面。