@tianhai/pi-workflow-kit 0.18.1 → 1.0.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 +38 -44
  7. package/docs/lessons.md +2 -7
  8. package/docs/oversight-model.md +18 -14
  9. package/docs/workflow-phases.md +52 -29
  10. package/extensions/workflow-guard.ts +190 -92
  11. package/package.json +18 -3
  12. package/skills/pwk-brainstorming/SKILL.md +19 -18
  13. package/skills/pwk-code-review/SKILL.md +46 -0
  14. package/skills/pwk-diagnose/SKILL.md +2 -1
  15. package/skills/pwk-executing-tasks/SKILL.md +102 -328
  16. package/skills/pwk-finalizing/SKILL.md +36 -84
  17. package/skills/pwk-status/SKILL.md +28 -0
  18. package/skills/pwk-writing-plans/SKILL.md +50 -325
  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
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # pi-workflow-kit
2
2
 
3
- > Stop AI agents from rushing to code. Enforce a structured brainstorm→plan→execute→verify→finalize workflow with TDD discipline.
3
+ > Stop AI agents from rushing to code. Enforce a structured brainstorm→plan→execute→finalize workflow with test-first discipline and per-requirement code review.
4
4
 
5
5
  AI coding agents tend to skip design and jump straight into implementation, producing over-engineered or misaligned code. **pi-workflow-kit** solves this by hard-blocking write operations during brainstorm and planning phases — the agent *literally cannot modify your source files* until you approve the design.
6
6
 
@@ -20,6 +20,14 @@ No setup needed — skills and guards activate automatically after install.
20
20
  pi -e npm:@tianhai/pi-workflow-kit
21
21
  ```
22
22
 
23
+ **Optional — parallel code review.** Per-requirement review can run four specialized reviewers in parallel via the `subagent` tool. Install [`pi-subagents`](https://pi.dev/packages/pi-subagents) to enable it:
24
+
25
+ ```bash
26
+ pi install npm:pi-subagents
27
+ ```
28
+
29
+ The four reviewers (`pwk-spec-reviewer`, `pwk-tracing-reviewer`, `pwk-smell-reviewer`, `pwk-hazard-reviewer`) ship with this kit as **package agents** — `pi-subagents` discovers them automatically, no extra setup. Without `pi-subagents`, `pwk-executing-tasks` falls back to inline `/skill:pwk-code-review`.
30
+
23
31
  ## What You Get
24
32
 
25
33
  ### 🛡️ Workflow Guard (extension)
@@ -28,30 +36,35 @@ Enforces phase-appropriate tool access — not just guidelines, but hard blocks:
28
36
 
29
37
  | Phase | `write` / `edit` | `bash` |
30
38
  |-------|:-:|:-:|
31
- | **Brainstorm** / **Plan** / **Verify** | 🔒 Blocked outside `docs/plans/` | 🔒 Read-only only (grep, find, cat, git status, curl…) |
32
- | **Execute** / **Finalize** | ✅ Full access | ✅ Full access |
39
+ | **Brainstorm** / **Plan** | 🔒 Blocked outside `docs/plans/` | 🔒 Destructive commands blocked (simple blacklist) |
40
+ | **Execute** / **Code-review** / **Finalize** / **Diagnose** / **Status** | ✅ Full access | ✅ Full access |
41
+
42
+ The agent can read code and discuss design with you during brainstorm/plan, but it physically cannot modify source files. Bash during gated phases is governed by a simple common-blacklist (a command is allowed unless it matches a destructive pattern), and a short phase reminder is shown once when the gated phase begins so the model self-restricts.
33
43
 
34
- The agent can read code and discuss design with you during brainstorm/plan, but it physically cannot modify source files or run mutating commands.
44
+ Phases transition only when you invoke a skill (`/skill:pwk-brainstorming` → read-only; `/skill:pwk-executing-tasks` unrestricted) no message keyword unlocks the guard. Need to override it? `/pwk-guard on` forces a read-only lock, `off` disables the guard entirely, `auto` (default) returns to skill-driven phases. The subcommands autocomplete after the command.
35
45
 
36
46
  ### 🧠 7 Workflow Skills
37
47
 
38
48
  Guide the agent through a disciplined development process:
39
49
 
40
- brainstorm → plan → [design-review?] → execute → [verify?] → finalize
41
-
42
- diagnose (anytime)
50
+ ```
51
+ brainstorm → writing-plans → executing-tasks → finalizing
52
+ (per requirement: tests → checkpoint → implement → checkpoint → code-review)
53
+
54
+ diagnose (anytime) · status (anytime)
55
+ ```
43
56
 
44
- For multi-feature designs, the plan→execute loop repeats per feature.
57
+ A **design doc is one PR**; a **requirement is one testable slice within it**. For multi-design work (a large issue split into several design docs — each its own PR), run the pipeline once per design doc.
45
58
 
46
59
  | Phase | Trigger | What Happens |
47
60
  |-------|---------|--------------|
48
- | **Brainstorm** | `/skill:pwk-brainstorming` | Explore approaches, debate tradeoffs, produce a design doc with a Features table |
49
- | **Design Review** | `/skill:pwk-design-review` | Audit plan and design for production risks (security, scalability, fault tolerance) |
50
- | **Plan** | `/skill:pwk-writing-plans` | Plan one feature at a time from the Features table bite-sized TDD tasks with acceptance criteria |
51
- | **Execute** | `/skill:pwk-executing-tasks` | Implement tasks one-by-one with TDD discipline and pre-commit checkpoint review gates |
52
- | **Verify** | `/skill:pwk-verify` | Three expert review passes (security, optimization, traceability) on implemented code |
53
- | **Finalize** | `/skill:pwk-finalizing` | Archive plan docs, update README/CHANGELOG, create PR |
54
- | **Diagnose** | `/skill:pwk-diagnose` | 6-phase debugging loop: reproduce hypothesize instrument fix verify |
61
+ | **Brainstorm** | `/skill:pwk-brainstorming` | Explore approaches, produce a design doc with a `## Requirements` list |
62
+ | **Plan** | `/skill:pwk-writing-plans` | Turn each requirement into **acceptance criteria + integration tests** — a behavioral spec (no implementation code) |
63
+ | **Execute** | `/skill:pwk-executing-tasks` | Per requirement: write tests (red) **checkpoint: tests** implement (green) **checkpoint: complete** code-review |
64
+ | **Code review** | `/skill:pwk-code-review` | Per requirement: code tracing, spec alignment, code smells (applies fixes), production hazard check |
65
+ | **Finalize** | `/skill:pwk-finalizing` | Delete consumed plan docs, update README/CHANGELOG, create PR |
66
+ | **Diagnose** | `/skill:pwk-diagnose` | Debugging loop: reproduce hypothesise instrument → fix → cleanup |
67
+ | **Status** | `/skill:pwk-status` | Read-only overview of all active design topics — phase + progress. Use when resuming or juggling several designs in parallel worktrees. Not a pipeline phase. |
55
68
 
