Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"name": "dx-workflow",
"source": "./plugins/dx-workflow",
"description": "Acceptance first, one design and one backend contract, enforced verification per lane (frontend, backend) with independent review and evidence."
"description": "Request to merge with real gates: spec and tasks for large changes, acceptance first, one design and one backend contract, enforced verification per lane (frontend, backend) with independent review and evidence."
}
]
}
78 changes: 64 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

仓库:`davidxiaodev/workflow`。

一个 Claude Code 插件:让 AI 改前端和后端时,先说清楚"做成什么样算对",按项目的约定去做,
在独立验证之前不能说"做完了",并且把每次犯过的错变成下次能自动拦住的检查。
一个 Claude Code 插件:把一个需求从"说清楚要什么"一路带到"可以合并",每一步之间都有能真正执行的关卡。
AI 先说清楚"做成什么样算对",按项目的约定去做,在独立验证之前不能说"做完了",并且把每次犯过的错变成下次能自动拦住的检查。

人不再逐行读 diff,而是看证据包:验收标准逐条由独立评审标记,机器检查只认真实退出码,合并分档由脚本计算。

Expand All @@ -15,16 +15,36 @@
| 步骤 | 做什么 | frontend lane | backend lane |
| --- | --- | --- | --- |
| 0 准备 | 每个项目一次:写约定、接检查、加 lint 护栏、标出 `sensitive` 路径 | `docs/design.md` + token 文件 | `docs/backend.md` + 契约文件(OpenAPI 等)+ 迁移目录 |
| 1 澄清 | 只在大改动时:先追问需求、边界、失败时怎么办 | 同左 | 同左 |
| 2 验收标准 | 写 `.verify/acceptance.md`:可观察的结果,每条写明用什么证明;逐项过一遍异常情况清单;可选写明怎么回滚、能否撤回 | 无效输入、键盘、慢请求、双击提交、390 宽…… | 边界值、越权、重复请求、并发写、下游失败…… |
| 3 实现 | 按约定做 | 需要时出 3 个结构不同的原型 | 先改契约,再按验收标准一条条先写测试后写实现 |
| 4 机器检查 | `run-verify.mjs` 按 lane 跑,只认真实退出码,遇到第一个失败就停 | 样式、类型、截图 + 可访问性、用户路径(Web 用 Playwright;移动端用模拟器截图 `rn-look.mjs` 和 Maestro) | 类型、单元、真实数据库的集成测试、**负向检查**、契约、迁移、用户路径 |
| 5 独立评审 | `review-brief.mjs` 写 brief,交给没参与实现的子代理;逐条标记验收标准和触发的清单项;最多 3 轮 | `design-review.md` 看截图,再用前端版 `code-review.md` 看代码(状态、请求竞态、错误态、XSS、可访问性) | `code-review.md` 看 diff,按专项逐一检查,并跑一遍证明关键事实 |
| 6 证据和分档 | `make-evidence.mjs` 生成证据包:验收标准和机器检查分开写,算合并分档,写明能否撤回、影响范围、怎么回滚 | 前后对比截图、录屏 | 检查日志、负向检查结果、契约与迁移改动 |
| 7 沉淀 | 评审的 Blocker、回滚、你的纠正,按 `shared/ratchet.md` 变成检查或清单项 | 同左 | 同左 |
| 1 定义(L) | 写规格 `docs/specs/<名字>.md`:问题、目标 `S1…`、不做什么、决定、未决问题,以及整个功能的验收标准;你同意(`Status: agreed`)后才往下走 | 同左 | 同左 |
| 2 验收标准 | 每条可观察、写明用什么证明,L 的写在规格里并标注对应哪个目标;逐项过一遍异常情况清单;可选写明怎么回滚、能否撤回 | 无效输入、键盘、慢请求、双击提交、390 宽;移动端:大字号、断网、切后台…… | 边界值、越权、重复请求、并发写、下游失败…… |
| 3 拆任务(L) | `docs/specs/<名字>.tasks.md`:每个任务一个 PR(S 或 M),写明 lane、负责哪几条验收标准、依赖、预估风险档;开工时由脚本生成这个任务的 `.verify/acceptance.md` | 同左 | 同左 |
| 4 实现 | 按约定做,先写测试;没有依赖关系的任务可以各开一个 worktree 并行做 | 需要时出 3 个结构不同的原型 | 先改契约,再按验收标准一条条先写测试后写实现 |
| 4′ 调试 | 同一个检查连续两次失败,`run-verify` 就要求停下来先找根因(`shared/debug.md`),根因写进 `.verify/debug.md`,再修 | 同左 | 同左 |
| 5 机器检查 | `run-verify.mjs` 按 lane 跑,只认真实退出码,遇到第一个失败就停 | 样式、类型、截图 + 可访问性、用户路径(Web 用 Playwright;移动端用模拟器截图 `rn-look.mjs` 和 Maestro) | 类型、单元、真实数据库的集成测试、**负向检查**、契约、迁移、用户路径 |
| 6 独立评审 | `review-brief.mjs` 写 brief,交给没参与实现的子代理;逐条标记验收标准和触发的清单项;最多 3 轮 | `design-review.md` 看截图,再用前端版 `code-review.md` 看代码(状态、请求竞态、错误态、XSS、可访问性) | `code-review.md` 看 diff,按专项逐一检查,并跑一遍证明关键事实 |
| 7 证据和分档 | `make-evidence.mjs` 生成证据包:验收标准和机器检查分开写,算合并分档,写明能否撤回、影响范围、怎么回滚 | 前后对比截图、录屏 | 检查日志、负向检查结果、契约与迁移改动 |
| 8 沉淀 | 评审的 Blocker、回滚、你的纠正,按 `shared/ratchet.md` 变成检查或清单项 | 同左 | 同左 |

