claude-delegate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseClaude Delegate
Claude 委托机制
You are the orchestrator. Delegate one bounded coding task to a separate implementer — a Claude
Code CLI session — then review what it produced and land it yourself. You write the brief and own the
judgment; the separate Claude session edits the working tree; you verify and commit.
This skill is not a signal for the current Claude to implement directly. Use it only after the human
explicitly asks for delegation to another Claude Code process or session.
你作为协调方,将一个限定范围的编码任务委托给独立的实现方——一个Claude
Code CLI会话——然后审核其产出内容并自行完成提交。由你撰写任务简报并负责判断;独立的Claude会话负责修改工作树;你进行验证并提交。
该技能并非让当前Claude直接实现任务的信号。仅当用户明确要求委托给另一个Claude Code进程或会话时,才可使用该技能。
When not to use this
禁用场景
- The human asked the current agent to implement the task directly.
- The task is small enough to do inline and the human did not request delegation.
- The CLI is missing or unauthenticated (
claude).claude auth status - The task needs a stronger host boundary than Claude Code's tool permissions and shell-only sandbox provide. Use an isolated container or VM for that requirement.
- 用户要求当前Agent直接实现任务。
- 任务规模小到可以直接完成,且用户未要求委托。
- CLI缺失或未认证(执行
claude查看)。claude auth status - 任务需要比Claude Code的工具权限和仅沙箱Shell更强的主机隔离边界。此类需求请使用独立容器或虚拟机。
Prerequisites
前置条件
- succeeds.
claude --version - reports an authenticated session.
claude auth status - The target repository is the directory passed with .
--cd - On Linux/WSL2, Claude's sandbox dependencies are installed. The normal relay profile is configured to fail when the sandbox is unavailable instead of silently running shell commands unsandboxed. Existing merged settings can still affect the effective boundary.
- 执行成功。
claude --version - 显示已认证会话。
claude auth status - 目标仓库是通过参数指定的目录。
--cd - 在Linux/WSL2系统中,已安装Claude沙箱依赖项。正常中继配置会在沙箱不可用时直接失败,而非静默运行未沙箱化的Shell命令。已合并的设置仍会影响实际隔离边界。
The loop
工作流程
1. Write the brief
1. 撰写任务简报
The separate session has no orchestrator chat history. It receives the brief on stdin and can inspect
the target working tree.
Claude Code automatically discovers the target project's and normal local Claude
configuration because the relay does not use . It does not generically auto-load
. Read yourself and copy every load-bearing constraint and the real gate
commands into the brief. Tell the implementer not to commit. Keep one task per brief.
CLAUDE.md--bareAGENTS.mdAGENTS.mdTemplate and details: references/writing-the-brief.md.
独立会话没有协调方的聊天历史。它会通过标准输入接收任务简报,并可检查目标工作树。
Claude Code会自动发现目标项目的和常规本地Claude配置,因为中继不会使用参数。但它不会自动加载通用的。你需要自行读取,并将所有关键约束和实际验证命令复制到任务简报中。告知实现方不要提交。每份简报对应一个任务。
CLAUDE.md--bareAGENTS.mdAGENTS.md模板及详细说明:references/writing-the-brief.md。
2. Dispatch
2. 分发任务
bash
node "<skill-dir>/scripts/relay.mjs" --brief brief.txt --cd /path/to/repobash
node "<skill-dir>/scripts/relay.mjs" --brief brief.txt --cd /path/to/reporeview/diagnosis only: add --read-only
仅用于审核/诊断: 添加 --read-only
continue the latest session: add --resume-last
继续最近的会话: 添加 --resume-last
continue the recorded session: add --session <id>
继续指定记录的会话: 添加 --session <id>
choose limits: add --max-turns 40 --max-budget-usd 10
设置限制: 添加 --max-turns 40 --max-budget-usd 10
hard relay deadline: add --timeout 2h
设置中继硬截止时间: 添加 --timeout 2h
inspect every option: node .../relay.mjs --help
查看所有选项: node .../relay.mjs --help
`<skill-dir>` is this installed skill directory, the folder containing this `SKILL.md`.
The relay runs `claude -p --output-format stream-json --verbose`, sends the brief through stdin, and
writes artifacts under the system temp directory by default. It never uses `--bg` or `--bare`, and it
never commits. See [references/dispatch-and-poll.md](references/dispatch-and-poll.md).
`<skill-dir>`是该已安装技能的目录,即包含此`SKILL.md`的文件夹。
中继会运行`claude -p --output-format stream-json --verbose`,通过标准输入发送任务简报,并默认将产物写入系统临时目录。它绝不会使用`--bg`或`--bare`参数,也绝不会执行提交操作。详情请见[references/dispatch-and-poll.md](references/dispatch-and-poll.md)。3. Wait
3. 等待执行
The relay blocks until Claude exits. Use the orchestrator's background-command facility, or run it in
the foreground and wait. Completion means the process exited and exists.
result.json- A pre-run usage error exits 2 and writes no .
result.json - A missing exits 127 and writes
claude.status: "claude_unavailable" - Timeout and caught relay signals terminate the whole implementer process tree and preserve an outcome artifact.
Read , , , and the raw artifact paths from .
finalMessagetouchedFilesresultSubtyperesult.json中继会阻塞直到Claude退出。可以使用协调方的后台命令功能,或在前台运行并等待。完成意味着进程已退出且文件存在。
result.json- 预运行使用错误会以状态码2退出,且不会生成。
result.json - 缺失会以状态码127退出,并写入
claude。status: "claude_unavailable" - 超时和捕获到的中继信号会终止整个实现方进程树,并保留结果产物。
从中读取、、以及原始产物路径。
result.jsonfinalMessagetouchedFilesresultSubtype4. Review
4. 审核内容
Treat the implementer's report and gate outcomes as claims:
- Review edits to existing tests before a green gate means anything.
- Re-run the project's actual gates yourself.
- Read the complete diff against the brief, starting with .
touchedFiles - Inspect untracked and staged content as well as the ordinary diff.
- Run relevant guard skills if installed.
Full checklist: references/review-and-land.md.
将实现方的报告和验证结果视为待确认的声明:
- 在验证通过前,先审核对现有测试的修改。
- 自行重新运行项目的实际验证流程。
- 对照任务简报查看完整差异,从开始。
touchedFiles - 除常规差异外,还要检查未跟踪和已暂存的内容。
- 如果已安装相关防护技能,请运行它们。
完整检查清单:references/review-and-land.md。
5. Land
5. 完成提交
The orchestrator commits only after the gates pass and the diff holds. For rework, resume the same
Claude session with a delta brief:
bash
echo "Keep the implementation, replace the mocked DB test with the migrated fixture, and remove the
unused import." | node "<skill-dir>/scripts/relay.mjs" --session <id> --cd /path/to/repoReview a resumed run exactly like the first run.
只有在验证通过且差异符合要求后,协调方才可执行提交。如需返工,请使用增量简报恢复同一个Claude会话:
bash
echo "保留现有实现,将模拟数据库测试替换为迁移后的测试夹具,并移除未使用的导入。" | node "<skill-dir>/scripts/relay.mjs" --session <id> --cd /path/to/repo恢复后的运行审核流程与首次运行完全相同。
Permission profiles
权限配置文件
The normal profile is deliberately explicit:
- permission mode.
acceptEdits - Built-in tools restricted to Read, Glob, Grep, Edit, Write, and the platform shell.
- On macOS, Linux, and WSL2, Claude's shell sandbox is enabled with startup failure on missing dependencies and no unsandboxed retry. Commands that stay sandboxed are auto-approved so ordinary gates can run headlessly. The sandbox governs shell processes and their children only; merged local or managed sandbox settings can add effective paths or exclusions.
- Configured MCP discovery and Claude.ai connectors are disabled, all MCP tools are denied, and
skills, commands, and Claude's Agent tool are unavailable to the child. Project , hooks, normal authentication, session persistence, and other local settings still load.
CLAUDE.md - String rules deny common direct shell forms of ,
git commit, and nestedgit push, plus any command containingclaude. Aliases, scripts, and wrappers can bypass them, so they are only a speed bump; the brief's no-commit instruction and orchestrator review remain the boundary.claude-delegate
Native Windows does not support Claude's shell sandbox. The relay restricts the tool surface and
pre-approves PowerShell so the run remains non-interactive, but that shell is not OS-isolated. Native
and npm launch paths are implemented; Windows verification is pending.
claude.execlaude.cmd--read-onlyplanreadOnlyViolationtruefalsenull--dangerously-skip-permissionsbypassPermissions常规配置文件设计得非常明确:
- 权限模式。
acceptEdits - 内置工具限制为Read、Glob、Grep、Edit、Write以及平台Shell。
- 在macOS、Linux和WSL2系统中,Claude的Shell沙箱已启用,若依赖项缺失则启动失败,且不会重试未沙箱化的操作。保持沙箱化的命令会自动批准,以便常规验证流程可以无头运行。沙箱仅管控Shell进程及其子进程;合并后的本地或托管沙箱设置可添加实际路径或排除项。
- 已禁用配置的MCP发现和Claude.ai连接器,拒绝所有MCP工具,子进程无法使用技能、命令和Claude的Agent工具。项目的、钩子、常规认证、会话持久化及其他本地设置仍会加载。
CLAUDE.md - 字符串规则禁止、
git commit和嵌套git push等常见直接Shell形式,以及任何包含claude的命令。别名、脚本和包装器可以绕过这些规则,因此它们只是一个防护措施;任务简报中的禁止提交指令和协调方审核仍是核心边界。claude-delegate
原生Windows不支持Claude的Shell沙箱。中继会限制工具范围并预先批准PowerShell,以保持运行非交互式,但该Shell并未进行系统隔离。已实现原生和npm 的启动路径;Windows验证仍在进行中。
claude.execlaude.cmd--read-onlyplanreadOnlyViolationtruefalsenull--dangerously-skip-permissionsbypassPermissionsComplementary to native Claude features
与Claude原生功能的互补性
Claude subagents, agent teams, and background sessions are useful when the current Claude environment
is already the orchestrator and native coordination is the goal. This skill is complementary: it
provides a cross-orchestrator contract — self-contained brief → dispatch → artifacts → review → land
— and keeps the commit with the orchestrator.
当当前Claude环境已作为协调方且目标是原生协作时,Claude子Agent、Agent团队和后台会话非常有用。本技能是一种补充:它提供跨协调方的约定——独立简报→任务分发→产物生成→审核→提交——并由协调方负责提交操作。
References
参考资料
- references/writing-the-brief.md — context, versus
CLAUDE.md, real gates, report contract, and delta briefs.AGENTS.md - references/dispatch-and-poll.md — flags, profiles, artifacts,
, polling, and failure recovery.
result.json - references/review-and-land.md — generated-code review, the commit boundary, and session rework.
- references/multi-task-queues.md — sequential queues, progress tracking, constraint carry-forward, and final coherence.
- references/writing-the-brief.md — 上下文信息、与
CLAUDE.md的区别、实际验证流程、报告约定及增量简报。AGENTS.md - references/dispatch-and-poll.md — 参数、配置文件、产物、、轮询及故障恢复。
result.json - references/review-and-land.md — 生成代码审核、提交边界及会话返工。
- references/multi-task-queues.md — 顺序任务队列、进度跟踪、约束传递及最终一致性。