56
69
  ## The Workflow in Detail
57
70
 
@@ -59,63 +72,61 @@ For multi-feature designs, the plan→execute loop repeats per feature.
59
72
 
60
73
  You control each phase — the agent never advances on its own. Invoke a skill to move forward:
61
74
 
62
- /skill:pwk-brainstorming → discuss and design (names features)
63
- /skill:pwk-writing-plansplan next feature from the Features table
64
- /skill:pwk-design-reviewaudit for production risks (on demand)
65
- /skill:pwk-executing-tasks → implement with TDD
66
- /skill:pwk-verify review code for security, optimization, and traceability
75
+ ```
76
+ /skill:pwk-brainstormingdiscuss and design (lists Requirements)
77
+ /skill:pwk-writing-plansturn each Requirement into acceptance criteria + integration tests
78
+ /skill:pwk-executing-tasks → implement per requirement with two mandatory checkpoints
79
+ /skill:pwk-code-review auto-runs per-requirement inside executing-tasks; also invocable manually for ad-hoc reviews
67
80
  /skill:pwk-finalizing → ship it
81
+ ```
68
82
 
69
- ### Feature-Based Planning
70
-
71
- Design docs include a `## Features` table that tracks each feature's status:
72
-
73
- | # | Feature | Status | Notes |
74
- |---|---------|--------|-------|
75
- | 1 | User signup | ✅ done | |
76
- | 2 | Email verification | 🔄 planned | Plan: docs/plans/...-email-verification-implementation.md |
77
- | 3 | Password reset | ⬜ pending | |
83
+ ### Behavioral-Spec Planning
78
84
 
79
- This enables incremental development plan and execute one feature at a time, then loop back for the next.
85
+ Plans specify *what*, not *how*. For each requirement, the plan gives **acceptance criteria + integration-test cases** — no implementation code, no file-by-file recipe. The executor has full autonomy to choose structure, signatures, and internals. A fine-grained implementation plan invalidates the moment a detail shifts; acceptance criteria + integration tests survive implementation changes.
80
86
 
81
- ### TDD Three-Scenario Model
87
+ ### Test-First per Requirement
82
88
 