入口是 `flow` 技能(`dx-workflow:flow`),它先给改动定大小,再决定走哪些步骤:

| 大小 | 什么时候 | 步骤 |
| --- | --- | --- |
| S | 改文案、颜色、一行修复、配置值;不碰契约、迁移、鉴权、原生 | 验收标准 1–3 条 → 实现 → 验证,评审一般是 quick |
| M | 一两条 lane 内、一个 PR 放得下(约 400 行)的功能或修复,不改契约 | 验收标准 + 异常情况 → 实现 → 验证 |
| L | 新流程;接口、数据或设计契约变更;迁移;鉴权或支付;原生改动;超过一个 PR;或者还说不清怎样算做完 | 定义 → 规格里的验收标准 → 拆任务 → 每个任务按 M 走 |

步骤之间的关卡是能执行的命令:

```bash
node <plugin>/scripts/flow-check.mjs spec docs/specs/x.md # 规格:你已同意、没有未决问题、每个目标都有验收标准
node <plugin>/scripts/flow-check.mjs tasks docs/specs/x.tasks.md # 任务:每条验收标准都有任务负责、没有循环依赖、没有超过 M 的任务
node <plugin>/scripts/flow-check.mjs next docs/specs/x.tasks.md --done T1 # 现在可以开工的任务
node <plugin>/scripts/flow-check.mjs acceptance docs/specs/x.md T2 --write # 生成这个任务的 .verify/acceptance.md
```

改动大小决定流程轻重:改文案、改颜色这类小改动不用追问,验收标准写 1 到 3 条,评审走 quick;
新流程、接口或数据契约变更、迁移、鉴权才走完整流程,评审走 deep。
生成的验收文件会带上 `Spec:` 和 `Task:`,证据包和 PR 描述里也会写明,所以评审的每一条标记都能追溯到你同意过的目标。

上线(部署、灰度、监控、回滚)这一步还没做:目前按合并分档决定谁批准合并,之后的流程按你们团队现有的做法。

**移动端(React Native / Expo)**:lane 写 `"kind": "frontend", "platform": "react-native"`,默认覆盖全部 JS/TS 代码和
`app.json`、`ios/`、`android/` 等原生配置。和 Web 的区别:
Expand All @@ -43,6 +63,29 @@
**负向检查**:把这条 lane 里的源码改动退回到基线、保留新测试,再跑一遍测试,测试必须失败。
测试在没有实现时也能通过,说明它没测到这次改动。

## 和其他 skill 包一起用

装了 Matt Pocock 的 skills、superpowers 或 agent-skills 的话,`flow` 会把某些步骤里的具体工作交给它们,
关卡和作为记录的文件仍以 dx-workflow 为准(详见 `shared/skill-packs.md`):

| 步骤 | 交给(装了才用) |
| --- | --- |
| 定义、访谈 | `mattpocock-skills:grilling` / `grill-with-docs`,`agent-skills:interview-me` / `spec-driven-development`,`superpowers:brainstorming` |
| 拆任务 | `agent-skills:planning-and-task-breakdown`,`superpowers:writing-plans`,`mattpocock-skills:to-tickets` |
| 先写测试 | `mattpocock-skills:tdd`,`superpowers:test-driven-development`,`agent-skills:test-driven-development` |
| 并行 | `superpowers:using-git-worktrees` / `dispatching-parallel-agents` |
| 调试 | `mattpocock-skills:diagnosing-bugs`,`superpowers:systematic-debugging`,`agent-skills:debugging-and-error-recovery` |
| 浏览器排查 | `agent-skills:browser-testing-with-devtools` |
| 架构和清理 | `mattpocock-skills:improve-codebase-architecture` / `codebase-design`,`agent-skills:code-simplification` |

