@tianhai/pi-workflow-kit 0.18.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +79 -62
  2. package/agents/pwk-hazard-reviewer.md +24 -0
  3. package/agents/pwk-smell-reviewer.md +17 -0
  4. package/agents/pwk-spec-reviewer.md +14 -0
  5. package/agents/pwk-tracing-reviewer.md +14 -0
  6. package/docs/developer-usage-guide.md +39 -44
  7. package/docs/lessons.md +2 -7
  8. package/docs/oversight-model.md +20 -14
  9. package/docs/workflow-phases.md +64 -30
  10. package/extensions/workflow-guard.ts +194 -92
  11. package/package.json +20 -4
  12. package/skills/pwk-brainstorming/SKILL.md +30 -27
  13. package/skills/pwk-code-review/SKILL.md +46 -0
  14. package/skills/pwk-diagnose/SKILL.md +5 -2
  15. package/skills/pwk-executing-tasks/SKILL.md +92 -328
  16. package/skills/pwk-finalizing/SKILL.md +23 -106
  17. package/skills/pwk-status/SKILL.md +28 -0
  18. package/skills/pwk-writing-plans/SKILL.md +49 -328
  19. package/docs/plans/2026-06-03-karpathy-guidelines-ab-comparison.md +0 -166
  20. package/docs/plans/completed/2026-04-11-checkpoint-review-gates-design.md +0 -50
  21. package/docs/plans/completed/2026-04-11-checkpoint-review-gates-implementation.md +0 -98
  22. package/docs/plans/completed/2026-04-11-finalizing-merge-options-design.md +0 -33
  23. package/docs/plans/completed/2026-04-11-finalizing-merge-options-implementation.md +0 -75
  24. package/docs/plans/completed/2026-04-11-workspace-setup-design.md +0 -28
  25. package/docs/plans/completed/2026-04-11-workspace-setup-implementation.md +0 -57
  26. package/docs/plans/completed/2026-04-15-bash-guard-design.md +0 -39
  27. package/docs/plans/completed/2026-04-15-bash-guard-implementation.md +0 -229
  28. package/docs/plans/completed/2026-04-21-workflow-guard-safe-commands-design.md +0 -172
  29. package/docs/plans/completed/2026-04-21-workflow-guard-safe-commands-implementation.md +0 -168
  30. package/docs/plans/completed/2026-04-22-go-readonly-safe-commands-implementation.md +0 -54
  31. package/docs/plans/completed/2026-04-28-executing-tasks-redesign-design.md +0 -171
  32. package/docs/plans/completed/2026-04-28-executing-tasks-redesign-implementation.md +0 -208
  33. package/docs/plans/completed/2026-04-28-executing-tasks-redesign-progress.md +0 -14
  34. package/docs/plans/completed/2026-05-01-incorporate-mattpocock-skills-design.md +0 -154
  35. package/docs/plans/completed/2026-05-01-incorporate-mattpocock-skills-implementation.md +0 -315
  36. package/docs/plans/completed/2026-05-01-incorporate-mattpocock-skills-progress.md +0 -15
  37. package/docs/plans/completed/2026-05-08-checkpoint-gates-design.md +0 -235
  38. package/docs/plans/completed/2026-05-08-checkpoint-gates-implementation.md +0 -83
  39. package/docs/plans/completed/2026-05-08-checkpoint-gates-progress.md +0 -11
  40. package/docs/plans/completed/2026-05-08-lessons-learned-design.md +0 -76
  41. package/docs/plans/completed/2026-05-08-lessons-learned-implementation.md +0 -219
  42. package/docs/plans/completed/2026-05-08-lessons-learned-progress.md +0 -15
  43. package/docs/plans/completed/2026-05-08-migrate-earendil-works-design.md +0 -39
  44. package/docs/plans/completed/2026-05-08-migrate-earendil-works-implementation.md +0 -45
  45. package/docs/plans/completed/2026-05-08-migrate-earendil-works-progress.md +0 -10
  46. package/docs/plans/completed/2026-05-08-worktree-handoff-design.md +0 -118
  47. package/docs/plans/completed/2026-05-08-worktree-handoff-implementation.md +0 -140
  48. package/docs/plans/completed/2026-05-08-worktree-handoff-progress.md +0 -10
  49. package/docs/plans/completed/2026-05-20-generic-lessons-design.md +0 -70
  50. package/docs/plans/completed/2026-05-20-generic-lessons-implementation.md +0 -114
  51. package/docs/plans/completed/2026-05-20-generic-lessons-progress.md +0 -11
  52. package/docs/plans/completed/2026-05-22-agentic-agile-enhancements-design.md +0 -77
  53. package/docs/plans/completed/2026-05-22-agentic-agile-enhancements-implementation.md +0 -473
  54. package/docs/plans/completed/2026-05-25-design-review-split-implementation.md +0 -622
  55. package/docs/plans/completed/2026-05-25-design-review-split-progress.md +0 -16
  56. package/docs/plans/completed/2026-05-25-pr5-improvements-implementation.md +0 -273
  57. package/docs/plans/completed/2026-05-25-pr5-improvements-progress.md +0 -17
  58. package/docs/plans/completed/2026-06-03-add-verify-skill-design.md +0 -51
  59. package/docs/plans/completed/2026-06-03-add-verify-skill-implementation.md +0 -111
  60. package/docs/plans/completed/2026-06-03-add-verify-skill-progress.md +0 -11
  61. package/docs/plans/completed/2026-06-03-verify-skill-design.md +0 -176
  62. package/docs/plans/completed/2026-06-09-code-review-fixes-implementation.md +0 -74
  63. package/docs/plans/completed/2026-06-09-code-review-fixes-progress.md +0 -14
  64. package/docs/plans/completed/2026-06-09-incremental-workflow-and-rename-design.md +0 -186
  65. package/docs/plans/completed/2026-06-09-incremental-workflow-and-rename-implementation.md +0 -675
  66. package/docs/plans/completed/2026-06-09-incremental-workflow-and-rename-progress.md +0 -18
  67. package/docs/plans/completed/2026-06-09-incremental-workflow-and-rename-verification-report.md +0 -81
  68. package/docs/plans/completed/2026-06-09-verification-fixes-implementation.md +0 -69
  69. package/docs/plans/completed/2026-06-09-verification-fixes-progress.md +0 -14
  70. package/skills/pwk-design-review/SKILL.md +0 -115
  71. package/skills/pwk-verify/SKILL.md +0 -170