83
- Each task is labeled with its TDD scenario during planning:
89
+ Each requirement is implemented test-first:
84
90
 
85
- | Scenario | When | Rule |
86
- |----------|------|------|
87
- | **New feature** | Adding new behavior | Write failing test → implement → pass |
88
- | **Modifying tested code** | Changing existing behavior | Run existing tests first → modify → verify |
89
- | **Trivial** | Config, docs, naming | Use judgment |
91
+ 1. Write the integration tests (red)
92
+ 2. ⏸ **checkpoint: tests** — you review the test design
93
+ 3. Implement to green (full autonomy)
94
+ 4. **checkpoint: complete** you review the implementation
95
+ 5. Commit code review
90
96
 
91
97
  ### Lessons Learned
92
98
 
93
- A persistent rules file (`docs/lessons.md`) helps the agent learn from repeat mistakes across sessions. When the agent catches itself making the same error — like forgetting to run `make lint` — it writes a rule immediately. Future sessions (even after `/new`) pick it up automatically.
99
+ A persistent rules file (`docs/lessons.md`) helps the agent learn from repeat mistakes across sessions. When the agent catches itself making the same error, it writes a generic rule immediately. Future sessions (even after `/new`) pick it up automatically.
94
100
 
95
101
  ```
96
102
  brainstorm → reads lessons (design context)
97
- plan → reads lessons (task breakdown)
98
- execute → reads lessons per task, writes new ones on repeat mistakes
99
- finalize → reviews and retires stale rules
103
+ plan → reads lessons (acceptance criteria / tests)
104
+ execute → reads lessons per requirement, writes new ones on repeat mistakes
105
+ finalize → reviews, generalizes, and retires stale rules
100
106
  ```
101
107
 
102
108
  Rules are simple imperative bullets:
103
109
 
104
- - After completing each task, run `make lint && make fmt` before committing
110
+ - After completing each requirement, run `make lint && make fmt` before committing
105
111
  - Never import `testify` in this project
106
112
  - Always check for existing test helpers before writing new ones
107
113
 
108
- No configuration needed — the file is created automatically when the first lesson is written.
114
+ No configuration needed — the file ships with starter rules and grows as the agent learns.
109
115
 
110
- ### Checkpoint Review Gates
116
+ ### Two Mandatory Checkpoints per Requirement
111
117
 
112
- Optionally label tasks with a `checkpoint` to pause for human review. At each checkpoint the agent stops and waits for your feedback — you can approve, ask for changes, or send it back to rethink. Only when you're satisfied does it move on to the next task.
118
+ Each requirement has **two hard human-review gates** (not optional):
113
119
 
114
- | Checkpoint | When to Use | What Happens |
120
+ | Checkpoint | What's done | What you review |
115
121
  |---|---|---|