冲突时以 dx-workflow 为准:
- 规格和任务以 `docs/specs/` 下的文件为准,别的 skill 写到 `docs/superpowers/`、`SPEC.md`、`tasks/todo.md` 或 issue 里的只算草稿;
- "做完"以 Stop 钩子放行为准,别的 skill 的"测试过了就算完"只是其中一部分;
- 独立评审以 `review-brief.mjs` 派出的为准,它们的评审只能作为额外的检查;
- 合并按分档来,证据包出来之前不在本地 merge,也不开可以直接合并的 PR。

安装命令和锁定的版本见 `vendor.lock.json` 的 `routed`。

## 合并分档

脚本算,不能手动改。
Expand Down Expand Up @@ -155,7 +198,8 @@ baoyu-design 是可选的看图调色工具,只在项目仓库外用(它含

两者都会写约定文件、接好 `.verify/config.json`、加 lint 护栏、建一个空的 `docs/checklist.md`、和你一起填 `sensitive` 路径;
没有可脚本化的用户路径时生成 `ctl` 控制命令;最后用 `run-verify.mjs --config working` 在未改动的代码上跑一遍全部检查
(配置合进默认分支之后,就不再需要 `--config working`)。之后正常让 Claude 改代码即可。
(配置合进默认分支之后,就不再需要 `--config working`)。之后正常提需求即可:`flow` 技能会先给改动定大小,
大的改动先和你一起写规格、拆任务,再一个任务一个 PR 地做。

接着可以做的:装提交盖章钩子、接 CI 模板。

Expand All @@ -172,10 +216,13 @@ baoyu-design 是可选的看图调色工具,只在项目仓库外用(它含

| 路径 | 作用 |
| --- | --- |
| `plugins/dx-workflow/skills/flow/` | 入口:给改动定大小,按步骤和关卡走完整个流程,按步骤分派给其他 skill 包 |
| `plugins/dx-workflow/skills/frontend/` | 前端:`SKILL.md`(入口)、`setup.md`、`build.md`、`verify.md`、`mobile.md`(React Native / Expo)、`design-review.md`(截图评审)、`code-review.md`(前端代码评审)、`templates/`(design.md、Web 截图测试、页面清单、`rn-look.json`、Maestro journey) |
| `plugins/dx-workflow/skills/backend/` | 后端:`SKILL.md`(入口)、`setup.md`、`build.md`、`verify.md`、`code-review.md`(代码评审)、`templates/backend.md` |
| `plugins/dx-workflow/shared/acceptance.md` | 怎么写验收标准、异常情况清单、评审怎么标记 |
| `plugins/dx-workflow/shared/ctl.md` | 生成项目的控制命令(读写分开),以及 `verify-<app>` skill 和用户路径 |
| `plugins/dx-workflow/shared/spec.md`、`tasks.md`、`debug.md` | 定义、拆任务、调试三步的做法和文件格式 |
| `plugins/dx-workflow/shared/skill-packs.md` | 和 Matt Pocock、superpowers、agent-skills 一起用:谁做哪一步,冲突时以谁为准 |
| `plugins/dx-workflow/shared/ratchet.md` | 把犯过的错变成检查:分类、准入、单独提交、清理;清单格式 |
| `plugins/dx-workflow/shared/verify.config.json` | `.verify/config.json` 模板(frontend 和 backend 两条 lane) |
| `plugins/dx-workflow/shared/verify-ci.yml` | 项目用的 CI 模板 |
Expand All @@ -186,6 +233,8 @@ baoyu-design 是可选的看图调色工具,只在项目仓库外用(它含
| --- | --- |
| `plugins/dx-workflow/hooks/hooks.json` | 注册 UserPromptSubmit 和 Stop 两个钩子 |
| `plugins/dx-workflow/scripts/run-verify.mjs` | 按 lane 跑检查(含负向检查),记录退出码和内容哈希;`--config working`、`--keep-going`、`--restore` |
| `plugins/dx-workflow/scripts/flow-check.mjs` | 步骤之间的关卡:规格、任务、下一步可做的任务、生成任务的验收文件 |
| `plugins/dx-workflow/scripts/lib/flow.mjs` | 解析规格和任务文件 |
| `plugins/dx-workflow/scripts/review-brief.mjs` | 写评审 brief:内容哈希、深度、触发的清单项、轮次 |
| `plugins/dx-workflow/scripts/make-evidence.mjs` | 生成证据包和合并分档;`--pr` 输出 PR 描述,`--checks-only --exit-code` 给 CI 用 |
| `plugins/dx-workflow/scripts/stop-gate.mjs` | Stop 钩子 |
Expand Down Expand Up @@ -215,11 +264,12 @@ npm test #
node evals/run.mjs all --reviewer "claude -p --permission-mode acceptEdits" # 改 code-review.md、brief 或换模型之前先跑,和 evals/results/ 里上一次比
```

发版:改 `plugins/dx-workflow/.claude-plugin/plugin.json` 的版本,合并后打同名 tag(如 `v0.5.0`),CI 模板按 tag 锁定插件版本。
发版:改 `plugins/dx-workflow/.claude-plugin/plugin.json` 的版本,合并后打同名 tag(如 `v0.6.0`),CI 模板按 tag 锁定插件版本。

升级第三方工具:一次只升一个,读它的改动,在两个项目上各跑一次 `run-verify.mjs`,结果没变差再改 `vendor.lock.json` 里的 commit。

## 思路来源

Anthropic Claude Code 团队关于代码评审和验证的文章,Lauren Tan(poteto)的 pstack 和"倒金字塔",Matt Pocock 的 skills
(grilling、tdd、code-review、retro、pr),Garry Tan 的 gstack,Damola Akinleye 的 interface-design。改编的文字和许可见 `NOTICE.md`。
(grilling、tdd、code-review、retro、pr),Jesse Vincent 的 superpowers,Addy Osmani 的 agent-skills,Garry Tan 的 gstack,
Damola Akinleye 的 interface-design。改编的文字和许可见 `NOTICE.md`;分派给其他 skill 包的步骤见 `shared/skill-packs.md`。
35 changes: 35 additions & 0 deletions docs/adr/0006-a-full-flow-with-gates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 6. A full flow with gates, delegating the steps

Date: 2026-11-18 · Status: accepted

## Context

The plugin proved a change right (acceptance, checks, independent review, evidence, tier) but said
nothing about the steps before and around that: when to write a spec, how to split work into pull
requests, what to do when a check keeps failing. Agents improvised between the pieces, and a
misunderstood requirement surfaced only at review. Matt Pocock's skills, superpowers and agent-skills
each cover the whole path and do several steps very well; each also has its own files, its own
definition of done, its own reviewers and, for some, its own merge.

## Decision

- A `flow` skill is the entry: it sizes a change (S, M, L) and runs it through define, acceptance,
tasks, build, debug, verify and learn, with a gate between steps.
- The gates are commands. `flow-check.mjs spec` (agreed, no open question, every goal has a criterion
with a proof), `tasks` (every criterion in a task, lanes exist, tasks S or M with a risk tier, no
cycle), `next`, and `acceptance --write`, which generates a task's `.verify/acceptance.md` with
`Spec:` and `Task:` lines that the evidence pack and pull request body carry. `run-verify.mjs`
counts consecutive failures per check and sends the second to `shared/debug.md`; the root cause in
`.verify/debug.md` appears in the evidence pack.
- Files of record: `docs/specs/<slug>.md` and `docs/specs/<slug>.tasks.md`.
- Other skill packs do the work inside steps when installed (`shared/skill-packs.md`); this plugin
keeps the files of record, the definition of done, the independent review and the merge tier. Their
versions are pinned under `routed` in `vendor.lock.json`; they are never vendored.
- Shipping (deploy, rollout, monitoring, rollback) is out of scope until the team's deployment
setup is known; merging follows the tier.

## Consequences

Large changes take a spec and a task list before code, and the user agrees the spec. The routing
table depends on other packs' skill names; when one is renamed the step falls back to this plugin's
own text. The consecutive-failure trigger is advisory: it prints and records, it does not block.
4 changes: 2 additions & 2 deletions plugins/dx-workflow/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dx-workflow",
"version": "0.5.0",
"description": "Front-end and back-end changes you can trust: acceptance criteria first, a design contract and a backend contract, checks per lane (frontend on the web or React Native / Expo, backend) including a negative check, independent review, an evidence pack with a computed merge tier, and a Stop gate. Checks are read from the base commit, runs and reviews are bound to a content hash, and changes to the checks themselves are tier 3.",
"version": "0.6.0",
"description": "A request to a mergeable change with a gate between every step: size the change, spec and tasks for large ones (flow-check), acceptance criteria first, a design contract and a backend contract, checks per lane (frontend on the web or React Native / Expo, backend) including a negative check, independent review, an evidence pack with a computed merge tier, and a Stop gate. Checks are read from the base commit, runs and reviews are bound to a content hash, and changes to the checks themselves are tier 3. Works with Matt Pocock's skills, superpowers and agent-skills for the work inside a step.",
"author": {
"name": "davidxiaodev"
},
Expand Down
Loading
Loading