@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
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: pwk-finalizing
3
- description: "Use this after all tasks are complete to clean up, document, and ship the work."
3
+ description: "Use after all requirements are complete to delete consumed plan docs, curate lessons, update documentation, and ship the work."
4
4
  ---
5
5
 
6
6
  # Finalizing
@@ -9,86 +9,49 @@ Ship the completed work.
9
9
 
10
10
  ## Pre-finalization checks
11
11
 
12
- ### Check for skipped tasks
12
+ 1. **Run the FULL test suite.** Every test must pass. Resume spans sessions — don't assume the last execute session left the suite green. If anything fails, stop and send the user back to `/skill:pwk-executing-tasks` to fix; never archive or open a PR against a red suite.
13
13
 
14
- Before archiving, if a progress file exists (`docs/plans/*-progress.md`), read it and check for any `⏭ skipped` tasks. If found, warn:
14
+ 2. Read the progress file (`docs/plans/*-progress.md`). Check for failed or skipped rows:
15
15
 
16
- ```
17
- ⚠️ Tasks 4 and 7 were skipped. Continue with finalizing, or go back?
18
- ```
16
+ - **Any `❌ failed`** → **block**. Present the count and reasons to the user. Do not continue until one of:
17
+ - The user sends the task back to `/skill:pwk-executing-tasks` to fix the failures, or
18
+ - The user explicitly types `--force-failed` to acknowledge shipping with known incomplete requirements.
19
19
 
20
- Wait for the user to confirm before proceeding.
20
+ Never merge a branch that carries incomplete requirements without explicit acknowledgment.
21
21
 
22
- ## Process
23
-
24
- 1. **Move planning docs** — before archiving, check the design doc's `## Features` table (if one exists). If any features have status `⬜ pending` or `🔄 planned`, warn:
25
-
26
- ```
27
- ⚠️ Design doc has N unplanned features. Archive anyway, or go back to plan them?
28
- ```
22
+ - **Only `⏭ skipped`** (no `❌ failed`) → present a warning and confirm:
29
23
 
30
- Wait for the user to confirm before proceeding. Then archive the design, implementation, progress docs, and ADRs (if any), then commit:
31
- ```
32
- mkdir -p docs/plans/completed
33
- mkdir -p docs/plans/completed/adr
34
- mv docs/plans/*-design.md docs/plans/completed/ 2>/dev/null || true
35
- mv docs/plans/*-implementation.md docs/plans/completed/ 2>/dev/null || true
36
- mv docs/plans/*-progress.md docs/plans/completed/ 2>/dev/null || true
37
- mv docs/plans/*-verification-report.md docs/plans/completed/ 2>/dev/null || true
38
- mv docs/plans/adr/*.md docs/plans/completed/adr/ 2>/dev/null || true
39
- rmdir docs/plans/adr 2>/dev/null || true
40
- git add docs/plans/ && git commit -m "chore: archive planning docs"
41
- ```
24
+ ```
25
+ ⚠️ Requirement 4 was skipped. Continue with finalizing, or go back?
26
+ ```
42
27
 
43
- Each `mv` gracefully handles the case where no matching files exist (e.g., if the user skipped straight from brainstorm to finalize without executing tasks).
28
+ Continue on confirmation; abort otherwise.
44
29
 
45
- 2. **Review & Polish Lessons (Agile Scrum Master Hat)** — if `docs/lessons.md` exists, put on your **Agile Scrum Master Hat** to curate and optimize it for future sprints:
46
- - **Add missed lessons** — capture any lessons from this session that weren't written during execution
47
- - **Generalize domain-specific rules** — if a rule names a specific service, entity, or feature, either rewrite it as a generic pattern or remove it if no generic form exists
48
- - **De-duplicate** — combine overlapping or redundant rules into single, sharper entries
49
- - **Categorize** — group the rules under clear, structured markdown headers (e.g., `## Tool Usage`, `## Testing Patterns`, `## Architecture Rules`) to make the document highly scannable for future sessions. Keep the `## Rules` section as the append target for new entries during execution — categorization moves rules out of `## Rules` into the appropriate category headers.
50
- - **Retire stale rules** — remove bullets that no longer apply
51
- - If no changes are needed, leave it as-is
30
+ ## Process
52
31
 