@@ -1,380 +1,144 @@
1
1
  ---
2
2
  name: pwk-executing-tasks
3
- description: "Use this to implement an approved plan task-by-task. Run after pwk-writing-plans, before finalizing."
3
+ description: "Implement a plan requirement-by-requirement with test-first discipline and full autonomy. Run after pwk-writing-plans. Each requirement: write integration tests (red) → checkpoint → implement to green → checkpoint → pwk-code-review."
4
4
  ---
5
5
 
6
6
  # Executing Tasks
7
7
 
8
- Implement the plan from `docs/plans/*-implementation.md` task by task, with file-based progress tracking and session-aware context management.
8
+ Implement the plan from `docs/plans/*-implementation.md` requirement by requirement, tracking progress in a file.
9
+
10
+ The plan is a **behavioral spec** (acceptance criteria + integration tests) — it deliberately contains no implementation steps. You choose structure, signatures, and internals; the criteria define *what*, you decide *how*.
9
11
 
10
12
  ## Before you start
11
13
 
12
- 1. **Check git state** — run `git status` and `git log --oneline -5`. Note any uncommitted changes.
13
- 2. **Find the plan** — look for `docs/plans/*-design.md` to get the Features table. Find the feature with status `🔄 planned`. The plan doc is `docs/plans/YYYY-MM-DD-<topic>-<slugified-feature-name>-implementation.md`. If no design doc exists, fall back to looking for a single `*-implementation.md` (backward compatibility with plans not using the feature table). This covers plans created without a brainstorm session (no design doc or Features table). If multiple plan docs exist and no design doc, ask the user which one to execute.
14
- 3. **Check for existing progress** look for `docs/plans/*-progress.md`. If one exists matching the plan, this is a **resume** (see [Resume](#resume)). If not, this is a **first run** (see [First run](#first-run)).
14
+ 1. **Git state** — `git status` + `git log --oneline -5`; note uncommitted changes.
15
+ 2. **Find the plan** — glob `docs/plans/*-implementation.md`; if several, ask which. Report one line, e.g. `Found: design "auth" execute phase (1/3 done)`. A matching `*-progress.md` means this is a **resume** (see [Resume](#resume)).
16
+ 3. **Workspace** `pwk-writing-plans` already created the branch/worktree. If you're still on `main`, tell the user the workspace wasn't set up and suggest fixing that before executing.
15
17
 
16
18
  ## First run
17
19
 
18
- 1. **Parse the implementation plan** — read the plan and extract all `## Task N:` headings. Build the progress table with all tasks as `⬜ pending`.
19
- 2. **Suggest workspace isolation** if the user isn't already on a feature branch or worktree, present the options:
20
-
21
- - **Branch** (smaller changes):
22
- ```
23
- git checkout -b <feature-name>
24
- ```
25
- - **Worktree** (larger features, keeps main clean):
26
- ```
27
- git worktree add ../<repo>-<feature-name> -b <feature-name>
28
- ```
29
-
30
- Derive `<feature-name>` from the plan doc (e.g. `docs/plans/2026-04-16-auth-design.md` → `auth`). Ask the user which they prefer, then wait for confirmation before proceeding.
31
-
32
- 3. **If worktree was chosen — hand off to new session:**
33
-
34
- a. Ensure the worktree's `docs/plans/` directory exists:
35
- ```
36
- mkdir -p <worktree>/docs/plans
37
- mkdir -p <worktree>/docs/plans/adr
38
- ```
39
-
40
- b. Move plan docs into the worktree:
41
-
42
- > When using the feature table, all plan docs for this design move together — completed feature plans, the current feature's plan, and the design doc. This is intentional: the worktree works on one design at a time.
43
-
44
- ```
45
- mv docs/plans/*-design.md <worktree>/docs/plans/ 2>/dev/null || true
46
- mv docs/plans/*-implementation.md <worktree>/docs/plans/ 2>/dev/null || true
47
- mv docs/plans/*-progress.md <worktree>/docs/plans/ 2>/dev/null || true
48
- mv docs/plans/adr/*.md <worktree>/docs/plans/adr/ 2>/dev/null || true
49
- ```
50
-
51
- c. Commit the removal on the current branch (if any plan docs were committed):
52
- ```
53
- git rm docs/plans/*-design.md docs/plans/*-implementation.md docs/plans/*-progress.md 2>/dev/null || true
54
- git rm -r docs/plans/adr/ 2>/dev/null || true
55
- git commit -m "chore: move plan docs to worktree for <feature-name>"
56
- ```
57
-
58
- d. Stop and show the user:
59
- ```
60
- ✅ Worktree created at ../<repo>-<feature-name>
61
- 📄 Plan docs moved to the worktree.
62
-
63
- To continue, start a new session there:
64
- cd ../<repo>-<feature-name> && pi
65
-
66
- Then run: /skill:pwk-executing-tasks
67
- ```
68
-
69
- e. **Create the progress file** in the worktree — save to `<worktree>/docs/plans/<plan-name>-progress.md`:
70
-
71
- ```markdown
72
- # Progress: <topic>
73
-
74
- Plan: docs/plans/YYYY-MM-DD-<topic>-implementation.md
75
- Branch: <feature-name>
76
- Started: <ISO timestamp>
77
- Last updated: <ISO timestamp>
78
-
79
- | # | Status | Task | Commit |
80
- |---|--------|------|--------|
81
- | 1 | ⬜ pending | Task description (preserve checkpoint labels) | — |
82
- ```
83
-
84
- This ensures the new session in the worktree will detect the progress file and resume correctly.
85
-
86
- f. **Do not proceed with task execution.** The session ends here.
87
-
88
- 4. **If branch was chosen — continue with execution:**
89
-
90
- a. **Create the progress file** — save to `docs/plans/<plan-name>-progress.md` (replace `-implementation` with `-progress` in the plan filename):
91
-
92
- ```markdown
93
- # Progress: <topic>
20
+ 1. **Parse the plan** — read every `## Requirement N:` heading and its `### Checkpoints` / `### Review` tags (defaults `full` / `parallel`). Requirements run in **listed order** — the plan is already in build order; do not reorder.
21
+ 2. **Setup pre-flight** *(only if the plan has a `## Setup` section)* install dependencies, apply migrations, seed data, then run the existing test suite. **⏸ CHECKPOINT: setup** — present results and wait for approval. Record `setup: done` in the progress-file header so a resume can confirm it rather than assume it.
22
+ 3. **Create the progress file** `docs/plans/<plan-name>-progress.md`:
94
23
 
95
- Plan: docs/plans/YYYY-MM-DD-<topic>-implementation.md
96
- Branch: <actual branch name>
97
- Started: <ISO timestamp>
98
- Last updated: <ISO timestamp>
24
+ ```markdown
25
+ # Progress: <topic>
99
26
 
100
- | # | Status | Task | Commit |
101
- |---|--------|------|--------|
102
- | 1 | ⬜ pending | Task description (preserve checkpoint labels) | — |
103
- ```
27
+ Plan: docs/plans/YYYY-MM-DD-<topic>-implementation.md
28
+ Branch: <branch>
29
+ Started: <ISO timestamp>
30
+ Last updated: <ISO timestamp>
104
31
 
105
- Use the actual branch name whether it's the original branch or a new one from the isolation step.
106
-
107
- b. **Commit the plan docs** if `docs/plans/` has uncommitted files, commit them on the new branch:
108
- ```
109
- git add docs/plans/ && git commit -m "docs: add design and implementation plan"
110
- ```
111
-
112
- c. **Begin task execution** — start with task 1 (see [Per-task execution](#per-task-execution)).
32
+ | # | Status | Requirement | Commit |
33
+ |---|--------|-------------|--------|
34
+ | 1 | pending | <requirement name> | |
35
+ ```
36
+ 4. **Commit the plan docs** — `git add docs/plans/ && git commit -m "docs: add implementation plan"`.
37
+ 5. Start requirement 1.
113
38
 
114
39
  ## Resume
115
40
 
116
- 1. **Read the progress file** — find the first task with status `⬜ pending`, `❌ failed`, or `🔄 in-progress`.
117
- 2. **Handle in-progress task** if a task is `🔄 in-progress` (mid-task crash):
118
- - Check `git log --oneline` since the last `✅ done` task's commit
119
- - If commits exist: ask the user — "Task N was in progress and commits were made. Continue from here, or reset it to pending?"
120
- - If no commits: restart the task (reset to `🔄 in-progress` and begin)
121
- 3. **Handle failed task** — if a task is `❌ failed`:
122
- - Show the failure reason from the progress file
123
- - Ask: "Retry, skip, or abort?"
124
- 4. **Handle pending task** — proceed normally
125
- 5. **All done** — if no `⬜ pending` or `❌ failed` tasks remain, show summary and suggest `/skill:pwk-finalizing`
126
- 6. **Begin task execution** — proceed from the identified task
41
+ Find the first row that is `⬜ pending`, `🔄 in-progress`, `⏸ tests-review`, or `⏸ complete-review`:
42
+ - `⏸ *-review` re-present that checkpoint and wait.
43
+ - `🔄 in-progress` continue the requirement.
44
+ - `⬜ pending` start it.
127
45
 
128
46
  ## Progress file
129
47
 
130
- **Path:** `docs/plans/<plan-name>-progress.md`
131
-
132
- **Status values:**
48
+ Update the matching row directly (not via pattern matching that could corrupt the table). Update `Last updated` on every change.
133
49
 
134
50
  | Status | Meaning |
135
51
  |--------|---------|
136
52
  | `⬜ pending` | Not started |
137
- | `🔄 in-progress` | Currently executing plan steps |
138
- | `⏸ test-review` | Paused at checkpoint: test, waiting for human approval |
139
- | `⏸ done-review` | Paused at checkpoint: done, waiting for human approval |
140
- | `✅ done` | Committed successfully |
141
- | `❌ failed` | Could not complete (append `Failed: <reason>`) |
53
+ | `🔄 in-progress` | Writing tests or implementing |
54
+ | `⏸ tests-review` | Paused at tests checkpoint, awaiting approval |
55
+ | `⏸ complete-review` | Paused at complete checkpoint, awaiting approval |
56
+ | `🔎 review` | Committed; code review in progress |
57
+ | `✅ done` | Reviewed (smells fixed, hazards noted), all green |
58
+ | `❌ failed` | Abandoned; partial work discarded/reverted (append `Failed: <reason>`) |
142
59
  | `⏭ skipped` | User chose to skip |
143
60
 
144
- **Update rules:**
145
- - Mark `🔄 in-progress` immediately when starting a task
146
- - Mark `⏸ test-review` or `⏸ done-review` when the agent reaches a `⏸ CHECKPOINT` gate in the plan — this must happen BEFORE any `git add` or `git commit`
147
- - Can only return to `🔄 in-progress` after the human explicitly says "approve"
148
- - Mark `✅ done` + record commit hash only after successful `git commit`
149
- - Cannot go from `🔄 in-progress` `✅ done` if the task has a checkpoint must go through the review status first
150
- - `git add` and `git commit` happen AFTER human approval, never before
151
- - Mark `❌ failed` + append reason when the agent can't proceed after retrying
152
- - Mark `⏭ skipped` when the user says "skip"
153
- - Update `Last updated` timestamp on every change
154
- - Preserve checkpoint labels in the task description column
155
-
156
- ## Per-task execution
157
-
158
- For each task:
159
-
160
- 1. **Mark in-progress** — update the progress file: `🔄 in-progress`
161
- 2. **Read the plan** — read the plan's overview section (everything before `## Task 1:`). Extract the `Design:` and `Feature:` metadata to know which design doc and feature row this execution covers. If no `Design:` or `Feature:` metadata is present, the plan covers the entire design (no feature table). Skip design doc reading and proceed directly to task execution. Otherwise, check the current feature's status in the design doc's Features table. Skim all `## Task N:` headings for dependency awareness. Then read the current task's body in full. **Read `docs/lessons.md`** if it exists — follow all rules listed there while working on this task.
162
- 3. **Execute the plan steps** — follow each numbered step in the task body, in order. As you work, shift your cognitive focus through three frames:
163
-
164
- **QA Test frame** (when writing/running tests): Focus entirely on translating the task's `Given/When/Then` Acceptance Criteria into precise failing tests. Before running tests, verify the test environment is sandboxed — no real database connections, API calls, or live services. External dependencies must be mocked or stubbed. Ensure the test environment is isolated (e.g., `NODE_ENV=test`, `GO_ENV=test`, or equivalent for your stack).
165
-
166
- **Pragmatic Developer frame** (when implementing): Focus on the simplest possible code to make the tests green. Do not over-engineer or add code for future requirements. Keep complexity to a bare minimum.
167
-
168
- **Senior Refactoring frame** (when refactoring): Evaluate the craftsmanship of the code. Check for:
169
- - **Shallow modules** — is the interface nearly as complex as the implementation? Can complexity be hidden behind a simpler interface?
170
- - **Deletion test** — if you deleted this module, would complexity vanish (pass-through) or reappear across callers (earning its keep)?
171
- - **Duplication** — extract repeated patterns
172
- - **Seam discipline** — don't introduce abstraction unless something actually varies across it. One adapter = hypothetical seam. Two adapters = real seam
173
-
174
- Run tests after each refactor step. Never refactor while tests are failing.
175
-
176
- Stop at any `⏸ CHECKPOINT` gate (see [Checkpoint gates](#checkpoint-gates--when-the-plan-says-stop)).
177
- 4. **Verify against task description** — re-read the task from the plan. Does the implementation satisfy every requirement listed? If not, fix before proceeding.
178
- 5. **Learn from mistakes** — if you caught yourself making a mistake during this task that you've made before or that would apply to future tasks, append a rule to `docs/lessons.md`. Only add rules that would change future behavior. If the file doesn't exist, create it with the standard format (see below).
179
-
180
- Before writing, apply the **generalization test**: would this rule apply equally to a completely different feature or domain in this repo? If not, rewrite it — strip out specific service names, entity types, and domain concepts, and express the underlying pattern instead. If you can't express a generic form, don't write the rule.
181
-
182
- ❌ **Domain-specific** (only survives this sprint):
183
- > "Always validate `userId` before calling `UserProfile.Get`"
184
-
185
- ✅ **Generic** (applies across the whole repo):
186
- > "Always validate required ID fields at the service boundary — missing IDs should return 400, not 500"
187
- 6. **Commit** — after all steps are done (no checkpoint gates remain in the task), `git add` the relevant files and commit with a clear message.
188
- 7. **Update progress** — mark `✅ done` + record the commit hash.
189
- 8. **Update design doc** — if the progress file shows all tasks for the current feature are `✅ done`, find the design doc (from plan metadata), and mark the current feature row as `✅ done` in the Features table.
190
- 9. **Suggest session break if needed** — after completing ~3-5 tasks since the last break, suggest:
191
- ```
192
- ✅ Tasks N-M done (commits: abc, def)
193
- Progress: X/Y tasks done
194
- ⏭ Next: Task [N+1] — [description]
195
- 💡 Context is building up. For clean context on remaining tasks:
196
- /new then /skill:pwk-executing-tasks
197
- (or just say "continue" to keep going here)
61
+ ## Per-requirement execution
62
+
63
+ 1. **Mark 🔄 in-progress** and read this requirement's `### Checkpoints` / `### Review` tags.
64
+ 2. **Write the integration tests (red).** Encode the acceptance criteria + test cases from the plan as real test files; run them; confirm they **fail**. If they pass immediately, the behavior may already exist or the tests are wrong — investigate before proceeding.
65
+ 3. **⏸ CHECKPOINT: tests** *(fires for `full` and `spec`)* — mark `⏸ tests-review`, present the tests + failing output, wait. **request changes** revise, re-run, re-present. With `none`, show the red output inline and proceed.
66
+ 4. **Implement (green)** with full autonomy. Run tests after each meaningful change; refactor for clarity (deep modules, no duplication, seam discipline) while tests stay green.
67
+ 5. **Learn.** Caught a repeat mistake? Append a **generic** rule to `docs/lessons.md` (strip domain specifics).
68
+ 6. **⏸ CHECKPOINT: complete** *(fires for `full` only)* — mark `⏸ complete-review`, show passing tests + `git diff`, wait. With `spec`/`none`, show them inline and proceed (**review** covers implementation quality; `spec` requires at least `inline` review).
69
+ 7. **Commit** the relevant files with a clear message. Status stays `🔄 in-progress` not done yet.
70
+ 8. **Composition check** — if this diff touched code shared with other requirements in the plan, run the **full test suite** now and fix any cross-requirement regression while the context is fresh. Otherwise keep running just this requirement's tests.
71
+ 9. **Code review** mark `🔎 review`; drive review by the `### Review` tag (`parallel | inline | skip`):
72
+ - **`parallel`** — four fresh-context reviewers via the `subagent` tool (see below).
73
+ - **`inline`** — run `/skill:pwk-code-review` as a single pass.
74
+ - **`skip`** — mark `✅ done` and move to the next requirement.
75
+
76
+ **Parallel path** — gather scope (acceptance criteria, test cases, `git log --oneline -5 && git diff HEAD~N..HEAD`) and invoke:
77
+ ```json
78
+ {
79
+ "tasks": [
80
+ {"agent": "pwk-spec-reviewer", "task": "<scope + diff here>"},
81
+ {"agent": "pwk-tracing-reviewer", "task": "<scope + diff here>"},
82
+ {"agent": "pwk-smell-reviewer", "task": "<scope + diff here>"},
83
+ {"agent": "pwk-hazard-reviewer", "task": "<scope + diff here>"}
84
+ ],
85
+ "agentScope": "both",
86
+ "cwd": "<repo-root>"
87
+ }
198
88
  ```
199
- Also suggest at checkpoint review pauses when multiple tasks have been completed since the last break. Respect the user's choice if they say "continue".
200
- 10. **Loop** — go back to step 1 for the next `⬜ pending` task, or see [After all tasks](#after-all-tasks) if none remain.
89
+ The reviewer checklists live only in `agents/pwk-*-reviewer.md` don't restate them in the task strings (duplication guarantees drift). Reviewers are read-only reporters; the executing agent applies fixes and commits.
201
90
 
202
- ### `docs/lessons.md` format
203
-
204
- ```markdown
205
- # Lessons Learned
206
-
207
- <!--
208
- Agent: read this at the start of each task during executing-tasks.
209
- Follow every rule. Add new rules when you catch yourself making repeat mistakes.
210
- Rules must be generic patterns applicable to any domain or feature — not specific to one service, entity, or use case.
211
- Retire rules that no longer apply during finalizing.
212
- -->
213
-
214
- ## Rules
215
-
216
- - <new rule here>
217
- ```
91
+ **On success** — apply smell fixes yourself (re-run integration tests, must stay green, commit), flag trace/spec/hazard findings as follow-ups for the human, mark `✅ done`.
218
92
 
219
- When adding a new rule during execution, always append it under `## Rules`. The categorization into specific headers (e.g., `## Tool Usage`, `## Testing Patterns`) is done during finalizing — never during execution.
93
+ **Fallback** subagent tool unavailable or errors run `/skill:pwk-code-review` inline instead.
94
+ 10. **Loop** to step 1 for the next `⬜ pending` requirement, or see [After all requirements](#after-all-requirements).
220
95
 
221
- ### Checkpoint gates when the plan says STOP
96
+ ### Checkpoint gates are mandatory (when the tag says so)
222
97
 
223
- The plan marks certain steps with `⏸ **CHECKPOINT: test**` or `⏸ **CHECKPOINT: done**`. These are hard stop points. When you reach one:
98
+ `### Checkpoints` accepted values: `full | spec | none` both stops / tests stop only / no stops. When a checkpoint fires it is a **hard stop**:
99
+ - Stop immediately; never proceed without explicit human approval.
100
+ - **Never** `git add` or `git commit` before approval at a checkpoint.
101
+ - Mark the progress file to the review status **before** pausing.
224
102
 
225
- 1. **Stop executing immediately.** Do not proceed to the next step in the task. Do not pass go.
226
- 2. **Do NOT run `git add` or `git commit`.** The code stays uncommitted until the human approves.
227
- 3. Update the progress file to `⏸ test-review` or `⏸ done-review`.
228
- 4. Present the checkpoint review (see below).
229
- 5. **Wait for the human to respond.** Do not continue executing steps, do not commit, do not move to the next task.
230
- 6. On approval, update progress back to `🔄 in-progress` and continue with the next step in the task.
231
-
232
- The whole point of checkpoints is that the human reviews code at critical moments before the agent proceeds further. If you skip past a checkpoint without waiting, you defeat this purpose.
233
-
234
- | Checkpoint type | What the agent has done at this point | What needs human approval |
235
- |---|---|---|
236
- | `checkpoint: test` | Written failing tests, confirmed they fail | The test design — are the right things being tested? |
237
- | `checkpoint: done` | Implemented, refactored, written lessons | The implementation approach, the refactoring choices |
238
-
239
- **For `checkpoint: test`:** Only the test file should exist at this point. No implementation code yet. The human reviews the test to confirm the right behavior is being specified.
240
-
241
- **For `checkpoint: done`:** All code changes are made but NOT committed. Run `git diff` (not `git diff --cached` — nothing should be staged) to show the human what changed. The human reviews before anything is committed.
242
-
243
- ## Checkpoint review
244
-
245
- When you hit a checkpoint gate, present a review to the human and **stop all execution** until they respond.
246
-
247
- ### At `checkpoint: test`
248
-
249
- You have written the failing tests and confirmed they fail. No implementation code exists yet.
250
-
251
- Present:
252
- ```
253
- ⏸ Paused at checkpoint: test for task [N]
254
-
255
- **Test file:** `path/to/test.ts`
256
-
257
- **Test code:**
258
- [show the full test code]
259
-
260
- **Test results:** [paste the failing test output showing which tests fail and why]
261
-
262
- **What this validates:** [summarize the behavior these tests specify]
263
- **Next step after approval:** Write the implementation to make these tests pass
264
-
265
- What would you like to do?
266
- - **approve** — I'll implement to make these tests pass
267
- - **request changes** — tell me what to change in the tests
268
- - **revert** — undo this task and go back to pending
269
- - **skip** — skip this task entirely
270
- - **stop** — pause here, resume later with /skill:pwk-executing-tasks
271
- - **status** — show the full progress table
272
- ```
273
-
274
- ### At `checkpoint: done`
275
-
276
- You have implemented the code, run the refactor step, and written any lessons. Nothing is committed yet.
277
-
278
- Present:
279
- ```
280
- ⏸ Paused at checkpoint: done for task [N]
281
-
282
- **What was done:** [brief summary — what feature/fix was implemented]
283
-
284
- **Test results:** [run tests now, paste the passing output]
285
-
286
- **Diff:** [run `git diff` — the unstaged changes are what this task produced]
287
- [paste the full diff]
288
-
289
- **Refactoring done:** [what changed during refactor, or "none needed — [reason]"]
290
- **Lessons learned:** [new rule added to docs/lessons.md, or "none"]
291
- **Next step after approval:** git add, commit, and move to next task
292
-
293
- What would you like to do?
294
- - **approve** — I'll commit and move to the next task
295
- - **request changes** — tell me what to change, I'll update and re-present
296
- - **revert** — undo this task and go back to pending
297
- - **skip** — skip this task entirely
298
- - **stop** — pause here, resume later with /skill:pwk-executing-tasks
299
- - **status** — show the full progress table
300
- ```
301
-
302
- **Do not commit before the human approves.** The diff you show at `checkpoint: done` is the uncommitted work. If the human requests changes, make the edits, re-run tests, and re-present the updated diff at the same checkpoint. Repeat until they say "approve".
303
-
304
- Only after approval: `git add` the relevant files, commit, and mark the task `✅ done`.
305
-
306
- ## Progress file updates
307
-
308
- Update the progress file by reading it, modifying the relevant row's status and commit hash, and writing it back. Target the specific task row — do not use pattern-matching approaches (e.g. sed) that could corrupt the table.
309
-
310
- Update `Last updated` timestamp on every change.
103
+ `Checkpoints: spec` with `Review: skip` is invalid (nothing would cover implementation quality) — stop and ask the human to fix the tags; use `Checkpoints: none` for truly trivial diffs.
311
104
 
312
105
  ## User override commands
313
106
 
314
- The user can issue these commands at any time during execution:
315
-
316
107
  | User says | Agent does |
317
108
  |-----------|-----------|
318
- | `skip` | Mark current task `⏭ skipped`, move to next |
109
+ | `skip` | Mark current requirement `⏭ skipped`, move to next |
319
110
  | `status` | Show the progress table |
320
- | `stop` | Mark current task back to `⬜ pending`, suggest `/new` |
321
- | `retry` | Re-read current task section, start over |
322
-
323
- ## Receiving code review
111
+ | `stop` | Restore current requirement to its pre-in-progress state, suggest `/new` |
112
+ | `retry` | Re-read the requirement, start over |
324
113
 
325
- When the user shares code review feedback (outside of a checkpoint pause):
114
+ ## Receiving feedback (outside a checkpoint)
326
115
 
327
- 1. **Verify the criticism** read the relevant code. Is the feedback accurate?
328
- 2. **Evaluate the suggestion** — is the proposed fix the right approach? Consider alternatives.
329
- 3. **Implement or push back** — if valid, fix it, re-run tests, and amend the commit. If not, explain why with evidence from the codebase.
330
- 4. **Don't blindly implement** — every suggestion should be verified against the code before accepting.
116
+ Verify the criticism against the code, evaluate the suggestion, then implement (with tests) or push back with evidence. Don't blindly apply.
331
117
 
332
- ## If you're stuck
118
+ ## After all requirements
333
119
 
334
- 1. Re-read the current task section from the plan you may have drifted from the spec
335
- 2. Check git log — recent commits may reveal context
336
- 3. Ask the user — it's better to clarify than to guess wrong
337
- 4. If still stuck after asking, mark the task `❌ failed` with the reason in the progress file and move to the next task
338
- 5. **Check `docs/lessons.md`** — a previous lesson may be relevant to your current problem.
120
+ When no `⬜ pending` or `🔄 in-progress` requirements remain, run the **integration gate** before suggesting finalizeper-requirement review only saw each diff in isolation; this proves the requirements *compose* into the feature:
339
121
 
340
- ## After all tasks
122
+ 1. **Run the FULL test suite.** A failure here means one requirement regressed another — fix it now, in execute context.
123
+ 2. **Run the feature-acceptance test.** The plan's `## Feature acceptance` section specifies one end-to-end test exercising the requirements *together* against the design's claim. Write it if missing; run it; it must pass. If the plan has no such section, stop and tell the human — the gate has nothing concrete to verify.
124
+ 3. **Confirm composition.** Do the requirements together deliver the end-to-end behavior the design doc described? Fix gaps here, with tests, before shipping.
341
125
 
342
- When no `⬜ pending` or `❌ failed` tasks remain for the current feature, read the design doc's Features table. Show the per-task summary from the progress file, then check for more features:
126
+ Then present:
343
127
 
344
- ### More features remaining
345
-
346
- ```
347
- ✅ Feature "<feature name>" complete.
348
-
349
- | # | Status | Task |
350
- |---|--------|------|
351
- | 1 | ✅ done | Create User model |
352
- | 2 | ✅ done | Add signup endpoint |
353
-
354
- ⏭ Next: "<next pending feature name>"
355
- 💡 Options:
356
- - Plan next feature: /skill:pwk-writing-plans
357
- - Verify this feature first: /skill:pwk-verify
358
- - Or just say "continue"
359
128
  ```
129
+ ✅ All requirements complete — integration verified!
360
130
 
361
- ### All features complete
131
+ | # | Status | Requirement |
132
+ |---|--------|-------------|
133
+ | 1 | ✅ done | <name> |
134
+ | … | … | … |
362
135
 
136
+ - Ship: /skill:pwk-finalizing
363
137
  ```
364
- ✅ All features complete!
365
-
366
- | # | Status | Feature |
367
- |---|--------|---------|
368
- | 1 | ✅ done | User signup |
369
- | 2 | ✅ done | Email verification |
370
- | 3 | ⏭ skipped | Password reset |
371
138
 
372
- | # | Status | Task |
373
- |---|--------|------|
374
- | 1 | ✅ done | Create User model |
375
- | 2 | ✅ done | Add signup endpoint |
376
- | ... | ... | ... |
139
+ ## If you're stuck
377
140
 
378
- - Verify everything: /skill:pwk-verify
379
- - Ship: /skill:pwk-finalizing
380
- ```
141
+ 1. Re-read the requirement's acceptance criteria — you may have drifted.
142
+ 2. Check `git log` for context. Ask the user — clarify beats guessing.
143
+ 3. Still stuck → discard uncommitted changes (`git restore .`); if already committed, also `git revert` the requirement's commit(s). **Never leave a failed requirement's partial work on the shipped branch.**
144
+ 4. Mark `❌ failed` with the reason and move on. Check `docs/lessons.md` — a prior lesson may apply.