Stephan:多 Agent 管理的經驗(含 pi-matt-implement-flow)
- 作者
- Stephan(@Stephan_Talk)
- 日期
- 2026-10-28 10:52(台北時間)
- 來源
- https://x.com/Stephan_Talk/status/2115275382303953140
- 是否完整
- 完整。貼文加上倉庫 README 中英全文。
- 抓取時間
- 2026-11-23 09:00(台北時間)
這篇在說什麼
四條經驗:別把任務切太細,他覺得小時級最舒服;幾十、幾百個單元測試不能說明品質,要有符合需求的端到端驗證;他推薦 pstack 的驗證 skill,並要隨著專案更新;溝通要非同步,窗口極限約 3 到 4 個。他用 Matt 的流程問出一批票後,可自主跑幾小時,並開源了 pi-matt-implement-flow:隔離 worktree 平行寫碼、每張票雙軸審查、整合測試門禁、整支分支終審。
以上摘要整理自 2026-11-22 的閱讀筆記,並對過本包原文。完整論證以下面正文為準。
全文
Stephan:多 Agent 管理的經驗(含 pi-matt-implement-flow)
- 來源: https://x.com/Stephan_Talk/status/2115275382303953140
- 作者: Stephan(@Stephan_Talk)
- 日期: 2026-10-28 10:52(台北時間)
- 抓取時間: 2026-11-23 09:00(台北時間)
- 是否完整: 完整(貼文全文+倉庫 README)
- 說明/缺漏:
- 貼文裡附的專案:https://github.com/toomanyopenfiles/pi-matt-implement-flow
- 已抓英文 README 與簡體中文 README 全文。
貼文全文
分享下我在多 Agent 管理时的一点经验:
不要把任务切分的太细,重点放在设计和验收
正如宝玉老师所说,管多 Agent 正如管人一样。新的技术管理者最容易陷入的误区就是事无巨细的管,导致自己最容易成为瓶颈
管 Agent 也是,如果每个 Agent 的执行粒度是几分钟的话,很快人的脑袋就晕了,上下文切不过来,也容易管出问题
我目前体会是每个任务控制在小时粒度(长的话有几小时的)是最舒服的,这就需要设计阶段多花些时间和 Agent 调研和讨论,形成文档化的共识后让它去慢慢跑。与此同时我再切到下一个 Agent 讨论和布置任务
- 验收要落在实处,“多少测试用例绿了” 不能说明任何问题
Agent 在跑长程任务后很容易跑出几十上百个单元测试,
这些不是质量证据,甚至不能说明 spec 的遵从度。只有从设计角度出发,写一套符合需求的端到端验证,拿到验证证据才算数
这方面特别推荐使用 pstack 的以下两个元技能(用来创建skill的skill):
/
create-verification-skill
/create-formal-verification-skill
第一个能帮你创建一个 e2e 测试的基础设施、以及当前项目的功能地图,根据功能地图进行真实的e2e测试:
https://t.co/oAV599JOyu
第二个是对第一个测不到的地方的补充,比如无法枚举的测试、并发竞态条件等,用形式化验证来做数学证明,确保复杂状态的正确性
相对应的 lauren 还提供了两个维护更新这两个skill的元skill,简单说就是项目功能在不断迭代过程中,验证类的skill也要随项目不断更新才行
- 与多 Agent 的沟通方式:不要打乱自己的节奏
刚开始管理多 Agent 的时候,我开很多窗口,一有 Agent 完成任务了我就切过去看,很快证明这样马上就会乱成一坨
多 Agent 管理必然是异步沟通的方式,这有点像是 CPU 的时间片切换,不应该一有消息就马上切,而是 Agent 异步通知 → 我看到通知了 → 等我把手头的一个检查点工作做完 → 再切过去接收
Agent 永远是在挂起等我反馈,而我只有做完当前“线程”的阶段性事务才会切我的注意力过去
目前我的窗口极限大概就3-4个,这和当前 AI 的长程能力也息息相关(如果未来Agent可以按天高质量交付了,这个窗口数就能扩大)
- 反模式:单任务不要过大
按照当前的前沿模型能力,我认为单任务最长控制在小时级别是合适的,到天级别很容易跑歪
之前我跑了一个几天的长程任务,跑完发现一堆问题,最后还是不得不全部回滚了
这还是上面说到的原因:当前最前沿模型的能力,我的感觉还到不了天级别
上下文窗口、幻觉、自动压缩、指令遵从性等等,会让 Agent 在长程任务上的问题会逐渐放大到不可控
以上就是我在管理多 Agent 上的一点经验,欢迎讨论下:你现在能控制几个 Agent ?每个的平均时长是多少?如何把控质量?
附錄:pi-matt-implement-flow README(英文)
來源:https://raw.githubusercontent.com/toomanyopenfiles/pi-matt-implement-flow/main/README.md
pi-matt-implement-flow
pi-matt-implement-flow is a package for pi: one skill (/pi-matt-implement-flow) plus three agents — coder, reviewer, and final-reviewer.
It covers the part of Matt Pocock's /implement that stops scaling when the work is many tickets with dependencies between them: a single session moving one ticket at a time, you watching for what has unlocked, and no quality gate per ticket.
The upstream flow stays as-is: /grill-with-docs → /to-spec → /to-tickets. This package takes over the last step — implementing the ticket graph, getting implementation, review, and testing done in one command.
English | 简体中文
Capabilities
- Parallel by dependency, no context to fight over — each ticket gets its own throwaway worktree and a fresh context; independent tickets run in parallel, blocked ones start automatically once their prerequisites close.
- Throwaway workspaces managed for you — temp worktrees and branches are created when needed and reclaimed when a ticket ends; nothing to maintain by hand.
- Reviewed as soon as it is written, fixed until it passes — each ticket gets a two-axis review right after coding — the repo's coding standards and the spec — and failures go back for fixes while there is a reasonable next step within the approved scope; otherwise the run pauses for your input.
- Coding and review are separate roles, configured separately — coder and reviewer are independent agents; each role can have its own model and thinking level.
- The full suite runs on every merge — each ticket merged into the feature branch immediately triggers the project's full test suite, so integration problems surface on the ticket that caused them instead of piling up at the end.
- A whole-branch final review — after the last ticket merges, the entire feature branch is reviewed once more for what single-ticket reviews cannot see: cross-file drift, components contradicting each other, spec requirements no ticket implemented, docs that no longer match the code.
- Interrupted runs resume — a run's progress is recorded in a local run directory inside your repo; after an interruption or context compaction it continues from the recorded state, not from memory.
- Repairs without a retry quota — ticket repairs do not stop just because an attempt count was reached. When a requirement decision, permission, external condition, or evidence-backed next step is missing, the run pauses and explains what it needs from you. With GitHub or GitLab the run opens a draft PR or MR at the start; with local markdown the feature branch itself is the deliverable.
- Three trackers, first-class — local markdown, GitHub Issues, or GitLab Issues: the run picks up whichever tracker
/setup-matt-pocock-skillsset up in your repo. With GitHub or GitLab your tickets are updated automatically at the end — merged tickets closed and linked to their commits, escalations commented and left open — two sessions can never silently start the same feature, and renamed labels are still recognized.
Requirements
- pi coding agent with the pi-subagents package (parallel dispatch, managed worktrees, resume)
- Matt Pocock's engineering skills — the upstream commands (
/grill-with-docs→/to-spec→/to-tickets) and the skills the agents work with:tdd,codebase-design,code-review,resolving-merge-conflicts
This package does not replace the upstream flow — it only takes over the implementation stage.
- Remote trackers also need the host CLI for that tracker:
ghfor GitHub,glabfor GitLab (installed and signed in to the target host). Local markdown needs no CLI.
Before every run, check three things: a clean worktree, at least one commit in the repo, and a full-suite test command that runs.
Tracker support
Where your tickets live is not a flag — it comes from the two setup files /setup-matt-pocock-skills wrote into your repo: docs/agents/issue-tracker.md plus the triage-labels.md beside it. The run identifies your tracker from them automatically (edited wording in the files is fine).
| Tracker | Status | PR / MR | Notes |
|---|---|---|---|
Local markdown (.scratch/<feature>/) |
first-class | none | your ticket files stay the single source of truth — nothing is synced either way |
| GitHub Issues | first-class | PR | your issues are updated automatically at the end (merged tickets closed with their commit linked); ticket dependencies expressed via sub-issues |
| GitLab Issues | first-class | MR | your issues are updated automatically at the end (a note is posted before a ticket closes); ticket dependencies without sub-issues; self-hosted GitLab works too |
| Anything else | explicitly unsupported | — | not guessed, not degraded — the run stops with a clear error, see below |
When the setup is missing or does not look like one of the three, the run stops with a clear error instead of guessing: setup files missing → run /setup-matt-pocock-skills in your repo; tracker not recognized → the run refuses with 仅支持 local / github / gitlab 三种 (only these three are supported).
Install
Install into pi from npm:
pi install npm:pi-matt-implement-flow
Quick start
- One-time setup — install pi, pi-subagents, and Matt Pocock's engineering skills, then run
/setup-matt-pocock-skillsonce in your repo. - Prepare the work:
/grill-with-docs
/to-spec
/to-tickets
- Run:
/pi-matt-implement-flow [N]
N is the number of parallel coders; the command-line value overrides the configured default (see Configuration). Most tickets finish on their own; when progress needs your decision or help, the run explains the blocker and pauses rather than waiting until the end to tell you.
What you get
After normal, complete delivery, you have:
- a merged feature branch — every accepted ticket's changes on it, with the full test suite green;
- with GitHub / GitLab: a draft PR / MR marked ready for review, and your tracker tickets updated (see Tracker support);
- a run directory
.pi/matt-implement/<feature>/(see Run directory): a human-readable progress ledger (ledger.md), notes (notes.md), and the evidence behind the result (also summarized at the end); - optionally, a browsable audit report of the whole run.
How it works
The roles
A run has four roles. The last three take a model and thinking level (see Configuration):
| Role | Does | Doesn't |
|---|---|---|
| Main agent (the skill running in your current session) | Reads the spec and ticket graph, dispatches by dependency, merges, runs the full suite, decides what comes next | Never writes feature code |
| coder | Implements one ticket in its own worktree (tests first, then the implementation), commits everything, reports verifiable results | Never touches ticket status, merges, or pushes |
| reviewer | Read-only review of that one ticket: repo standards + the spec / ticket requirements | No code changes, no test runs (tests already ran at the gate) |
| final-reviewer | After everything merges, reviews the whole feature branch — including what only cross-ticket eyes can see | Also read-only, no code changes |
The flow
- Read the spec and the ticket dependency graph; create (or reuse) the feature branch.
- Pick the tickets with no unfinished prerequisites and dispatch coders up to the concurrency cap — one ticket per coder, one worktree per ticket.
- When a coder finishes: the ticket's gate tests run → (if per-ticket review is on) the reviewer does a two-axis review → failures go back to the same coder while there is a reasonable next step within the approved scope.
- Merge into the feature branch and immediately run the full suite; if it is red, fix the integration problem on the feature branch.
- Recompute the next batch of doable tickets and repeat 2–4 until everything is done, pausing when your input is needed.
- The final-reviewer reviews the whole branch. Only after the work is complete and the branch has passed the necessary validation and final review does the run finish normally; with GitHub or GitLab, the draft PR / MR is marked ready for review.
flowchart TD
A["Read spec + ticket graph<br>create feature branch"] --> B["Dispatch coders in parallel<br>one ticket per worktree"]
B --> C["Review each ticket<br>failures loop back"]
C --> D["Merge<br>run full test suite"]
D --> E{"Tickets left?"}
E -- yes --> B
E -- no --> F["Whole-branch final review"]
F --> G{"Ready?"}
G -- no --> H["Repair or pause for your input<br>check evidence; repeat review if needed"]
H --> G
G -- yes --> I["Complete delivery<br>PR / MR ready"]
Ticket repair has no attempt quota. A clarification or withdrawal of one review finding is not approval to merge: the necessary full review and validation must still cover the current code. More than one repair can happen between reviews, and a fresh full review can happen without another code change.
Repairs and pauses
Ticket, integration, and final-review repairs follow the same rule: continue when there is a
reasonable, evidence-backed next step within the approved scope. Repeated failures prompt a
fresh look at the diagnosis and approach, not an automatic stop after two attempts. New diagnostic
evidence can justify continuing even while tests still fail; more commits or a different agent
alone do not prove progress. Tests, acceptance criteria, and safety constraints are not weakened
to make a repair appear successful.
If the run needs a requirement decision, permission, an external condition, or cannot identify a
justified next step, it pauses and explains what is missing in notes.md. A pause keeps the run
open for continuation; it is not completion. Timeouts, concurrency limits, and cancellation still
apply, but they do not cap total runtime or cost.
When a ticket is handed to you for a decision (an escalation), notes.md keeps the question,
your decision, and the continuation details. After you provide the missing input, the same open
run can continue the original ticket: rerun the same command after an interruption. The run checks
the new conditions against the recorded work and evidence; saying “continue” alone does not prove
that every blocker is gone or that the current code is approved. A hand-off does not complete the
ticket or unlock its dependents. Once that ticket is later merged and validated, it shows as
complete and closes normally in the tracker at the end, while its hand-off history remains.
Past anomalies remain in the history, but do not by themselves mean the run is still broken or
prevent it from finishing. The handling and supporting evidence are kept in notes.md; missing
evidence calls for a check, not an invented recovery. For example, if a tracker update fails,
finishing pauses while the failure is handled. After the retry succeeds and the result is checked,
the run can continue without erasing the failure from its history.
If recorded progress disagrees with the branch or ticket status, ordinary work and finishing the
run pause while the discrepancy is explained. Work needed to resolve that discrepancy can still
continue. For example, a merge whose integration tests failed can be repaired after an interruption,
without moving on to unrelated tickets or claiming the merged ticket is complete before validation
passes. Unexplained discrepancies need investigation or your input.
After final-review repairs, each finding is checked against the repair evidence. A clear, local
correction can be checked without a full repeat review; changes to requirements or behavior,
broader changes, or insufficient evidence require another final review. The notes explain the
choice. Passing tests or an earlier favorable review alone do not prove the changed code is ready.
For the design and its limits, see ADR-0009.
Partial delivery and continuation
You can explicitly accept partial delivery when some finished work is useful but the rest is
blocked. Before you decide, the run checks that the completed work is usable on the current
branch and gives you the branch name, commit SHAs, and validation evidence. The hand-off explains
what is complete, the unfinished items and their effects, the risks, and what is needed next.
A previous merge or a ticket handed to you for a decision is not enough to claim full delivery.
Your acceptance, the blocker, and the next steps are saved in notes.md.
For example, if A and B are complete but C needs permission, you can accept A and B now without
abandoning C. The same open run keeps its local ticket copies, findings, and continuation evidence;
the spec stays open, and the PR / MR stays draft rather than being marked ready for review. There
is no final tracker update or final cleanup at this stage. Keep the run directory even if no agent
is currently executing. Partial delivery provides a branch and evidence, not an automatic release
or a separate PR / MR split from the unfinished work.
After the permission is available, provide it and rerun the same command if the session was
interrupted. The run checks the new condition and the saved notes and evidence, then continues C
without reimplementing or merging A and B again. It does not start a new run or replace the saved
local progress with delayed remote ticket statuses. Only after all agreed work is complete does
it perform the necessary validation and final review, update the tracker, mark the PR / MR ready
where applicable, and finish normally. Closed runs cannot be reopened.
Ending a run
Normal completion means the agreed work is complete and the required validation and final
review support delivery. A final review that says “not ready” prevents normal completion;
handing an unfinished ticket to you is not a substitute for completing it.
Explicit abandonment is different: tell the run that you want to abandon it, not merely pause.
It stops the related agents, saves the code and evidence, and explains the completed and unfinished
work. Existing commits and merges are not undone. For GitHub or GitLab, it posts the abandonment
explanation and releases the feature claim before closing the run; if that fails, the run stays
open while the problem is handled and the missing actions can be retried. Local markdown runs
save the same results without remote updates.
Abandonment needs neither a new final review nor a hand-off for every unfinished ticket. It does
not close unfinished tickets, mark the feature ready, or claim complete delivery. The run
summary and audit report distinguish abandonment from normal completion. Closing is irreversible:
an abandoned or otherwise closed run cannot be reopened. A pause does not close the run.
Configuration
Changing settings
The built-in interactive wizard — instant, no model calls:
/matt-flow-config # pick a role → pick model / thinking level, or edit flow options (reviewer / concurrency / run deadline)
/matt-flow-config show # show the effective flow options and each role's actual model / thinking level
You can also edit pi's settings.json directly. Settings have two layers; the project layer overrides the user layer field by field:
- user:
~/.pi/agent/settings.json - project:
<repo>/.pi/settings.json
When changes take effect:
- Model / thinking level: the next time that role is dispatched — no pi restart needed.
- Flow options: from the next
/pi-matt-implement-flow; a run already in progress is never affected. - Run deadline (
agentTimeoutMs): the next time the flow starts one of its own subagent runs (ticket coder / reviewer / final reviewer / fixer) — including inside a run already in progress. A subagent that is already working keeps the deadline it started with.
Flow options (mattImplementFlow)
| Option | Default | What it does |
|---|---|---|
reviewer |
on | Runs a two-axis review per ticket before merge, with a fix loop. Off: each ticket keeps only the test gate; the whole-branch final review still runs. Parallelism and per-ticket review both cost extra model calls — to spend less, turn this off first or lower maxConcurrent. |
maxConcurrent |
3 |
Coders working at the same time. The number in /pi-matt-implement-flow 5 overrides this. |
agentTimeoutMs |
14400000 (4 h) |
Run deadline for each subagent run the flow starts (ticket coder / reviewer / final reviewer / fixer): how long it may work before the platform stops it. In milliseconds; valid values are positive whole numbers up to 2147483647 (the wizard inputs minutes and refuses anything else). |
{
"mattImplementFlow": {
"reviewer": true,
"maxConcurrent": 3,
"agentTimeoutMs": 14400000
}
}
reviewer and maxConcurrent are frozen when a run starts. The run deadline works differently: after saving it, you do not need to restart or initialize the flow again. Each new subagent uses the latest setting when it is dispatched, including the two review checks started by a reviewer. Subagents already running are not affected. Continuing an existing subagent (resume) follows the platform's rules; this setting does not override its resume timeout.
Old repair-limit settings are no longer effective, including for older runs that have not been closed. Your saved settings and historical run records are not rewritten. Command timeouts, concurrency limits, and cancellation remain available; having no repair quota does not guarantee a finite total runtime or cost.
Model & thinking per role
Three configurable roles: coder, reviewer, final-reviewer (the main agent is your current session — not configured here). Per role:
- Model: the model that role actually calls; unset means it follows the session / pi default subagent model.
- Thinking level:
off/minimal/low/medium/high/xhigh/max. The package ships with high levels; lower them for cost or easier tasks.
A typical split: a strong model for coder; reviewers on a cheaper (or different) review-oriented model; keep final-reviewer thinking high. All of it is set through /matt-flow-config.
How the command line interacts
Nin/pi-matt-implement-flow [N]overrides concurrency only — not the review switch.- Project settings override user settings field by field, not as a whole block.
- Changing settings mid-run never affects a run already in progress — except the run deadline (
agentTimeoutMs), which applies from the next subagent run the flow starts inside that run. A subagent that is already working keeps the deadline it started with.
Run directory
Every run writes a local run directory, .pi/matt-implement/<feature>/:
.pi/matt-implement/<feature>/
ledger.md # human-readable progress: open / closed, per-ticket status, timeline
events.jsonl # machine-run record; an interrupted run resumes from it
notes.md # process notes and decisions worth remembering (for you)
reviews/ # diffs used by each review round
findings/ # review findings, plus post-merge full-suite failures
tracker/ # local copy of your remote spec + tickets (GitHub / GitLab runs only)
runningmeans the run has not ended and can continue; it does not mean an agent is currently executing. Pauses and accepted partial delivery keep the run open.- The path is gitignored and never enters version control. This is run data, not a cache — keep the local ticket copies, findings, notes, and other evidence while the run is open or might be resumed.
ledger.mdandevents.jsonlare maintained by the flow; do not hand-edit them. Notes belong innotes.md.- Once the run has closed and only the branch / PR / MR matters, keep the directory as a record or clean it up — your call. Accepting partial delivery is not that endpoint.
Audit report
Inspect a paused or partially delivered run, or audit a finished one: audit-report/ turns the run directory into a browsable static report site — no LLM calls, and it never changes your run data. It ships with the npm package: node <install-dir>/audit-report/report.js --runtime-dir <repo>/.pi/matt-implement/<feature> (with pi install, <install-dir> is ~/.pi/agent/npm/node_modules/pi-matt-implement-flow).
FAQ & troubleshooting
The run complains about docs/agents/issue-tracker.md / tells me to run /setup-matt-pocock-skills?
The one-time setup is missing — run /setup-matt-pocock-skills once in your repo.
It refuses with 仅支持 local / github / gitlab 三种?
Your tracker setup file is not one of the three supported templates. Regenerate it with
/setup-matt-pocock-skills, or switch to local markdown / GitHub / GitLab.
Why did the run stop to ask me?
There is no ticket repair quota to extend. The run asks when it needs a requirement decision,
permission, an external condition, or help finding a justified next step. Read notes.md for
the blocker and evidence, and provide the missing input. A pause does not close the run.
A tracker update failed. Is the run permanently blocked?
No. Finishing pauses until the failed update is handled. Check notes.md for the failure and
needed permissions or other conditions, then retry once they are addressed. A checked successful
retry lets the open run continue; the earlier failure stays visible as history.
The run was interrupted (or my context was compacted). Do I start over?
No — run the same command again and it continues from the recorded state (see Run directory). Older runs that are still open also use the new repair rules: their old attempt limits no longer apply. Closed runs stay closed.
Can I stop without losing the work?
Ask to pause if you may continue later; the run stays open. If you explicitly abandon it, the
code, evidence, and unfinished-work summary are saved, but the run closes and cannot be reopened.
Neither choice means the unfinished feature is ready (see Ending a run). If you
want to use completed work while keeping the rest for later, explicitly accept
partial delivery after checking its evidence and limitations.
What exactly did the run do, and are there hidden problems?
Generate an audit report: a browsable, per-ticket account of the whole run, with
an "anomalies & risks" section found by rules.
Contributing
Contributions are welcome! Before diving in:
- CONTRIBUTING.md — dev workflow (
npm test, no build step), the issue lifecycle labels, and the PR checklist - When validating repair, pause, partial-delivery, or abandonment behavior: scenario acceptance — reproducible steps and the limits of recorded native, walkthrough, and CLI evidence
- File a bug report or a feature request through the issue forms
- Report security vulnerabilities privately via SECURITY.md — never as public issues
License
附錄:pi-matt-implement-flow README(簡體中文)
來源:https://raw.githubusercontent.com/toomanyopenfiles/pi-matt-implement-flow/main/README.zh-CN.md
pi-matt-implement-flow
pi-matt-implement-flow 是给 pi 用的扩展包:内含一条 skill(/pi-matt-implement-flow)和三个配套 agent——coder、reviewer、final-reviewer。
它补强的是 Matt Pocock 的 /implement 在多张 ticket、且 ticket 之间有依赖时不够用的那一段:单会话串行推进、要人盯着哪些票解锁了、没有逐票质量关。
上游照旧:/grill-with-docs → /to-spec → /to-tickets。本包接手最后一步——按 ticket 依赖图实现,把实现、review、测试在一条命令里做完。
English | 简体中文
核心能力
- 按依赖并行,互不抢上下文——每张 ticket 用独立的临时 worktree 和干净上下文;没有依赖关系的 ticket 并行推进,有依赖的等前置完成后自动开跑。
- 临时工作区自动管理——需要时创建临时 worktree 和临时分支,ticket 结束后自动收回,不用手工维护。
- 写完即审、有问题就改——
每张 ticket 编码完成后自动做双轴 review,审两个维度:是否符合仓库代码规范、是否符合 spec 需求;没过就交回修复,只要还有合理且在批准范围内的下一步就继续,否则暂停并请求你提供信息。
4. 编码与审查分工,模型可分开配——coder 和 reviewer 是独立 agent,可以给不同角色指定不同的模型和 thinking 档位。
5. 合并即跑全量测试——每张 ticket 合入 feature 分支后立刻跑项目全量测试,集成问题当场暴露、当场修,而不是堆到最后。
6. 整分支 final review——全部 ticket 合完后,对整条 feature 分支再审一次,专门看单张 ticket 看不见的问题:跨文件漂移、组件互相矛盾、spec 里有要求却没有 ticket 承接、文档和实现对不上。
7. 中断可续跑——一次 run 的进度记录在仓库本地的运行目录里;会话中断或上下文被压缩后,从已记录的状态继续,不用凭记忆重来。
8. 修复不受次数配额限制——逐票修复不会只因达到某个尝试次数就停止。缺少需求决定、权限、外部条件,或没有证据支持下一步时,run 会暂停并说明需要你提供什么。用 GitHub / GitLab 时,run 开始会开一个草稿 PR / MR(draft PR / MR);用本地 markdown 时,feature 分支本身就是交付物。
9. 三种工单管理方式,全都一等支持——本地 markdown、GitHub Issues、GitLab Issues:run 会自动用 /setup-matt-pocock-skills 在你仓库里配好的那一种。用 GitHub / GitLab 时,跑完自动更新工单——合并的票自动关闭并关联提交,升级给你的票留评论、保持打开;两个会话不会悄悄开跑同一个功能;标签改过名也能正常识别。
环境要求
- pi coding agent,以及 pi-subagents 包(提供并行派发、托管 worktree 和续跑能力)
- Matt Pocock 的 engineering skills——上游三条命令(
/grill-with-docs→/to-spec→/to-tickets)和各 agent 依赖的tdd、codebase-design、code-review、resolving-merge-conflicts都来自这里
本包不替代上游流程,只接手实现阶段。
- 远端 tracker 还需要对应的宿主命令行工具:GitHub 用
gh,GitLab 用glab(安装并登录目标站点)。本地 markdown 不需要任何命令行工具。
每次开跑前请确认三件事:工作区干净、仓库至少有一个 commit、全量测试命令能跑通。
tracker 支持
tracker 不是开关——它来自 /setup-matt-pocock-skills 写进仓库的两份配置文件:docs/agents/issue-tracker.md 与其旁边的 triage-labels.md。run 会据此自动识别你的工单方式(文件里的措辞改过也没关系)。
| tracker | 支持度 | PR / MR | 说明 |
|---|---|---|---|
local markdown(.scratch/<feature>/) |
一等公民 | 无 | 票文件就是唯一真相——不做任何同步 |
| GitHub Issues | 一等公民 | PR | 跑完自动更新工单(合并的票自动关闭并关联提交);用 sub-issues 表达依赖 |
| GitLab Issues | 一等公民 | MR | 跑完自动更新工单(关票前先留一条评论);不用 sub-issues 也能表达依赖;自建 GitLab 也支持 |
| 其他 tracker | 显式不支持 | — | 不猜测、不降级——run 会明确报错停下,见下 |
配置缺失或认不出时,run 会明确报错停下,绝不猜测乱跑:缺 setup 文件 → 在仓库里运行 /setup-matt-pocock-skills;认不出工单方式 → 直接拒绝并报 仅支持 local / github / gitlab 三种(只支持这三种)。
安装
从 npm 安装进 pi:
pi install npm:pi-matt-implement-flow
快速上手
- 一次性配置——装好 pi、pi-subagents 和 Matt Pocock 的 engineering skills,然后在你的仓库里跑一次
/setup-matt-pocock-skills。 - 准备工作:
/grill-with-docs
/to-spec
/to-tickets
- 运行:
/pi-matt-implement-flow [N]
N 是并行 coder 数量,命令行取值覆盖配置里的默认并发(见配置)。多数 ticket 会自动走完;推进需要你拍板或协助时,run 会说明阻塞并暂停,不会等到最后才告诉你。
跑完你会拿到什么
正常完整交付后,你手上有:
- 一条合好的 feature 分支:所有通过验收的 ticket 改动都在上面,全量测试是绿的;
- 用 GitHub / GitLab 时:一个标为可审查的 draft PR / MR,工单也会自动更新(见tracker 支持);
- 一个运行目录
.pi/matt-implement/<feature>/(见运行目录):可读的进度账本ledger.md、备注notes.md,以及结果的证据记录(结束时也会汇总); - 可选:用审计报告把这次 run 生成为可浏览的静态报告。
工作原理
角色
一个 run 里共有四种角色。后三个可配模型和 thinking 档位(见配置):
| 角色 | 做什么 | 不做什么 |
|---|---|---|
| 主 agent(你当前会话里的这条 skill) | 读 spec 与 ticket 依赖图,按依赖派活、合并、跑全量测试、决定下一张票 | 不写任何功能代码 |
| coder | 在一张 ticket 的独立 worktree 里按票实现(先写测试再写实现),提交全部改动并给出可核验的结果 | 不改票状态、不合并、不推远程 |
| reviewer | 只读审查这一张 ticket:对照仓库规范 + 对照 spec / 票面要求 | 不改代码、不跑测试(测试已由流程门禁跑过) |
| final-reviewer | 全部合入后审查整条 feature 分支;除双轴审查外,还看跨 ticket 才能发现的问题 | 同样只读,不改代码 |
流程
- 读取 spec 与 ticket 依赖图,建(或沿用)feature 分支。
- 找出当前没有未完成前置依赖的 ticket,按并发上限派 coder,一人一票、一票一个 worktree。
- coder 完成后:先跑该票的测试门禁 →(若开启逐票 review)reviewer 做双轴 review → 没过就交回同一个 coder 修复,只要还有合理且在批准范围内的下一步就继续。
- 合入 feature 分支,立刻跑全量测试;测试红了,就在 feature 分支上修集成问题。
- 重算下一批可做的 ticket,重复 2–4,直到全部完成;需要你提供信息时暂停。
- final-reviewer 审查整条分支。只有工作全部完成,分支通过必要验证与终审后,run 才正常结束;用 GitHub / GitLab 时,把草稿 PR / MR 标为可审查。
flowchart TD
A["读 spec + ticket 依赖图<br>建 feature 分支"] --> B["派 coder 并行实现<br>一票一个 worktree"]
B --> C["每票 review<br>没过就交回修复"]
C --> D["合入分支<br>跑全量测试"]
D --> E{"还有 ticket 吗"}
E -- 有 --> B
E -- 没有 --> F["整分支 final review"]
F --> G{"已就绪?"}
G -- 否 --> H["修复或暂停,请你提供信息<br>核对证据,必要时重审"]
H --> G
G -- 是 --> I["完整交付<br>PR / MR 标为可审查"]
逐票修复没有次数配额。澄清或撤回一条评审问题,不等于批准合并:必要的完整评审与验证仍须覆盖当前代码。两次评审之间可以多次修复,也可以没有新代码改动就重新做完整评审。
修复与暂停
逐票、集成与终审修复采用同一原则:有合理、有证据支持且在批准范围内的下一步就继续。
连续失败会促使重新审视诊断和办法,不会两次失败就自动停止。即使测试仍未通过,新的诊断
证据也可以支持继续;仅有更多提交或换一个 agent 不能证明进展。不会通过削弱测试、验收
标准或安全约束让修复显得成功。
缺少需求决定、权限、外部条件,或找不到有依据的下一步时,run 会暂停并在 notes.md 中
说明缺少什么。暂停会保留 run,供之后续跑,不代表完成。命令超时、并发上限与取消能力
仍生效,但它们不限制总运行时间或费用。
一张票交给你决策(升级,escalation)时,notes.md 会保留待决策问题、你的决定和续跑说明。
你提供缺少的信息后,同一个未封账 run 可以继续原票;中断后重新运行同一条命令即可。run 会
对照已记录的工作和证据核验新条件;仅说“继续”不能证明所有阻塞都已消除,也不能证明当前
代码已获批准。交接不代表票已完成,也不解除下游依赖。该票后来合并并通过验证后,会显示
完成,在最终收尾时按正常流程关闭工单,同时保留交接历史。
过去的异常会保留在历史中,但仅凭异常记录,不能认定 run 当前仍有故障,也不会因此阻止
收尾。处理结果与支持证据保存在 notes.md;证据不足时需要核对,不能编造已恢复的结论。
例如,工单更新失败时,收尾会暂停,先处理失败;重试成功并核对结果后,run 可以继续,
但历史中的失败记录不会被抹去。
记录的进度与分支或票状态不一致时,普通推进和收尾会暂停,先说明差异;直接处理差异的
必要工作仍可继续。例如,合并后集成测试失败,中断后仍可修复这次合并,不推进无关票,
也不在验证通过前声称已合并的票完成。无法解释的差异需要先核查或请你提供信息。
终审修复后,会逐条对照修复证据核对问题。明确、局部的修正可以核对后继续,不必完整重审;
涉及需求或行为、影响较广,或证据不足时则需要重新终审。笔记会说明选择依据。测试通过或
先前的有利评审,不能单独证明改动后的代码已就绪。
设计与限制见 ADR-0009。
阶段性交付与续跑
部分已完成工作有用、剩余工作仍被阻塞时,你可以明确接受阶段性交付。决定前,run 会核验
当前分支上已完成部分是否可用,提供分支名、提交 SHA 和验证证据。交接说明会列出已完成
内容、未完成项及其影响、风险,以及下一步需要什么。曾经合并过,或把一张票交给你决策,
都不足以宣称完整交付。你的接受决定、阻塞条件与下一步会保存在 notes.md。
例如,A、B 已完成但 C 缺权限,你可以先接受 A、B,而不放弃 C。同一个未封账 run 会保留
本地工单副本、评审问题和续跑证据;spec 保持开放,PR / MR 保持草稿,不标为可审查。
此时不会做最终工单更新或最终清理。即使当前没有 agent 执行,也请保留运行目录。
阶段性交付提供的是分支和证据,不会自动发布版本,也不会把已完成部分拆成独立 PR / MR。
权限补齐后,请提供新条件;会话中断时重新运行同一条命令即可。run 会核验新条件,读取
已保存的笔记和证据,再继续 C,不重复实现或合并 A、B。它不会另起一次 run,也不会用
延迟的远端工单状态覆盖已保存的本地进度。只有全部约定工作完成后,才做必要验证与终审、
更新工单、在适用时把 PR / MR 标为可审查,并正常结束。已封账的 run 不能重开。
结束 run
正常完成表示约定工作已全部完成,必要验证与终审支持交付。终审结论为“未就绪”时,
不能正常完成;把未完成票交给你处理,不能代替完成它。
明确放弃则不同:请明确告诉 run 你要放弃,而不只是暂停。它会停止相关 agent,保存
代码与证据,并说明已完成与未完成的工作。已有提交和合并不会被撤销。用 GitHub / GitLab
时,run 会先留下放弃说明、释放该功能的认领,再封账;这一步失败时,run 保持开放,先
处理问题,再重试缺少的操作。本地 markdown run 同样保存结果,但不做远端更新。
放弃不需要补做终审,也不需要把每张未完成票逐一交接。放弃不会关闭未完成票、把
功能标为就绪,或声称完整交付。run 汇总与审计报告会区分放弃和正常完成。封账不可逆:
已放弃或以其他方式封账的 run 不能重开。暂停不会封账。
配置
怎么改
推荐用包内置的交互向导 /matt-flow-config(即时生效,不消耗模型调用):
/matt-flow-config # 选角色 → 选模型 / thinking 档位,或编辑流程选项(reviewer / 并发 / 运行时限)
/matt-flow-config show # 查看当前生效的流程选项,以及三个角色实际用的模型与 thinking 档位
也可以直接改 pi 的 settings.json。配置有两层,项目级按字段覆盖用户级:
- 用户级:
~/.pi/agent/settings.json - 项目级:
<仓库>/.pi/settings.json
改动什么时候生效:
- 改模型 / thinking 档位:下一次派出该角色时生效,不用重启 pi。
- 改流程选项:从下一次
/pi-matt-implement-flow开始生效;正在跑的 run 不受影响。 - 改运行时限(
agentTimeoutMs):流程下一次启动自己的子代理(逐票 coder / 评审 / 终审 / 修复者)时生效,正在跑的 run 中途改也一样。已经在跑的子代理继续用它启动时的死线。
流程选项(mattImplementFlow)
| 项 | 默认 | 作用 |
|---|---|---|
reviewer |
开启 | 每张 ticket 合入前做双轴 review 并进入修复。关闭后单票只保留测试门禁,整分支 final review 仍会跑。并行数量和逐票 review 都会明显增加模型调用——想省,先关这项或调低 maxConcurrent。 |
maxConcurrent |
3 |
同时工作的 coder 数量。命令 /pi-matt-implement-flow 5 里的数字优先于这项。 |
agentTimeoutMs |
14400000(4 小时) |
流程每次启动子代理(逐票 coder / 评审 / 终审 / 修复者)的单次运行时限,到点由平台终止。单位毫秒,合法值是不超过 2147483647 的正整数(向导按分钟输入,其他值拒绝写入)。 |
{
"mattImplementFlow": {
"reviewer": true,
"maxConcurrent": 3,
"agentTimeoutMs": 14400000
}
}
reviewer 和 maxConcurrent 在 run 启动时冻结。运行时限不同:保存后,无需重新启动或初始化流程。之后每次新派发子代理,都使用当时的最新配置,包括评审者启动的两个评审子代理。已经运行的子代理不受影响。接续已有子代理(resume)遵循平台规则;这项设置不覆盖 resume 的时限。
旧修复次数设置不再生效,尚未封账的旧 run 也一样;已保存的设置和历史运行记录不会被改写。命令超时、并发上限与取消能力仍保留;没有修复配额不保证总运行时间或费用有限。
角色的模型与 thinking 档位
可配的角色是三个:coder、reviewer、final-reviewer(主 agent 是你当前会话,不在其列)。每个角色可配:
- 模型:该角色实际调用的模型;不设则跟随当前会话 / pi 的默认子 agent 模型。
- thinking 档位:
off/minimal/low/medium/high/xhigh/max。包内默认是较高档位,可按成本或任务难度下调。
典型用法:coder 给较强的模型;reviewer 换成更便宜(或另一家)的审查向模型;final-reviewer 保持高 thinking。都在 /matt-flow-config 里设置。
和命令行的关系
/pi-matt-implement-flow [N]的N只覆盖并发,不影响 review 开关。- 项目配置覆盖用户配置,是按字段覆盖,不是整段替换。
- 开跑后中途改
settings.json不影响正在跑的那次 run——运行时限(agentTimeoutMs)除外:它从该 run 下一次启动子代理时生效;已经在跑的子代理继续用它启动时的死线。
运行目录
每次 run 都在仓库本地写一个运行目录 .pi/matt-implement/<功能名>/:
.pi/matt-implement/<功能名>/
ledger.md # 这次 run 的可读进度:未封账 / 已封账、各票状态、时间线
events.jsonl # 机器使用的运行记录,中断后靠它续跑
notes.md # 过程说明、需要记住的决定(给人看)
reviews/ # 各轮 review 用的 diff
findings/ # review 意见,以及合并后全量测试失败时的记录
tracker/ # 远端工单的本地副本:从 GitHub / GitLab 拉下来的 spec 与工单(仅远端 run)
running表示 run 尚未终结,可以续跑,不表示当前有 agent 执行。暂停或接受阶段性交付后,run 仍保持开放。- 路径已写入
.gitignore,不会进版本库。这是运行数据,不是缓存——run 未封账或还打算续跑时,请保留本地工单副本、评审问题、笔记和其他证据。 ledger.md和events.jsonl由流程维护,不要手工修改;想留备注写到notes.md。- run 封账后,如果只关心 feature 分支 / PR / MR,目录可以留作记录,也可以自行清理。接受阶段性交付还没有到这个终点。
审计报告
暂停或阶段性交付时可以查看,跑完也可以做事后审计:audit-report/ 把运行目录生成为可浏览的静态报告网站——不消耗大模型调用,也不会改动你的运行数据。工具随 npm 包发布:node <安装目录>/audit-report/report.js --runtime-dir <仓库>/.pi/matt-implement/<feature>(pi install 安装时 <安装目录> 为 ~/.pi/agent/npm/node_modules/pi-matt-implement-flow)。
常见问题与排错
run 提示缺少 docs/agents/issue-tracker.md / 让我先跑 /setup-matt-pocock-skills?
一次性配置还没做:在你的仓库里跑一次 /setup-matt-pocock-skills。
报错 仅支持 local / github / gitlab 三种?
工单配置文件不是三种受支持的模板之一。重新运行 /setup-matt-pocock-skills 生成,或改用本地 markdown / GitHub / GitLab。
为什么 run 停下来问我?
逐票修复没有需要追加的次数配额。run 会在缺少需求决定、权限、外部条件,或需要你协助找到有依据的下一步时请求介入。请查看 notes.md 中的阻塞与证据,提供缺少的信息。暂停不会封账。
工单更新失败,run 会永久卡住吗?
不会。失败的更新处理好之前,收尾会暂停。请查看 notes.md 中的失败说明,以及所需权限
或其他条件,补齐后重试。重试成功并核对结果后,未封账的 run 可以继续;先前的失败仍保留
为历史记录。
跑到一半中断(或上下文被压缩)了,要从头再来吗?
不用——重新运行同一条命令,会从记录的状态继续(见运行目录)。尚未封账的旧 run 也采用新修复规则,旧次数上限不再生效;已封账的 run 保持关闭。
能停止又不丢掉工作吗?
以后可能继续时,请要求暂停,run 会保持开放。明确放弃后,代码、证据与未完成项说明仍会
保存,但 run 会封账且不能重开。两种选择都不代表未完成的功能已就绪(见结束 run)。
如果想先使用已完成部分、保留剩余工作待续跑,请核对证据与限制后,明确接受
阶段性交付。
这次 run 到底做了什么?有没有隐患?
用审计报告生成静态报告:逐票可查完整过程,还有专门的"异常与风险"区。
贡献
欢迎贡献!动手前先看:
- CONTRIBUTING.md——开发流程(
npm test,无构建步骤)、issue 生命周期标签、PR 检查清单 - 验证修复、暂停、阶段性交付或放弃行为时,请看场景验收——可复查步骤,以及已有原生执行、受控推演与 CLI 证据的边界
- 用 issue 表单提交 Bug 报告 或 功能请求
- 安全漏洞请按 SECURITY.md 私密上报——永远不要开公开 issue