53
- If `docs/lessons.md` doesn't exist but lessons were learned this session, create it with the standard format:
32
+ 1. **Derive the topic** — from the progress file → its `Plan:` ref → the plan's `Design:` ref the design-doc filename `<topic>`. If several designs are in flight and it's ambiguous, ask which is being shipped.
54
33
 
55
- ```markdown
56
- # Lessons Learned
34
+ 2. **Delete consumed plan docs** — only this design's artifacts; leave other (un-started) design docs in place:
57
35
 
58
- <!--
59
- Agent: read this at the start of each task during executing-tasks.
60
- Follow every rule. Add new rules when you catch yourself making repeat mistakes.
61
- Rules must be generic patterns applicable to any domain or feature — not specific to one service, entity, or use case.
62
- Retire rules that no longer apply during finalizing.
63
- -->
36
+ ```bash
37
+ rm -f docs/plans/*<topic>*-design.md
38
+ rm -f docs/plans/*<topic>*-implementation.md
39
+ rm -f docs/plans/*<topic>*-progress.md
40
+ ```
64
41
 
65
- ## Rules
42
+ Each `rm -f` gracefully handles a missing file. **Do not touch `docs/adr/`**, `docs/lessons.md`, `CHANGELOG.md`, or `README.md` — those are permanent.
66
43
 
67
- - <rule 1>
68
- - <rule 2>
69
- ```
44
+ 3. **Review & polish lessons (Agile Scrum Master Hat)** — if `docs/lessons.md` exists, curate it for future sprints: add missed lessons, generalize domain-specific rules into generic patterns, de-duplicate, categorize under clear headers, retire stale rules. If it doesn't exist but lessons were learned, create it with the standard format.
70
45
 
71
- 3. **Update documentation** — if the API or surface changed:
72
- - Update README.md
73
- - Update CHANGELOG.md
74
- - Update any inline docs
46
+ 4. **Update documentation** — if the API or surface changed: update `README.md`, `CHANGELOG.md`, and any inline docs.
75
47
 
76
- 4. **Choose a merge strategy** — ask the human which option they prefer:
48
+ 5. **Choose a merge strategy** — ask the human which they prefer:
77
49
 
78
50
  1. **Create PR** — push and open a PR for external review:
79
51
  ```
80
52
  git push origin <branch>
81
- gh pr create --title "feat: <summary>" --body "<task summary>"
82
- ```
83
-
84
- Use the progress file to generate the summary. Convert the task table to a bulleted list:
53
+ gh pr create --title "feat: <summary>" --body "<summary>"
85
54
  ```
86
- - ✅ Create User model
87
- - ✅ Write User model tests
88
- - ⏭ Add auth middleware (skipped)
89
- - ✅ Add login endpoint
90
- ```
91
-
92
55
  2. **Rebase & merge** *(recommended)* — rebase onto parent, fast-forward merge, push parent, delete branch:
93
56
  ```
94
57
  parent=$(git show-branch -a 2>/dev/null | grep '\*' | grep -v "$(git branch --show-current)" | head -1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//')
@@ -98,29 +61,18 @@ Wait for the user to confirm before proceeding.
98
61
  git push origin "$parent"
99
62
  git branch -d - && git push origin --delete -
100
63
  ```
64
+ 3. **Squash & merge** — squash all commits into one on parent, push, delete branch.
65
+ 4. **Merge commit** — merge with `--no-ff`, push parent, delete branch.
101
66
 
102
- 3. **Squash & merge** squash all commits into one on parent, push parent, delete branch:
103
- ```
104
- parent=$(git show-branch -a 2>/dev/null | grep '\*' | grep -v "$(git branch --show-current)" | head -1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//')
105
- git checkout "$parent" && git pull
106
- git merge --squash -
107
- git commit -m "feat: <summary>"
108
- git push origin "$parent"
109
- git branch -d - && git push origin --delete -
110
- ```
111
-
112
- 4. **Merge commit** — merge with `--no-ff`, push parent, delete branch:
113
- ```
114
- parent=$(git show-branch -a 2>/dev/null | grep '\*' | grep -v "$(git branch --show-current)" | head -1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//')
115
- git checkout "$parent" && git pull
116
- git checkout - && git merge --no-ff -m "Merge branch '<branch>'" -
117
- git push origin "$parent"
118
- git branch -d - && git push origin --delete -
119
- ```
67
+ For options 2–4, confirm the detected parent branch before proceeding.
120
68
 
121
- For options 2–4, confirm the detected parent branch with the human before proceeding.
122
-
123
- 5. **Clean up** — if a worktree was used, remove it:
69
+ 6. **Clean up** if a worktree was used, remove it:
124
70
  ```
125
- git worktree remove ../<repo>-<feature-name>
71
+ git worktree remove ../<repo>-<topic>
126
72
  ```
73
+
74
+ ## Principles
75
+
76
+ - Delete **only** the active design's artifacts — un-started designs (from a split) stay in `docs/plans/`.
77
+ - ADRs are never archived.
78
+ - Bump the package version if this is a published change (major bump for breaking changes).
@@ -0,0 +1,28 @@
1
+ ---
2
+ name: pwk-status
3
+ description: "Show all active pipeline topics and their phase/progress. Use when the user asks 'where are we', 'status', 'what's in flight', or when resuming and unsure which design to continue. Read-only discovery. Not a pipeline phase."
4
+ ---
5
+
6
+ # Status
7
+
8
+ Report on all in-flight pipelines (split designs may run in parallel across worktrees). Read-only.
9
+
10
+ ## Process
11
+
12
+ 1. Glob `docs/plans/*-design.md`, `*-implementation.md`, `*-progress.md`.
13
+ 2. For each `<topic>`, infer the furthest artifact present:
14
+ - only `*-design.md` → brainstorm done, plan next
15
+ - `*-implementation.md` but no progress → plan done, execute next
16
+ - `*-progress.md` → execute phase — show `done/total` requirement count
17
+ 3. Print a one-line table, e.g.:
18
+
19
+ ```
20
+ | Topic | Phase | Progress | Branch |
21
+ |---------|---------|----------|------------------|
22
+ | auth | execute | 2/3 done | auth |
23
+ | billing | plan | — | ../repo-billing |
24
+ ```
25
+
26
+ 4. If none, say so and suggest `/skill:pwk-brainstorming`.
27
+
28
+ Keep it short — this is orientation, not analysis. No writes; the `<topic>` slug is the identity.
@@ -1,358 +1,83 @@
1
1
  ---
2
2
  name: pwk-writing-plans
3
- description: "Use this to break a design into an implementation plan with bite-sized TDD tasks. Works with or without a prior brainstorm. Use this skill when the user says 'let's plan', 'break this down', 'write a plan', 'create tasks', or after a brainstorm session when they want to move to implementation. Also use when the user has a clear idea and wants to jump straight to a structured plan."
3
+ description: "Turn a design doc's requirements into a behavioral spec acceptance criteria + integration tests per requirement. Use after pwk-brainstorming, before pwk-executing-tasks. Use when the user says 'let's plan', 'write a plan', 'break this down', or after a brainstorm when ready to move to implementation."
4
4
  ---
5
5
 
6
6
  # Writing Plans
7
7
 
8
- You may only create or edit files under `docs/plans/`. Do not modify source code or configuration.
9
-
10
- ## Process
8
+ Turn the design doc's requirements into a **behavioral spec** the executor implements against.
11
9
 
12
- 1. **Check for a design doc** look for `docs/plans/*-design.md`. If one exists, use it as the basis for the plan. If the design doc is incomplete, fill gaps by asking the human. If no design doc exists, ask the user to describe what they want to build and read relevant code. **Read `docs/lessons.md`** if it exists — incorporate known patterns into the task breakdown (e.g., if a lesson says "always run lint before commit," include that in relevant task instructions).
10
+ One design doc = one plan = one PR. The plan lists **all** the design's requirements; the executor builds them one at a time, in the order you list them (see **Ordering** below).
13
11
 
14
- If the design doc has a `## Features` table, read it to identify the next feature with status `⬜ pending`. Mark that feature as `🔄 planned` by editing the design doc. This plan will cover only that one feature. If the design doc has no Features table, plan the entire design as before.
12
+ You may only create or edit files under `docs/plans/`. Do not modify source code or configuration.
15
13
 
16
- Then evaluate whether the feature — whether from the design doc or from the user's description and codebase exploration — involves any of the following:
14
+ ## Process
17
15
 
18
- - Database schema changes or migrations
19
- - Authentication or authorization logic
20
- - External API or service integrations
21
- - Concurrency or batch processing
22
- - File uploads or large data flows
23
- - Redis, caching, or message queues
16
+ 1. **Find the design doc** — look for `docs/plans/*-design.md`. (For a full multi-topic overview when several are in flight, use `/skill:pwk-status`.) If none, ask the user to run `/skill:pwk-brainstorming` first. If several exist (a large issue was split), list them and ask which to plan. **Read `docs/lessons.md`** if it exists — incorporate known patterns into the acceptance criteria and tests.
17
+ 2. **Create the feature branch first** — `git checkout -b <topic>` (branch creation is allowed in the plan phase). The design + plan docs are written on this branch (committed at the start of `pwk-executing-tasks`), not `main`.
18
+ 3. **Read the Requirements** the design doc opens with a `## Requirements` list; each requirement is one testable behavior the user will get. This plan covers **all** requirements in the design doc (one pipeline per design doc). If the design has no Requirements list, derive the requirements from its described behaviors and confirm them with the human before proceeding.
24
19
 
25
- If any apply, prompt the user: "This feature involves [list what you found] but hasn't been reviewed for production risks. Run `/skill:pwk-design-review` first, or type 'proceed' to skip."
20
+ 4. **Write the plan acceptance criteria + integration tests per requirement.** For each requirement specify:
21
+ - **Acceptance criteria** — `Given/When/Then` behavioral statements that define "done" for that requirement.
22
+ - **Integration tests** — the concrete test cases that encode the acceptance criteria: a test name and what each asserts. This is the spec the executor writes and implements against.
23
+ - **Challenge the design first** *(if `## Production-risk areas` exists)* — before writing acceptance criteria, stress-test the design against the flagged risks: ask the uncomfortable "what breaks under load / on failure / on bad input" questions and confirm the approach holds. If a risk invalidates a design choice, stop and return to `/skill:pwk-brainstorming` rather than planning around a flawed design.
24
+ - **Ordering** — list requirements in the order they should be built. If a requirement depends on another, the dependency must come **earlier in the list**; the executor runs requirements in listed order and does not reorder. Aim for each requirement to be a vertical slice that merges cleanly on its own — if a dependency can't be sliced away, position resolves it (there is no parsed dependency graph).
25
+ - **Production-risk notes** *(if the design flagged any in `## Production-risk areas`)* — carried forward so the executor and `pwk-code-review` account for them.
26
26
 
27
- If the design doc explicitly notes "Simple change — no design review needed", skip this check.
28
- 2. **Write the implementation plan** — break the feature into tasks. Save to `docs/plans/YYYY-MM-DD-<topic>-<feature-name>-implementation.md` (derive `<feature-name>` from the feature's name in the table, slugified). If the design doc has no Features table, use `docs/plans/YYYY-MM-DD-<topic>-implementation.md`. Include metadata at the top of the plan doc so the executor can find the design doc and feature row:
27
+ Save to `docs/plans/YYYY-MM-DD-<topic>-implementation.md`:
29
28
 
30
29
  ```markdown
31
- # Implementation Plan: <feature name>
30
+ # Implementation Plan: <topic>
32
31
 
33
32
  ## Overview
34
-
35
33
  Design: docs/plans/YYYY-MM-DD-<topic>-design.md
36
- Feature: <feature name> (row N in Features table)
37
- ```
38
-
39
- If the design is too large for ~15 tasks for a single feature, flag this to the human and ask whether to reduce scope or proceed with the full plan.
40
- 3. **Present the plan** — show the complete plan to the human. Wait for approval before suggesting execution.
41
-
42
- Before presenting, run the **Plan Acceptance Audit**:
43
- - **Vertical Slices**: Is every task a complete vertical slice (not horizontal)?
44
- - **Task Sizing**: Is any single task too large or covering multiple complex behaviors? If so, split it.
45
- - **QA Coverage**: Does every task have both a Happy Path and at least one Edge Case in its Acceptance Criteria?
46
- - **Checkpoint Alignment**: Are `checkpoint: test` and `checkpoint: done` gates placed on the most critical or risky tasks?
47
- - **Risk Enforcement**: If this plan doc's Architectural Review section flagged any hazards as `[TRIGGERED]`, verify the corresponding tasks have `checkpoint: done` and a `Hazard Mitigation Verification` section.
48
-
49
- If any check fails, fix the plan before presenting.
50
-
51
- ## Task format
52
-
53
- Each task should produce one testable change. The executing-tasks skill handles committing — do not include `git commit` in the task body.
54
-
55
- Each task must include:
56
- - Exact file paths to create/modify
57
- - **Acceptance Criteria (QA Engineer Hat)** — Put on your **QA Engineer Hat** to design exhaustive test coverage. Explicitly define:
58
- - **Happy Path**: Expected behavior under normal operations.
59
- - **Edge Cases & Error Paths**: What happens with empty inputs, limits exceeded, authentication failures, or error states.
60
- Ensure every criteria block specifies the expected state and returned results using `Given/When/Then` behavioral blocks.
61
- - **Concrete code** — include the actual implementation, not a summary. Write out SQL schemas, type definitions, function signatures with bodies, route handler code, and test assertions. A developer should be able to copy-paste from the plan and have working code. For tasks that depend on types or utilities from earlier tasks, reference them explicitly (e.g., `import { User } from Task 2`) and include only the new code
62
- - Exact commands with expected output (e.g., `npx vitest run src/user/model.test.ts` → shows 1 test passing)
63
-
64
- Each task must use a numbered heading with optional metadata comments:
65
-
66
- ```markdown
67
- ## Task N: <description>
68
-
69
- <!-- tdd: new-feature -->
70
- ```
71
-
72
- ...where N starts at 1 and incrementally numbers each task in the plan.
73
-
74
- The metadata comments (placed right after the heading) are optional. If omitted, the executing-tasks skill infers the TDD scenario and checkpoint from context. When in doubt, include them explicitly.
75
-
76
- Valid TDD values: `new-feature`, `modifying-tested-code`, `trivial`
77
-
78
- Valid checkpoint values: `none`, `test`, `done`
79
-
80
- ### Level of detail
81
-
82
- This is the #1 thing to get right. The plan is not a high-level outline — it's a detailed recipe that the executing-tasks skill will follow step by step. If you write "implement login handler" without showing the code, the executing agent has to guess, and that defeats the purpose of the plan.
83
-
84
- Think of it this way: the plan author (you, now) has the full design context, the domain model, and the architecture in mind. The plan executor (a future agent session) will have none of that context — just the plan file. Write accordingly.
85
-
86
- **What "concrete code" means in practice:**
87
- - SQL: `CREATE TABLE` statements with all columns, types, and constraints
88
- - Types/interfaces: full type definitions with fields
89
- - Functions: signature + body (the logic, not just the name)
90
- - Tests: concrete assertions (`expect(result.status).toBe(409)`) not descriptions ("test that it returns an error")
91
- - Routes: the actual handler code with validation, error handling, and response format
92
- - Config: exact values, not "configure appropriately"
93
-
94
- **Bad** (too vague — the executor must guess):
95
- ```
96
- 3. Implement bookmark model
97
- ```
98
-
99
- **Good** (executor can copy-paste):
100
- ```
101
- 3. Implement `src/db/bookmarks.ts`:
102
-
103
- ```ts
104
- import db from '../db.js';
105
-
106
- export function createBookmarksTable() {
107
- db.exec(`
108
- CREATE TABLE IF NOT EXISTS bookmarks (
109
- id TEXT PRIMARY KEY,
110
- userId TEXT NOT NULL,
111
- messageId TEXT NOT NULL,
112
- createdAt TEXT DEFAULT (datetime('now')),
113
- UNIQUE(userId, messageId)
114
- )
115
- `);
116
- }
117
-
118
- export function insertBookmark(userId: string, messageId: string) {
119
- const id = crypto.randomUUID();
120
- db.prepare('INSERT INTO bookmarks (id, userId, messageId) VALUES (?, ?, ?)').run(id, userId, messageId);
121
- return { id, userId, messageId };
122
- }
123
- ```
124
- ```
125
-
126
- ### Task body structure
127
-
128
- The examples below show the structure — headings, metadata comments, checkpoints, and step numbering. For the code content within steps, follow the detail level described above.
129
-
130
- **No checkpoint** — numbered steps only:
131
- ```markdown
132
- ## Task 1: Create User model
133
-
134
- <!-- tdd: new-feature -->
135
-
136
- Acceptance Criteria (QA Engineer Hat):
137
- - **Happy Path**:
138
- - Given: Valid user data with name and email
139
- - When: The User model is created
140
- - Then: The model contains the correct fields and a generated ID
141
- - **Edge Case (duplicate email)**:
142
- - Given: A user with email "test@example.com" already exists
143
- - When: Another user is created with the same email
144
- - Then: Creation fails with a unique constraint error
145
-
146
- Files:
147
- - `src/user/model.ts`
148
- - `src/user/model.test.ts`
149
-
150
- Steps:
151
- 1. Write failing test for User model creation
152
- 2. Run test — confirm it fails
153
- 3. Implement User model
154
- 4. Run test — confirm it passes
155
- ```
156
-
157
- **`checkpoint: test`** — gate after test, before implementing:
158
- ```markdown
159
- ## Task 2: Write auth tests
160
-
161
- <!-- tdd: new-feature -->
162
- <!-- checkpoint: test -->
163
-
164
- Acceptance Criteria (QA Engineer Hat):
165
- - **Happy Path**:
166
- - Given: A user with valid credentials exists
167
- - When: Login is attempted
168
- - Then: A valid session token is returned
169
- - **Edge Case (wrong password)**:
170
- - Given: A user exists but password is incorrect
171
- - When: Login is attempted
172
- - Then: An authentication error is returned
173
34
 
174
- Files:
175
- - `src/auth/login.test.ts`
35
+ ## Requirement 1: <name>
176
36
 
177
- Steps:
178
- 1. Write failing test for login with valid credentials
179
- 2. Run test confirm it fails
37
+ ### Acceptance criteria
38
+ - Given When Then
39
+ - Given When Then … (edge cases)
180
40
 
181
- **CHECKPOINT: test** — present test review. Wait for human approval before implementing.
41
+ ### Integration tests
42
+ - `should <behavior>` — asserts <observable outcome>
43
+ - `should <error case>` — asserts <failure outcome>
182
44
 
183
- 3. Implement login handler
184
- 4. Run test confirm it passes
185
- 5. Refactor — check for shallow modules, duplication, seam discipline. Run tests after changes.
186
- 6. Lessons — caught a mistake that applies to future tasks? Add rule to `docs/lessons.md`.
187
- ```
45
+ ### Production-risk notes
46
+ - <from the design's Production-risk areas, if any>
188
47
 
189
- **`checkpoint: done`** gate after all steps including refactor/lessons:
190
- ```markdown
191
- ## Task 3: Add login endpoint
192
-
193
- <!-- tdd: new-feature -->
194
- <!-- checkpoint: done -->
195
-
196
- Acceptance Criteria (QA Engineer Hat):
197
- - **Happy Path**:
198
- - Given: A user with email "user@example.com" and password "secure123" exists
199
- - When: A POST request with those credentials is sent to `/api/login`
200
- - Then: Response returns `200 OK` with a signed JWT token
201
- - **Edge Case (invalid password)**:
202
- - Given: A user exists but the password sent is "wrong-pass"
203
- - When: A POST request is sent to `/api/login`
204
- - Then: Response returns `401 Unauthorized`
205
- - **Edge Case (rate limiting)**:
206
- - Given: 5 failed login attempts from the same IP
207
- - When: A 6th attempt is sent
208
- - Then: Response returns `429 Too Many Requests`
209
-
210
- Files:
211
- - `src/auth/login.ts`
212
- - `src/auth/login.test.ts`
213
-
214
- Steps:
215
- 1. Write failing test for login with valid credentials
216
- 2. Run test — confirm it fails
217
- 3. Implement login handler
218
- 4. Run test — confirm it passes
219
- 5. Add edge case tests (invalid password, missing email)
220
- 6. Refactor — check for shallow modules, duplication, seam discipline. Run tests after changes.
221
- 7. Lessons — caught a mistake that applies to future tasks? Add rule to `docs/lessons.md`.
222
-
223
- ⏸ **CHECKPOINT: done** — present implementation review. Wait for human approval before committing.
224
- ```
225
-
226
- **Both checkpoints** — gate after test, then gate after refactor/lessons:
227
- ```markdown
228
- ## Task 4: Complex auth flow
229
-
230
- <!-- tdd: new-feature -->
231
- <!-- checkpoint: test -->
232
- <!-- checkpoint: done -->
233
-
234
- Acceptance Criteria (QA Engineer Hat):
235
- - **Happy Path**:
236
- - Given: A valid OAuth2 authorization code
237
- - When: The auth callback is invoked
238
- - Then: A user session is created and the user is redirected to the dashboard
239
- - **Edge Case (expired code)**:
240
- - Given: An expired or invalid authorization code
241
- - When: The auth callback is invoked
242
- - Then: The user is redirected to login with an error message
243
-
244
- Steps:
245
- 1. Write failing test for auth flow
246
- 2. Run test — confirm it fails
247
-
248
- ⏸ **CHECKPOINT: test** — present test review. Wait for human approval before implementing.
249
-
250
- 3. Implement auth flow
251
- 4. Run test — confirm it passes
252
- 5. Refactor — check for shallow modules, duplication, seam discipline. Run tests after changes.
253
- 6. Lessons — caught a mistake that applies to future tasks? Add rule to `docs/lessons.md`.
254
-
255
- ⏸ **CHECKPOINT: done** — present implementation review. Wait for human approval before committing.
256
- ```
257
-
258
-
259
- ## Vertical slices
260
-
261
- Each task should be a **vertical slice** — a thin path through ALL relevant layers end-to-end, delivering one complete piece of observable behavior.
262
-
263
- ```
264
- WRONG (horizontal):
265
- Task 1: Create database schema for users
266
- Task 2: Write user API endpoints
267
- Task 3: Build user UI components
268
- Task 4: Wire everything together
269
-
270
- RIGHT (vertical):
271
- Task 1: User can sign up (model + endpoint + validation + test)
272
- Task 2: User can log in (auth check + token + test)
273
- Task 3: User can view profile (query + endpoint + test)
274
- ```
275
-
276
- Order tasks so each one can be verified independently and delivers a complete vertical slice. If a task requires infrastructure (models, types) that no previous task has created, include it in that task — don't create it as a separate task.
48
+ ## Requirement 2: <name>
49
+
50
+ ```
277
51
 
278
- Vertical slices ensure every committed task leaves the codebase in a testable state and reduces the blast radius of a bad task.
52
+ **If the design has `## Production-risk areas`** that flag schema migrations, new dependencies, external API integrations, or seed data, emit a `## Setup` section between `## Overview` and `## Requirement 1`:
279
53
 
280
- ## TDD in the plan
54
+ ```markdown
55
+ ## Setup
281
56
 
282
- Label each task with its TDD scenario:
57
+ - **Dependencies:** what to install (and how)
58
+ - **Migrations:** each migration with a brief description
59
+ - **Seed / test data:** what data to prepare
60
+ - **Verify:** how to confirm setup worked (e.g. `npm test` still passes)
61
+ ```
283
62
 
284
- | Scenario | When | Instructions in the task |
285
- |---|---|---|
286
- | **New feature** | Adding new behavior | Write failing test → run it → implement → run it |
287
- | **Modifying tested code** | Changing existing behavior | Run existing tests first → modify → verify they pass |
288
- | **Trivial** | Config, docs, naming | Use judgment |
63
+ 5. **Before presenting audit the spec:**
64
+ - Every requirement has acceptance criteria **and** matching integration tests.
65
+ - Acceptance criteria are observable behaviors, not implementation steps.
66
+ - Edge/error cases are covered.
67
+ - Production-risk areas from the design are reflected.
68
+ Fix gaps before presenting.
289
69
 
290
- ## Checkpoint labels
70
+ 6. **Set up workspace isolation** *(before approving)* — you're already on the `<topic>` feature branch (step 2); the design + plan docs live here, not on `main` (committed at the start of `pwk-executing-tasks`). For larger work, offer a worktree (`git worktree add ../<repo>-<topic> <topic>`) and hand off to a new session there so `pwd` is the worktree. Wait for the user's choice.
71
+ 7. **Present the plan** — show the complete plan and wait for approval. On approval, hand off to `/skill:pwk-executing-tasks` — running it is what transitions out of the gated plan phase (the guard unlocks on the skill, not on the word "approve").
291
72
 
292
- Label each task with a `checkpoint` to require human review before proceeding. The checkpoint gate (`⏸ CHECKPOINT`) goes in the task body — the agent follows the plan step by step and pauses when it reaches the gate.
73
+ ## What the plan is NOT
293
74
 
294
- | Checkpoint | When to use | What the plan should include |
295
- |---|---|---|
296
- | *(none)* | Trivial tasks, well-understood changes | Numbered steps only |
297
- | **`checkpoint: test`** | Test design matters (API contracts, edge cases, complex behavior) | Steps up to test → `⏸ CHECKPOINT: test` → implement steps (including refactor/lessons) |
298
- | **`checkpoint: done`** | Implementation review matters (complex logic, security, performance) | Steps (including refactor/lessons) → `⏸ CHECKPOINT: done` |
299
- | Both | Non-obvious tests AND complex logic | Steps up to test → `⏸ CHECKPOINT: test` → implement steps (including refactor/lessons) → `⏸ CHECKPOINT: done` |
75
+ - **Not an implementation recipe** no exact code, no file-by-file breakdowns, no signatures, no stubs. (A fine-grained implementation plan invalidates the moment a detail shifts; acceptance criteria + integration tests survive implementation changes.)
76
+ - **Not micro-tasks** — one coarse block per requirement. The executor decides how to structure and slice the implementation.
77
+ - **Not the tests themselves** — the plan specifies *what* the tests prove (names + assertions); `pwk-executing-tasks` writes the actual test files first (red), then implements to green.
300
78
 
301
- Use judgment when assigning checkpoints. Prefer `checkpoint: test` for new features with non-obvious test design. Prefer `checkpoint: done` for tasks where the implementation approach is debatable. Most tasks should not need a checkpoint. The user can adjust checkpoints when reviewing the plan.
79
+ The executor has **full autonomy** to choose structure, signatures, and internals bounded only by the acceptance criteria and the two mandatory checkpoints per requirement (after integration tests are written, and after the requirement is complete), enforced by `pwk-executing-tasks`.
302
80
 
303
81
  ## After the plan
304
82
 
305
- Ask: "Ready to execute? Run `/skill:pwk-executing-tasks`"
306
-
307
- > After executing this feature, the executor will check for more `⬜ pending` features and suggest planning the next one.
308
-
309
- ## Behavioral Guidelines
310
-
311
- Guidelines to reduce overcomplication and hidden assumptions in plans. Derived from [Andrej Karpathy's observations](https://x.com/karpathy/status/2015883857489522876) on LLM coding pitfalls, adapted for the planning context.
312
-
313
- **Tradeoff:** These guidelines bias toward caution over speed. For trivial plans (1-2 tasks), use judgment.
314
-
315
- ### Surface Assumptions
316
-
317
- **When the design is ambiguous, annotate — don't silently pick.**
318
-
319
- When writing a plan, you'll encounter gaps: the design says "paginated" but doesn't specify how, says "validate input" but doesn't say which fields, or leaves the data layer unspecified. Your instinct will be to fill the gap and keep writing. Resist that.
320
-
321
- Instead, add a brief `> **Assumption:** ...` note in the plan at the point where you made the call:
322
-
323
- ```
324
- > **Assumption:** Using offset/limit pagination because the design just says
325
- > "paginated". Cursor-based would be better for large datasets.
326
- ```
327
-
328
- ```
329
- > **Assumption:** No service layer — handler calls store directly. Add one
330
- > if cross-cutting concerns (logging, auth checks) emerge later.
331
- ```
332
-
333
- This lets the reviewer see what you chose and why, without blocking progress. Common gaps worth annotating:
334
- - Pagination style, error handling strategy, concurrency model
335
- - Whether to add a service/middleware layer
336
- - Whether to add external dependencies
337
- - Naming conventions when the design doesn't specify
338
-
339
- ### Build Only What Each Task Needs
340
-
341
- **Minimum code to deliver the task's observable behavior. Nothing more.**
342
-
343
- - No interface methods that no task exercises yet. If Task 2 creates a `Store` interface, it should have only the methods Task 2 calls. Add methods in the task that first needs them.
344
- - No layers (service, middleware, repository) unless the design explicitly requires them.
345
- - No error types, helper files, or shared packages until a task actually uses them.
346
- - No external dependencies when stdlib suffices. Every `go get` or `npm install` is a choice — default to no.
347
- - No "flexible" or "configurable" code that wasn't requested.
348
-
349
- If you find yourself writing a store with 4 methods where only 1 is used in this task, stop. Write 1 method. Add the rest when the tasks that need them arrive.
350
-
351
- ### One Task, One Change
352
-
353
- **Each task should trace to exactly one user-facing behavior.**
354
-
355
- - If a task creates more than 4 new files, it's probably doing too much — split it.
356
- - If a task modifies existing files unrelated to its acceptance criteria, trim the scope.
357
- - Infrastructure (types, interfaces, module scaffolding) should live in the same task as the first code that uses it, not in a separate "setup" task — unless the infrastructure alone is complex enough to warrant its own task.
358
- - Every file listed in a task's `Files:` section should be directly necessary for that task's acceptance criteria to pass.
83
+ Ask: "Ready to execute? Run `/skill:pwk-executing-tasks`"