116
- | *(none)* | Trivial tasks, well-understood changes | Auto-advance, no pause |
117
- | `checkpoint: test` | Test design matters | Agent writes the failing test, then pauses for your review. Verify the test covers the right cases before the agent implements. |
118
- | `checkpoint: done` | Implementation review matters | Agent implements and passes tests, then pauses for your review. Verify the implementation is correct before committing. |
122
+ | **tests** | Integration tests written, confirmed failing | Are the right behaviors being specified? |
123
+ | **complete** | Implemented, tests green, refactored | Is the implementation correct before committing? |
124
+
125
+ The agent stops and waits at each — approve, request changes, or send it back.
126
+
127
+ ### Before You Ship: the Integration Gate
128
+
129
+ Per-requirement review checks each diff in isolation. Before finalizing, the agent runs an **integration gate**: the **full test suite** (not just the last requirement's) must pass, and it confirms the requirements compose into the feature the design described. Finalize re-runs the full suite too — it never ships a red suite, even across resumed sessions.
119
130
 
120
131
  ## Quick Start
121
132
 
@@ -127,29 +138,27 @@ pi install npm:@tianhai/pi-workflow-kit
127
138
  > /skill:pwk-brainstorming
128
139
  > I want to add OAuth2 login to our API
129
140
 
130
- # (agent explores approaches, writes design doc with Features table)
141
+ # (agent explores approaches, writes a design doc with a Requirements list)
131
142
  # (write/edit are blocked — your code is safe)
132
143
 
133
144
  > /skill:pwk-writing-plans
134
145
 
135
- # (agent picks next feature, breaks into TDD tasks)
136
- # (triggers design review for non-trivial features)
146
+ # (agent turns each Requirement into acceptance criteria + integration tests)
147
+
137
148
  > /skill:pwk-executing-tasks
138
149
 
139
- # (agent implements with TDD, cognitive persona shifts, all tools unlocked)
140
- > /skill:pwk-verify
150
+ # (per requirement: writes tests checkpoint implements checkpoint → code-review)
141
151
 
142
- # (agent runs security, optimization, and traceability reviews on implemented code)
143
152
  > /skill:pwk-finalizing
144
153
 
145
- # (agent archives docs, curates lessons, creates PR)
154
+ # (agent deletes consumed plan docs, curates lessons, creates PR)
146
155
  ```
147
156
 
148
157
  ## Why?
149
158
 
150
159
  - **AI agents skip design.** Left unchecked, they jump to code and over-engineer. This forces a think-first workflow.
151
- - **TDD needs structure.** The three-scenario model gives the agent clear rules for when to write tests first.
152
- - **You stay in control.** Checkpoint review gates let you approve test designs and implementations before the agent commits.
160
+ - **Specs beat recipes.** Plans are behavioral specs (acceptance criteria + tests), not implementation recipes they don't invalidate when details change.
161
+ - **You stay in control.** Two mandatory checkpoints per requirement let you approve test design and implementation before the agent commits.
153
162
  - **Enforced, not suggested.** Hard blocks mean the agent can't ignore the rules — not even accidentally.
154
163
 
155
164
  ## Project
@@ -157,15 +166,23 @@ pi install npm:@tianhai/pi-workflow-kit
157
166
  ```
158
167
  pi-workflow-kit/
159
168
  ├── extensions/
160
- │ └── workflow-guard.ts # Write blocker during brainstorm/plan/verify
169
+ │ └── workflow-guard.ts # Write blocker during brainstorm/plan; destructive-bash blacklist
161
170
  ├── skills/
162
171
  │ ├── pwk-brainstorming/SKILL.md
163
- │ ├── pwk-design-review/SKILL.md
164
172
  │ ├── pwk-writing-plans/SKILL.md
165
173
  │ ├── pwk-executing-tasks/SKILL.md
166
- │ ├── pwk-verify/SKILL.md
174
+ │ ├── pwk-code-review/SKILL.md
167
175
  │ ├── pwk-finalizing/SKILL.md
176
+ │ ├── pwk-status/SKILL.md
168
177
  │ └── pwk-diagnose/SKILL.md
178
+ ├── agents/ # package agents for parallel code-review (discovered by pi-subagents)
179
+ ├── docs/
180
+ │ ├── developer-usage-guide.md
181
+ │ ├── workflow-phases.md
182
+ │ ├── oversight-model.md
183
+ │ ├── lessons.md
184
+ │ ├── adr/ # permanent architectural decisions (never archived)
185
+ │ └── plans/ # active design/plan/progress docs (deleted after finalization)
169
186
  ├── tests/
170
187
  │ └── workflow-guard.test.ts
171
188
  ├── package.json
@@ -180,4 +197,4 @@ npm test
180
197
 
181
198
  ## License
182
199
 
183
- [MIT](LICENSE)
200
+ [MIT](LICENSE)
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: pwk-hazard-reviewer
3
+ description: Production-hazard reviewer — audits for unbounded ops, missing indexes, unbounded concurrency, long transactions, injection, silent swallowing loops. Read-only reporter.
4
+ tools: read, grep, find, ls, bash
5
+ systemPromptMode: replace
6
+ ---
7
+
8
+ # PWK Hazard Reviewer
9
+
10
+ You are a production-hazards reviewer. Execute the task instructions below faithfully using read-only tools (`read`, `grep`, `find`, `bash`). **Report findings only — do NOT modify files.** Flag hazards and non-trivial issues for the main agent / human to decide.
11
+
12
+ ## Checklist — audit each changed file
13
+
14
+ For each item below, write `[SAFE]` (1-line justification) or `[TRIGGERED]` (concrete mitigation):
15
+
16
+ 1. **Unbounded operations** — multi-key deletions/scans (`KEYS`, raw `SCAN` loops), full-table loads filtered in memory
17
+ 2. **Missing indexes** — hot queries on unindexed columns (table scans under load)
18
+ 3. **Unbounded concurrency** — unthrottled fan-out (`Promise.all` without batch limits)
19
+ 4. **Long-running transactions** — holding DB connections/locks across slow external calls
20
+ 5. **Query/command interpolation** — raw variables merged into SQL or shell (injection)
21
+ 6. **Unrestricted uploads / temp flooding** — uploads to local temp without limits or `finally` cleanup
22
+ 7. **Silent swallowing loops** — background workers catching/suppressing exceptions without logging/back-off
23
+
24
+ Also check the design doc's `## Production-risk areas`, if any.
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: pwk-smell-reviewer
3
+ description: Code-smell reviewer — flags shallow modules, duplication, missing seams, premature abstraction, poor naming, magic values, dead code. Read-only reporter.
4
+ tools: read, grep, find, ls, bash
5
+ systemPromptMode: replace
6
+ ---
7
+
8
+ # PWK Smell Reviewer
9
+
10
+ You are a code-smell reviewer. Execute the task instructions below faithfully using read-only tools (`read`, `grep`, `find`, `bash`). **Report findings only — do NOT modify files.** Flag only: smells that require large refactors risky to the requirement; everything else is for the main agent to fix.
11
+
12
+ ## Checklist — report what you find
13
+
14
+ - Shallow modules (interface nearly as complex as implementation)
15
+ - Duplication
16
+ - Missing seams / premature abstraction
17
+ - Poor naming, magic values, dead code
@@ -0,0 +1,14 @@
1
+ ---
2
+ name: pwk-spec-reviewer
3
+ description: Spec-alignment reviewer — checks each acceptance criterion has covering code and tests; flags gaps and scope creep. Read-only reporter.
4
+ tools: read, grep, find, ls, bash
5
+ systemPromptMode: replace
6
+ ---
7
+
8
+ # PWK Spec Reviewer
9
+
10
+ You are a spec-alignment reviewer. Execute the task instructions below faithfully using read-only tools (`read`, `grep`, `find`, `bash`). **Report findings only — do NOT modify files.**
11
+
12
+ ## Checklist
13
+
14
+ For each acceptance criterion, point to the code and the test that satisfy it. A criterion with no covering code or no test is a **gap**. Code that does more than the criteria specify is **scope creep** — flag it.
@@ -0,0 +1,14 @@
1
+ ---
2
+ name: pwk-tracing-reviewer
3
+ description: Code-tracing reviewer — traces new/changed paths end-to-end against tests; flags untested branches, dead branches, and broken traces. Read-only reporter.
4
+ tools: read, grep, find, ls, bash
5
+ systemPromptMode: replace
6
+ ---
7
+
8
+ # PWK Trace Reviewer
9
+
10
+ You are a code-tracing reviewer. Execute the task instructions below faithfully using read-only tools (`read`, `grep`, `find`, `bash`). **Report findings only — do NOT modify files.**
11
+
12
+ ## Checklist
13
+
14
+ Trace the new/changed code paths end-to-end against the integration tests. For each path: does data flow correctly from entry to the asserted outcome? Note any branch the tests don't exercise, any dead branch, any path where the trace breaks.
@@ -4,9 +4,9 @@ How to install and use `pi-workflow-kit` with the Pi coding agent.
4
4
 
5
5
  ## What you get
6
6
 
7
- - **4 workflow skills** that guide the agent through a structured feature-based workflow
8
- - **3 on-demand skills** for design review, verification, and debugging
9
- - **1 extension** that hard-blocks source writes during brainstorm, plan, and verify phases
7
+ - **5 pipeline skills** brainstorm writing-plans executing-tasks finalizing, with code-review running per requirement during execution.
8
+ - **2 utility skills** diagnose (debugging) and status (multi-topic overview), both on demand.
9
+ - **1 extension** hard-blocks source writes during brainstorm and writing-plans, and blocks destructive bash via a simple common-blacklist.
10
10
 
11
11
  ## Installation
12
12
 
@@ -32,10 +32,10 @@ Or in `.pi/settings.json` / `~/.pi/agent/config.json`:
32
32
 
33
33
  ## The workflow
34
34
 
35
- You control each phase by invoking the skill. For multi-feature designs, the plan→execute loop repeats per feature:
35
+ You control each phase by invoking the skill. A design doc is one PR; a requirement is one testable slice within it. For multi-design work (a large issue split), run the pipeline once per design doc:
36
36
 
37
37
  ```
38
- /skill:pwk-brainstorming → /skill:pwk-writing-plans → /skill:pwk-executing-tasks → loop or /skill:pwk-finalizing
38
+ /skill:pwk-brainstorming → /skill:pwk-writing-plans → /skill:pwk-executing-tasks → /skill:pwk-finalizing
39
39
  ```
40
40
 
41
41
  ### 1. Brainstorm
@@ -44,11 +44,9 @@ You control each phase by invoking the skill. For multi-feature designs, the pla
44
44
  /skill:pwk-brainstorming
45
45
  ```
46
46
 
47
- Explore the idea through collaborative dialogue. The agent reads code, asks questions one at a time, proposes 2-3 approaches, and presents the design in sections for your review.
47
+ Explore the idea through collaborative dialogue. The agent reads code, asks questions, proposes approaches, and presents the design for your review.
48
48
 
49
- Outcome: `docs/plans/YYYY-MM-DD-<topic>-design.md` with a `## Features` table
50
-
51
- Optionally writes ADRs to `docs/plans/adr/` for significant architectural decisions.
49
+ Outcome: `docs/plans/YYYY-MM-DD-<topic>-design.md` — descriptive, opening with a `## Requirements` list. May split a large issue into multiple design docs. ADRs go to `docs/adr/` (permanent).
52
50
 
53
51
  ### 2. Plan
54
52
 
@@ -56,9 +54,9 @@ Optionally writes ADRs to `docs/plans/adr/` for significant architectural decisi
56
54
  /skill:pwk-writing-plans
57
55
  ```
58
56
 
59
- Read the design doc's Features table, pick the next `⬜ pending` feature, and create a per-feature implementation plan with exact file paths, complete code, and TDD scenarios. Optionally set up a branch or worktree.
57
+ Read the design doc's Requirements and turn each into **acceptance criteria + integration-test cases** a behavioral spec (no implementation code).
60
58
 
61
- Outcome: `docs/plans/YYYY-MM-DD-<topic>-<feature-name>-implementation.md`
59
+ Outcome: `docs/plans/YYYY-MM-DD-<topic>-implementation.md`.
62
60
 
63
61
  ### 3. Execute
64
62
 
@@ -66,65 +64,61 @@ Outcome: `docs/plans/YYYY-MM-DD-<topic>-<feature-name>-implementation.md`
66
64
  /skill:pwk-executing-tasks
67
65
  ```
68
66
 
69
- Implement the plan task-by-task. Each task: implementrun tests → fix if needed → commit. When the feature is done, marks it `✅ done` in the design doc and suggests planning the next feature.
67
+ Implement requirement-by-requirement with **full autonomy**: write the integration tests (red) **checkpoint: tests**implement to green**checkpoint: complete** → commit → code-review. Two mandatory human checkpoints per requirement. After all requirements, an **integration gate** runs the full suite and confirms the requirements compose into the feature before finalize.
70
68
 
71
- ### 4. Finalize
69
+ ### 4. Code review (per requirement)
72
70
 
73
- ```
74
- /skill:pwk-finalizing
75
- ```
71
+ The `pwk-executing-tasks` skill invokes the `subagent` tool automatically (programmatic, not user-driven). Four specialized reviewers launch in parallel — each reviewing from a different dimension (spec gaps & scope creep, end-to-end code tracing, code smells, production hazards). The reviewers ship as **package agents** (`agents/pwk-*.md`, declared via the `pi-subagents.agents` manifest key) and are discovered natively by the optional **`pi-subagents`** package — no copy step. All report findings only; no agent edits files or produces commits. The main agent collects results, applies smell fixes itself, runs integration tests after each fix, then updates progress to `✅ done`.
76
72
 
77
- Archive plan docs, update CHANGELOG/README, create PR, clean up worktree.
73
+ *Fallback:* if `pi-subagents` is not installed (so the `subagent` tool is unavailable), the skill falls back to inline `/skill:pwk-code-review` as before. Install it to enable parallel review:
74
+
75
+ ```bash
76
+ pi install npm:pi-subagents
77
+ ```
78
78
 
79
- ### 5. Design Review (on demand)
79
+ ### 5. Finalize
80
80
 
81
81
  ```
82
- /skill:pwk-design-review
82
+ /skill:pwk-finalizing
83
83
  ```
84
84
 
85
- Audit a plan doc for production risks security, scalability, fault tolerance, and operational hazards. Triggered by writing-plans for non-trivial features. Review findings append to the plan doc, not the design doc.
85
+ **Pre-check: run the full test suite**never ship a red suite (resume spans sessions). Then delete consumed plan docs (code + tests are the source of truth), curate lessons, update CHANGELOG/README, create PR or merge.
86
86
 
87
- ### 6. Verify (on demand)
87
+ ### Diagnose (on demand)
88
88
 
89
89
  ```
90
- /skill:pwk-verify
90
+ /skill:pwk-diagnose
91
91
  ```
92
92
 
93
- Post-implementation verification with three expert passes security, optimization, and traceability. Run after executing a feature or before finalizing.
93
+ A debugging loop you invoke when something is broken. Not a pipeline phase.
94
94
 
95
- ### 7. Diagnose (on demand)
95
+ ### Status (on demand)
96
96
 
97
97
  ```
98
- /skill:pwk-diagnose
98
+ /skill:pwk-status
99
99
  ```
100
100
 
101
- A 6-phase debugging loop you invoke when something is broken. Build a feedback loop first, then reproduce, hypothesise, instrument, fix, and cleanup. Not a pipeline phase — use whenever needed.
101
+ A read-only overview of all active design topics — which phase each is in and how far along. Use when resuming work or juggling several designs in parallel (e.g. across worktrees) and you're unsure which topic to continue. Not a pipeline phase.
102
102
 
103
103
  ## What the extension does
104
104
 
105
- The `workflow-guard` extension watches `write` and `edit` tool calls:
105
+ The `workflow-guard` extension watches `write`/`edit` and `bash` tool calls:
106
106
 
107
- - **During brainstorm and plan**: blocks writes outside `docs/plans/`. The agent can read code and use bash, but cannot modify source files.
108
- - **During verify**: same read-only enforcement — the agent can inspect code but not modify it.
109
- - **During execute and finalize**: no restrictions. All tools available.
107
+ - **During brainstorm and writing-plans**: blocks writes outside `docs/plans/`, and blocks destructive bash via a simple common-blacklist (a command is allowed unless it matches a destructive pattern). A short phase reminder is shown once when the gated phase begins so the model self-restricts.
108
+ - **During executing-tasks, code-review, finalizing**: no restrictions.
109
+ - **Phases are skill-driven**: the guard follows the skill you invoke — it never unlocks on message keywords. To override, run `/pwk-guard on` (force read-only), `off` (disable), or `auto` (default; skill-driven). Subcommands autocomplete.
110
110
 
111
- No configuration needed. It activates automatically after install.
112
-
113
- ## TDD guidance
111
+ The destructive blacklist covers common file-mutating vectors (redirects, `tee`, `cp`/`mv`/`touch`/`rm`, `git commit`/`apply`, `npm install`, in-place editors like `sed -i`/`perl -i`, `patch`, `find -delete`). Exotic vectors (interpreter escapes like `node -e`, `python -c`, `| bash`) rely on the phase reminder — the guard is advisory, not a security boundary.
114
112
 
115
- The plan labels each task with a TDD scenario:
113
+ No configuration needed. It activates automatically after install.
116
114
 
117
- | Scenario | When | Rule |
118
- |----------|------|------|
119
- | New feature | Adding new behavior | Write failing test → implement → pass |
120
- | Modifying tested code | Changing existing behavior | Run existing tests first → modify → verify |
121
- | Trivial | Config, docs, naming | Use judgment |
115
+ ## Test-first discipline
122
116
 
123
- This is guidance in the skill instructions, not runtime enforcement.
117
+ Plans specify *what* (acceptance criteria + integration tests); the executor writes the tests first (red), then implements to green. This keeps the spec stable — implementation details can change without invalidating the plan.
124
118
 
125
119
  ## Tips
126
120
 
127
- - Start with brainstorming for anything non-trivial
128
- - Use writing-plans before touching code for multi-step work
129
- - Put all plan artifacts under `docs/plans/`
130
- - During execute, the agent handles code review feedback by verifying criticism before implementing
121
+ - Start with brainstorming for anything non-trivial.
122
+ - The plan is a behavioral spec, not an implementation recipe — let the executor choose how.
123
+ - Each requirement has two mandatory checkpoints: use them to steer test design and implementation.
124
+ - Put all plan artifacts under `docs/plans/`; ADRs under `docs/adr/`.
package/docs/lessons.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Lessons Learned
2
2
 
3
3
  <!--
4
- Agent: read this at the start of each task during executing-tasks.
4
+ Agent: read this during brainstorm (design), writing-plans (acceptance criteria + tests), executing-tasks (per requirement), and finalizing (curation).
5
5
  Follow every rule. Add new rules when you catch yourself making repeat mistakes.
6
6
  Rules must be generic patterns applicable to any domain or feature — not specific to one service, entity, or use case.
7
7
  Retire rules that no longer apply during finalizing.
@@ -9,10 +9,5 @@ Retire rules that no longer apply during finalizing.
9
9
 
10
10
  ## Cross-Skill Consistency
11
11
 
12
- - When adding instructions that reference artifacts from another skill (e.g., "extract metadata from plan doc"), always add a guard for when that artifact doesn't exist — not all workflows use all artifacts
13
- - When reordering instructions within a step, verify all conditional branches still reference the correct context (e.g., hazard checks that say "this feature" must run after feature identification)
14
12
 
15
- ## Documentation
16
-
17
- - When adding a new phase to an extension, update ALL comments and error messages — stale comments in one place create confusion about the actual behavior
18
- - When renaming skills with a prefix, check for `/skill:` references in prose and code blocks separately — backtick-enclosed references in code examples may use a different pattern than prose references
13
+ ## Documentation
@@ -4,31 +4,35 @@
4
4
 
5
5
  ## Skills
6
6
 
7
- Skills teach the agent the workflow. There are 4:
7
+ Skills teach the agent the workflow. There are 5 pipeline skills:
8
8
 
9
- - **pwk-brainstorming** — explore ideas, produce a design doc with a Features table
10
- - **pwk-writing-plans** — plan one feature at a time from the Features table
11
- - **pwk-executing-tasks** — implement tasks, mark features done, loop to next feature
12
- - **pwk-finalizing** — archive docs, create PR
9
+ - **pwk-brainstorming** — explore ideas, produce a descriptive design doc that opens with a `## Requirements` list
10
+ - **pwk-writing-plans** — turn each requirement into acceptance criteria + integration-test cases (a behavioral spec, no implementation code)
11
+ - **pwk-executing-tasks** — implement requirement-by-requirement, test-first, with two mandatory human checkpoints per requirement
12
+ - **pwk-code-review** — the inline reviewer (code tracing, spec alignment, code smells, production hazards). During `pwk-executing-tasks`, per-requirement review instead runs **four specialized reviewers in parallel** via the `subagent` tool, each from a fresh context (spec gaps & scope creep, tracing, smells, hazards). These ship as package agents (`agents/pwk-*.md`) discovered natively by the optional **`pi-subagents`** package; all report findings only — fixes are applied by the executing-tasks main agent. Falls back to inline `/skill:pwk-code-review` when `pi-subagents` is not installed.
13
+ - **pwk-finalizing** — delete consumed plan docs, curate lessons, update docs, create PR or merge
13
14
 
14
- Plus 3 on-demand skills:
15
+ Plus 2 on-demand skills:
15
16
 
16
- - **pwk-design-review** — audit a plan doc for production risks (triggered by writing-plans)
17
- - **pwk-verify** — post-implementation verification with security, optimization, and traceability passes
18
- - **pwk-diagnose** — 6-phase debugging loop
17
+ - **pwk-status** — read-only overview of all active design topics (phase + progress), for resuming or juggling parallel designs
18
+ - **pwk-diagnose** — 6-phase debugging loop, invoked anytime something is broken
19
19
 
20
- They explain *what* to do and *when* to do it.
20
+ They explain *what* to do and *when* to do it. Phase control is manual — you invoke each skill with `/skill:`; the agent never advances on its own.
21
21
 
22
22
  ## Extension
23
23
 
24
24
  The `workflow-guard` extension enforces one rule:
25
25
 
26
- > During brainstorm, plan, and verify phases, `write` and `edit` are **hard-blocked** outside `docs/plans/`.
26
+ > During brainstorm and plan phases, `write` and `edit` are **hard-blocked** outside `docs/plans/`.
27
27
 
28
- The agent can still use `read` and `bash` for investigation. It literally cannot call `write` or `edit` on source files — the tools are blocked at the extension level.
28
+ The agent can still use `read` and `bash` for investigation. During those gated phases, `bash` is governed by a simple destructive-command blacklist (`rm`, `>`, `git commit`, `npm install`, in-place editors, etc.) a command is allowed unless it matches a destructive pattern. A short phase reminder is shown once when the gated phase begins so the model self-restricts.
29
+
30
+ During executing-tasks, code-review, and finalizing, nothing is restricted.
31
+
32
+ Phases follow the skill you invoke — there is no message-keyword unlock. `/pwk-guard on|off|auto` manually overrides the guard (`on` = force read-only lock, `off` = disabled, `auto` = skill-driven, the default); subcommands autocomplete.
29
33
 
30
34
  ## Enforcement style
31
35
 
32
- Hard block for write boundaries. No warnings, no escalation, no prompts. Either the tool call is allowed or it's blocked.
36
+ Hard block for write boundaries during gated phases. No warnings, no escalation, no prompts. Either the tool call is allowed or it's blocked.
33
37
 
34
- TDD, debugging, and code review are guidance in the skill instructions, not runtime-enforced.
38
+ TDD, checkpoints, debugging, and code review are guidance in the skill instructions, not runtime-enforced. The bash blacklist covers common destructive vectors only; exotic escapes (interpreter one-liners, piped shells) rely on the phase reminder — the guard is advisory, not a security boundary.