/pstack-herdr:herdr-parallel-tasksfrom pstack-herdr
在 Herdr 里把几件独立的事分派给 agent 并行完成:一件事一个 agent 从头做到尾;同时有不止一个 agent 写代码时,每个各开一个 worktree。用于用户要求「这几件事并行做」「派几个 agent 分别去做」。要求 HC_TERMINAL_ID 已设置;否则停下来说明。
Ships in pstack-herdr. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
test -n "${HC_TERMINAL_ID:-}"
不满足就停下来,直接说「我不在 Herdr 的终端里,这套流程需要它」,不要用裸 git 命令硬凑。
同一时间有不止一个 agent 会写代码,才给每个写代码的 agent 各开一个 worktree。 只有一个在写,就用当前 checkout。
hc-spawn 起新 Tab 即可。仓库自己的 AGENTS.md / git 流程另有规定时,以仓库为准。
一件事由一个 agent 从头做完。不要因为「可以并行」就把一件事拆给两个 agent —— 并行发生在事与事之间,不在一件事内部。
agent 的 cwd 在进程启动那一刻钉死,之后没有任何办法改。所以:
git -C 去别人的 checkout 里干活;AGENTS.md 里的 .agents/skills/git-workflow/scripts/new-worktree 或 scripts/new-worktree)就优先用它;没有入口再用 git worktree add。需要 worktree 的一件事 = 两步:
# 1a) 仓库有入口:用它建(保留路径约定、基线刷新和环境准备)
<repo-root>/scripts/new-worktree <branch> # 以仓库文档为准;拿到新 checkout 路径
# 1b) 仓库没有入口:用 git worktree 建
git -C <repo-root> worktree add <新 checkout 路径> -b <branch>
# 2) 用 hc-spawn 在该 checkout 启动 worker(自动继承当前 herdr.space 开独立新 Tab,不分屏,挂在当前对话下)
hc-spawn --name <name> --cwd <新 checkout 路径> -- <agent> <模型参数...> "<任务描述 + 验收条件>"
没有安装 hc-spawn 时,等价展开为:
SPACE="$(hc get "$HC_TERMINAL_ID" --json | python3 -c 'import json,sys; print((json.load(sys.stdin).get("labels") or {}).get("herdr.space",""))')"
hc run --bg --name <name> --cwd <新 checkout 路径> --label "herdr.space=$SPACE" -- <agent> <模型参数...> "<任务描述 + 验收条件>"
不需要 worktree 时,跳过第 1 步,直接 --cwd <repo-root> 启动。
启动后用 hc get <name> --json 确认状态进入 working(若 first_message.sent 为 false,先 hc read --lines 40 <name> 看是否卡在启动提示)。
每件事取一个短名,例如 pre-commit、fix-login:
| 表面 | 值 |
|---|---|
终端名 (--name) | pre-commit |
| branch | 按仓库的命名约定,例如 chore/pre-commit;仓库没约定就用短名 |
任务来自 issue / ticket 时,按仓库约定把编号带进分支名即可,流程不变。--name 必须匹配 1–32 个 [a-z0-9_-] 字符且在存活终端内唯一,侧边栏和 hc ls 一眼就能对上。
herdr.space ID,绝不传 herdr.tab,保留默认 parent,不传 --rm —— 确保每个 worker 都是侧边栏里独立的新 Tab、不分屏、且挂在当前对话下面。codex 必带 --no-daemon(hc-spawn 会自动补上),否则 Codex 的命令会逃逸到 hc 之外。hc ls --json 或 hc get <name> --json。hc wait --children any / hc wait --children all / hc wait <name>,不要 sleep 轮询。hc read --lines 40 <name>(只看可见屏幕用 hc read --lines 0 <name>)。blocked:用 hc read --lines 40 <name> 看是什么,不替用户点批准,转述给用户决定。idle,必须同时核对报告文件已落盘。每个 worker 结束时写 <它的 checkout>/.herdr-report.md:做了什么、改了哪些文件、怎么验证、还剩什么。
主 agent 汇总这些文件回报给用户 —— 不要去翻 N 个终端的屏幕。
hc kill <name> && hc rm <name>(只清理自己起的,别碰用户的其他终端)。finish-branch 或 git worktree remove)。Herdr(hc)只负责终端进程与侧边栏归属;分支、worktree、commit、PR、合并后删分支,都是 git 的事。
并行派活时,主会话是调度台:建拓扑、派工、汇总。它自己也要写代码时,就算一个写代码的 agent,按上面「什么时候开 worktree」的规则计数。
| 反模式 | 为什么错 |
|---|---|
裸跑 hc run --bg 不传 herdr.space | Herdr 默认继承父终端的 Tab,直接把当前画面分屏 |
传了 herdr.tab | 强制分屏进当前 Tab,破坏独立 Tab 布局 |
起 codex 漏掉 --no-daemon | Codex 命令逃逸到 hc 之外,状态和父子关系失效 |
先起 agent 再让它 cd 进 worktree | cwd 钉死在启动时刻,无法事后切换 |
| 只有一个 agent 在写也开 worktree | 多一层拓扑,没换来任何隔离 |
| 多个 agent 同时写同一个 checkout | 互相覆盖,测试结果不可信,diff 分不清是谁的 |
| 主会话里用内部 subagent 干要并行写代码的活 | 侧边栏不可见、无法随时接管或看 blocked |
| 一件事拆给两个 agent | 并行粒度错了,合并成本远大于收益 |
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub dengnaichen/pstack-herdr --plugin pstack-herdr31 skills in this plugin
/architectSketch types, signatures, and module structure before code, then stay in the loop while implementation fills in. Use for /architect, 'architect this', 'design this', or non-trivial work where jumping to code would lock in the wrong shape./arena让不同家族的模型(Claude / OpenAI / Google)在 Herdr 里各自独立出一份方案,由当前会话主持:交叉评审、挑底稿、嫁接其他方案的长处,交给用户拍板。只用于方案类问题:架构、设计、技术选型。用于 /arena、'arena this'、'丢进 arena',以及其他 skill(如 architect)要求运行 arena 时。不写代码。要求 HC_TERMINAL_ID 已设置。/figure-it-outDesign an auditable playbook when no narrower one fits: a large migration, an ambitious multi-part change, or work a human reviews after stepping away. Scales rigor to the task, runs a hypothesis loop, and logs decisions via show-me-your-work. Use for /figure-it-out, 'figure it out', a large migration, or when no narrower playbook applies.Other plugins' skills for the same job