@tianhai/pi-workflow-kit 0.17.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 (67) hide show
  1. package/README.md +91 -64
  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 +49 -37
  7. package/docs/lessons.md +13 -0
  8. package/docs/oversight-model.md +19 -9
  9. package/docs/workflow-phases.md +58 -29
  10. package/extensions/workflow-guard.ts +190 -91
  11. package/package.json +19 -3
  12. package/skills/pwk-brainstorming/SKILL.md +60 -0
  13. package/skills/pwk-code-review/SKILL.md +46 -0
  14. package/skills/{diagnose → pwk-diagnose}/SKILL.md +3 -2
  15. package/skills/pwk-executing-tasks/SKILL.md +154 -0
  16. package/skills/pwk-finalizing/SKILL.md +78 -0
  17. package/skills/pwk-status/SKILL.md +28 -0
  18. package/skills/pwk-writing-plans/SKILL.md +83 -0
  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/skills/brainstorming/SKILL.md +0 -48
  63. package/skills/design-review/SKILL.md +0 -113
  64. package/skills/executing-tasks/SKILL.md +0 -350
  65. package/skills/finalizing/SKILL.md +0 -119
  66. package/skills/verify/SKILL.md +0 -170
  67. package/skills/writing-plans/SKILL.md +0 -343
@@ -1,5 +1,5 @@
1
1
  ---
2
- name: diagnose
2
+ name: pwk-diagnose
3
3
  description: "Disciplined debugging loop for hard bugs and performance regressions. Use when a test fails unexpectedly, a bug is found during execution, or something is broken. Use this skill whenever the user reports a bug, says 'this doesn't work', 'something's wrong', 'help me debug', or when tests fail for unclear reasons. Works at any point in the workflow — brainstorm, execute, or standalone."
4
4
  ---
5
5
 
@@ -53,4 +53,5 @@ Required before declaring done:
53
53
  - Regression test passes (or absence of seam is documented)
54
54
  - All `[DEBUG-...]` instrumentation removed
55
55
  - Ask: what would have prevented this bug?
56
- - If the bug was caused by an architectural problem (no good test seam, tangled callers, hidden coupling), suggest writing an ADR to `docs/plans/adr/` capturing that insight
56
+ - If the answer is a repeatable pattern, append a **generic** rule to `docs/lessons.md` (strip domain specifics) so future sessions catch it early.
57
+ - If the bug was caused by an architectural problem (no good test seam, tangled callers, hidden coupling), suggest writing an ADR to `docs/adr/` capturing that insight
@@ -0,0 +1,154 @@
1
+ ---
2
+ name: pwk-executing-tasks
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
+ ---
5
+
6
+ # Executing Tasks
7
+
8
+ Implement the plan from `docs/plans/*-implementation.md` requirement-by-requirement, with file-based progress tracking.
9
+
10
+ The plan is a **behavioral spec** (acceptance criteria + integration tests). You have **full autonomy** to choose structure, signatures, and internals — the acceptance criteria and integration tests define *what*; you decide *how*. Do not ask the plan for implementation steps; it deliberately doesn't contain them.
11
+
12
+ ## Before you start
13
+
14
+ 1. **Check git state** — `git status` and `git log --oneline -5`. Note uncommitted changes.
15
+ 2. **Find the plan + report** — look for `docs/plans/*-implementation.md`. If several, list them and ask which. Print a one-line discovery report, e.g. `Found: design "auth" — execute phase (1/3 requirements done)`. If a matching `*-progress.md` exists, this is a **resume** (see [Resume](#resume)).
16
+ 3. **Workspace isolation should already be done** — `pwk-writing-plans` set up the branch/worktree before handoff. If you land here still on `main`, tell the user the workspace wasn't set up and suggest doing it before executing.
17
+
18
+ ## First run
19
+
20
+ 1. **Parse the plan** — read all `## Requirement N:` headings. Build the progress table with all requirements as `⬜ pending`. Process them in **listed order** — the plan is already in build order; do not reorder.
21
+ 2. **Setup pre-flight** — if the plan has a `## Setup` section, follow it: install dependencies, apply migrations, and seed data. Run the existing test suite to confirm nothing broke. **⏸ CHECKPOINT: setup** — present the migration/output to the human and wait for approval.
22
+ - **approve** → continue.
23
+ - **request changes** → revise and re-present.
24
+ (Only runs on the first `First run` — the progress file is created after this step, so a resumed session skips setup.)
25
+ 3. **Create the progress file** at `docs/plans/<plan-name>-progress.md`:
26
+
27
+ ```markdown
28
+ # Progress: <topic>
29
+
30
+ Plan: docs/plans/YYYY-MM-DD-<topic>-implementation.md
31
+ Branch: <branch>
32
+ Started: <ISO timestamp>
33
+ Last updated: <ISO timestamp>
34
+
35
+ | # | Status | Requirement | Commit |
36
+ |---|--------|-------------|--------|
37
+ | 1 | ⬜ pending | <requirement name> | — |
38
+ ```
39
+ 4. **Commit the plan docs** — `git add docs/plans/ && git commit -m "docs: add implementation plan"`.
40
+ 5. Begin requirement 1 (see [Per-requirement execution](#per-requirement-execution)).
41
+
42
+ ## Resume
43
+
44
+ 1. Read the progress file. Find the first requirement that is `⬜ pending`, `🔄 in-progress`, `⏸ tests-review`, or `⏸ complete-review`.
45
+ 2. Resume from the recorded state:
46
+ - `⏸ tests-review` / `⏸ complete-review` → re-present that checkpoint and wait.
47
+ - `🔄 in-progress` mid-write → continue the requirement.
48
+ - `⬜ pending` → start it.
49
+
50
+ ## Progress file
51
+
52
+ Path: `docs/plans/<plan-name>-progress.md`. Update the matching row directly (not via pattern matching that could corrupt the table). Update `Last updated` on every change.
53
+
54
+ | Status | Meaning |
55
+ |--------|---------|
56
+ | `⬜ pending` | Not started |
57
+ | `🔄 in-progress` | Writing tests or implementing |
58
+ | `⏸ tests-review` | Paused at checkpoint: tests, awaiting human approval |
59
+ | `⏸ complete-review` | Paused at checkpoint: complete, awaiting human approval |
60
+ | `🔎 review` | Committed; `pwk-code-review` in progress |
61
+ | `✅ done` | `pwk-code-review` complete (smells fixed, hazards noted), all green |
62
+ | `❌ failed` | Could not complete; partial work discarded/reverted (append `Failed: <reason>`) |
63
+ | `⏭ skipped` | User chose to skip |
64
+
65
+ ## Per-requirement execution
66
+
67
+ For each requirement:
68
+
69
+ 1. **Mark in-progress** — `🔄 in-progress`.
70
+ 2. **Write the integration tests (red).** Read the requirement's acceptance criteria + integration-test cases from the plan and write the actual test files. Run them — confirm they **fail** (red). If they pass immediately, the behavior may already exist or the tests are wrong; investigate before proceeding.
71
+ 3. **⏸ CHECKPOINT: tests.** Stop. Do not implement yet. Mark `⏸ tests-review`. Present the integration tests and the failing output to the human, and wait for approval. The human reviews whether the right behaviors are being specified.
72
+ - **approve** → return to `🔄 in-progress` and continue.
73
+ - **request changes** → revise the tests, re-run, re-present.
74
+ 4. **Implement (green).** With full autonomy, implement whatever is needed to make the integration tests pass and satisfy the acceptance criteria — you choose the structure, modules, signatures, and internals. Run the tests after each meaningful change. Refactor for clarity (shallow modules, no duplication, seam discipline) while tests stay green.
75
+ 5. **Learn.** If you caught a repeat mistake, append a **generic** rule to `docs/lessons.md` (strip domain specifics).
76
+ 6. **⏸ CHECKPOINT: complete.** Stop. Do **not** commit yet. Mark `⏸ complete-review`. Run the tests (show passing output) and `git diff`, present the implementation to the human, and wait for approval.
77
+ - **approve** → return to `🔄 in-progress` and continue.
78
+ - **request changes** → revise, re-run, re-present at this same checkpoint.
79
+ 7. **Commit.** `git add` the relevant files and commit with a clear message. (Status stays `🔄 in-progress` — not done yet.)
80
+ 8. **Code review.** Mark `🔎 review`. Attempt isolated code-review via the `subagent` tool — four agents review the same diff in parallel, each from a different dimension (each gets a fresh context window, zero pollution from previous requirements):
81
+
82
+ Gather the requirement's scope: acceptance criteria, integration test cases, and git diff (`git log --oneline -5 && git diff HEAD~N..HEAD`).
83
+
84
+ **If the `subagent` tool is available**, invoke it with parallel tasks:
85
+ ```json
86
+ {
87
+ "tasks": [
88
+ {"agent": "pwk-spec-reviewer", "task": "<scope + diff here>\n\n## Spec Review\nFor each acceptance criterion, point to the code and test that satisfy it. Flag gaps (criterion with no covering code or test) and scope creep (code beyond criteria). Report only — do not modify files. Your findings are collected by the parent agent which applies fixes and commits changes."},
89
+ {"agent": "pwk-tracing-reviewer", "task": "<scope + diff here>\n\n## Trace Review\nTrace every new/changed code path end-to-end against tests. Note untested branches, dead branches, paths where the trace breaks. Report only — do not modify files. Your findings are collected by the parent agent which applies fixes and commits changes."},
90
+ {"agent": "pwk-smell-reviewer", "task": "<scope + diff here>\n\n## Smell Review\nReport: shallow modules (interface ≈ implementation complexity), duplication, missing seams / premature abstraction, poor naming, magic values, dead code. Flag only: smells requiring risky large refactors. Report only — do not modify files. Your findings are collected by the parent agent which applies fixes and commits changes."},
91
+ {"agent": "pwk-hazard-reviewer", "task": "<scope + diff here>\n\n## Hazard Review\nAudit changed code against these hazards: unbounded ops (KEYS/SCAN/full-table loads), missing indexes, unbounded concurrency (Promise.all without limits), long-running transactions, query/command interpolation (injection), unrestricted uploads/temp flooding, silent swallowing loops. Write [SAFE] (1-line reason) or [TRIGGERED] (mitigation). Report only — do not modify files. Your findings are collected by the parent agent which applies fixes and commits changes."}
92
+ ],
93
+ "agentScope": "both",
94
+ "cwd": "<repo-root>"
95
+ }
96
+ ```
97
+
98
+ **On success:** collect all findings. For smell-review findings: identify the smells, apply the fixes yourself (re-run integration tests after changes — must stay green, commit). For trace/spec/hazard findings: flag as follow-ups for human decision or later fix. Update the progress-file row to `✅ done`. Flag non-trivial issues as follow-ups.
99
+
100
+ **Fallback** (subagent unavailable or returns error): revert to inline review — run `/skill:pwk-code-review` for this requirement as before.
101
+ 9. **Loop** — go to step 1 for the next `⬜ pending` requirement, or see [After all requirements](#after-all-requirements).
102
+
103
+ ### Checkpoint gates are mandatory
104
+
105
+ Both checkpoints are **hard stops, not optional**. When you reach one:
106
+ - Stop executing immediately. Do not pass it without explicit human approval.
107
+ - **Never** `git add` or `git commit` before the human approves at a checkpoint.
108
+ - Mark the progress file to the review status **before** pausing.
109
+
110
+ ## User override commands
111
+
112
+ | User says | Agent does |
113
+ |-----------|-----------|
114
+ | `skip` | Mark current requirement `⏭ skipped`, move to next |
115
+ | `status` | Show the progress table |
116
+ | `stop` | Restore current requirement to its pre-in-progress state, suggest `/new` to resume later |
117
+ | `retry` | Re-read the requirement, start over |
118
+
119
+ ## Receiving feedback (outside a checkpoint)
120
+
121
+ When the user shares review feedback outside a checkpoint: verify the criticism against the code, evaluate the suggestion, then implement (with tests) or push back with evidence. Don't blindly apply.
122
+
123
+ ## After all requirements
124
+
125
+ When no `⬜ pending` or `❌ failed` requirements remain, run the **integration gate** before suggesting finalize. Per-requirement code-review only saw each requirement's diff in isolation — this is where you prove the requirements *compose* into the feature:
126
+
127
+ 1. **Run the FULL test suite** (not just the last requirement's tests). Every test must pass. A failure here means one requirement regressed another — fix it now, in execute context, while the progress file and fix autonomy are at hand.
128
+ 2. **Confirm the requirements compose** into the feature the design doc described. Each requirement passed alone; do they deliver the intended end-to-end behavior *together*? If integration exposes a gap, fix it here (with tests) before shipping.
129
+
130
+ Only when the full suite is green and the feature works end-to-end:
131
+
132
+ ```
133
+ ✅ All requirements complete — integration verified!
134
+
135
+ | # | Status | Requirement |
136
+ |---|--------|-------------|
137
+ | 1 | ✅ done | <name> |
138
+ | … | … | … |
139
+
140
+ - Ship: /skill:pwk-finalizing
141
+ ```
142
+
143
+ ## If you're stuck
144
+
145
+ 1. Re-read the requirement's acceptance criteria — you may have drifted.
146
+ 2. Check `git log` for context.
147
+ 3. Ask the user — clarify beats guessing.
148
+ 4. If still stuck:
149
+ - Discard uncommitted changes (`git restore .`).
150
+ - If the requirement has already been committed (step 7 completed), also revert its commit(s) so partial work leaves no trace on the shipped branch (`git revert HEAD --no-edit` if only the requirement commit; `git revert HEAD~N..HEAD --no-edit` if multiple commits including code-review smell fixes).
151
+
152
+ **Never leave a failed requirement's partial work on the shipped branch.** Dead code from incomplete requirements must be cleaned up before moving on.
153
+ 5. Mark `❌ failed` with the reason and move on.
154
+ 6. Check `docs/lessons.md` — a prior lesson may apply.
@@ -0,0 +1,78 @@
1
+ ---
2
+ name: pwk-finalizing
3
+ description: "Use after all requirements are complete to delete consumed plan docs, curate lessons, update documentation, and ship the work."
4
+ ---
5
+
6
+ # Finalizing
7
+
8
+ Ship the completed work.
9
+
10
+ ## Pre-finalization checks
11
+
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
+
14
+ 2. Read the progress file (`docs/plans/*-progress.md`). Check for failed or skipped rows:
15
+
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
+
20
+ Never merge a branch that carries incomplete requirements without explicit acknowledgment.
21
+
22
+ - **Only `⏭ skipped`** (no `❌ failed`) → present a warning and confirm:
23
+
24
+ ```
25
+ ⚠️ Requirement 4 was skipped. Continue with finalizing, or go back?
26
+ ```
27
+
28
+ Continue on confirmation; abort otherwise.
29
+
30
+ ## Process
31
+
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.
33
+
34
+ 2. **Delete consumed plan docs** — only this design's artifacts; leave other (un-started) design docs in place:
35
+
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
+ ```
41
+
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.
43
+
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.
45
+
46
+ 4. **Update documentation** — if the API or surface changed: update `README.md`, `CHANGELOG.md`, and any inline docs.
47
+
48
+ 5. **Choose a merge strategy** — ask the human which they prefer:
49
+
50
+ 1. **Create PR** — push and open a PR for external review:
51
+ ```
52
+ git push origin <branch>
53
+ gh pr create --title "feat: <summary>" --body "<summary>"
54
+ ```
55
+ 2. **Rebase & merge** *(recommended)* — rebase onto parent, fast-forward merge, push parent, delete branch:
56
+ ```
57
+ parent=$(git show-branch -a 2>/dev/null | grep '\*' | grep -v "$(git branch --show-current)" | head -1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//')
58
+ git checkout "$parent" && git pull
59
+ git checkout - && git rebase "$parent"
60
+ git checkout "$parent" && git merge --ff-only -
61
+ git push origin "$parent"
62
+ git branch -d - && git push origin --delete -
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.
66
+
67
+ For options 2–4, confirm the detected parent branch before proceeding.
68
+
69
+ 6. **Clean up** — if a worktree was used, remove it:
70
+ ```
71
+ git worktree remove ../<repo>-<topic>
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.
@@ -0,0 +1,83 @@
1
+ ---
2
+ name: pwk-writing-plans
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
+ ---
5
+
6
+ # Writing Plans
7
+
8
+ Turn the design doc's requirements into a **behavioral spec** the executor implements against.
9
+
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).
11
+
12
+ You may only create or edit files under `docs/plans/`. Do not modify source code or configuration.
13
+
14
+ ## Process
15
+
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.
19
+
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
+
27
+ Save to `docs/plans/YYYY-MM-DD-<topic>-implementation.md`:
28
+
29
+ ```markdown
30
+ # Implementation Plan: <topic>
31
+
32
+ ## Overview
33
+ Design: docs/plans/YYYY-MM-DD-<topic>-design.md
34
+
35
+ ## Requirement 1: <name>
36
+
37
+ ### Acceptance criteria
38
+ - Given … When … Then …
39
+ - Given … When … Then … (edge cases)
40
+
41
+ ### Integration tests
42
+ - `should <behavior>` — asserts <observable outcome>
43
+ - `should <error case>` — asserts <failure outcome>
44
+
45
+ ### Production-risk notes
46
+ - <from the design's Production-risk areas, if any>
47
+
48
+ ## Requirement 2: <name>
49
+
50
+ ```
51
+
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`:
53
+
54
+ ```markdown
55
+ ## Setup
56
+
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
+ ```
62
+
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.
69
+
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").
72
+
73
+ ## What the plan is NOT
74
+
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.
78
+
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`.
80
+
81
+ ## After the plan
82
+
83
+ Ask: "Ready to execute? Run `/skill:pwk-executing-tasks`"
@@ -1,166 +0,0 @@
1
- # A/B Comparison: Writing Plans — Karpathy Behavioral Guidelines
2
-
3
- ## Setup
4
- - **Same design doc** (bookmarks: CRUD + search)
5
- - **Same Go project scaffold**
6
- - **Same prompt** (no questions, full plan with concrete code)
7
- - **Variant A** (WITHOUT guidelines): 292-line SKILL.md — original writing-plans skill
8
- - **Variant B** (WITH guidelines): 354-line SKILL.md — with Behavioral Guidelines section appended
9
-
10
- ---
11
-
12
- ## Structural Comparison
13
-
14
- | Dimension | A (Without) | B (With) |
15
- |---|---|---|
16
- | **Total tasks** | 4 | 6 |
17
- | **Lines in plan** | ~1,054 | ~1,019 |
18
- | **New files per plan** | 7 files in Task 1 alone | 1-2 files per task |
19
- | **External dependency** | None (stdlib only) | `github.com/google/uuid` |
20
-
21
- ---
22
-
23
- ## Task Decomposition
24
-
25
- ### A (Without) — 4 tasks
26
- | Task | Scope | Files touched |
27
- |---|---|---|
28
- | 1 | Bookmark + ALL infrastructure (model, store interface, mem store with full CRUD, service, handler, errors, route, tests) | 7 files |
29
- | 2 | Delete bookmark | 3 files |
30
- | 3 | List bookmarks (paginated, cursor) | 3 files |
31
- | 4 | Search bookmarks (keyword + pagination) | 3 files |
32
-
33
- ### B (With) — 6 tasks
34
- | Task | Scope | Files touched |
35
- |---|---|---|
36
- | 1 | Scaffold (go.mod + model only) | 2 files |
37
- | 2 | Bookmark a message (store + handler + test + route) | 4 files |
38
- | 3 | List bookmarks (offset/limit pagination) | 4 files |
39
- | 4 | Remove a bookmark | 4 files |
40
- | 5 | Search bookmarks (keyword) | 4 files |
41
- | 6 | Final wiring + integration lifecycle test | 2 files |
42
-
43
- ---
44
-
45
- ## Detailed Analysis by Guideline
46
-
47
- ### Simplicity First
48
-
49
- **A (Without):** ⚠️ **Overbuilt in Task 1.** Task 1 creates a `BookmarkStore` interface with 4 methods (Create, Delete, ListByUser, SearchByUser) — methods that won't be used until Tasks 2-4. It also creates the full `MemoryStore` implementation with all 4 methods, an `errors.go` file, a `Service` struct, AND the handler — all in a single task. The store interface is the full contract upfront before any task exercises most of it.
50
-
51
- **B (With):** ✅ **Minimal per task.** Task 1 only creates `go.mod` + the `Bookmark` struct. Task 2 introduces `Store` with only `Create`, and `MemStore` with only `Create`. `List` is added to the interface in Task 3, `Delete` in Task 4, `Search` in Task 5 — each method appears when it's needed, not before.
52
-
53
- **Verdict:** Guidelines had a clear positive effect. Plan B builds only what each task needs.
54
-
55
- ### Surgical Changes
56
-
57
- **A (Without):** ⚠️ Task 1 touches 7 files in one go (model, store interface, store mem, errors, service, handler, main.go). The Task 1 description says "create the full vertical slice" which bundles infrastructure that isn't tested yet.
58
-
59
- **B (With):** ✅ Each task touches 1-2 files for new code. Task 1 creates 2 files (go.mod, model.go). Task 2 adds 3 new files + modifies main.go. No task creates more than 4 files.
60
-
61
- **Verdict:** Guidelines had a clear positive effect. Plan B has tighter blast radius per task.
62
-
63
- ### Think Before Coding (surface assumptions)
64
-
65
- **A (Without):** ❌ Silent assumptions throughout:
66
- - Used cursor-based pagination without noting the design just said "paginated" — didn't surface that offset-based vs cursor-based is a choice
67
- - Added `sync.RWMutex` and concurrent safety without the design mentioning concurrency
68
- - Created a `Service` layer between handler and store without justification
69
-
70
- **B (With):** ⚠️ Still has assumptions but more defensible:
71
- - Used offset/limit pagination (simpler, matches "paginated" literally)
72
- - No concurrency concerns added (store uses `sync.Mutex` only, no RWMutex overhead)
73
- - No `Service` layer — handler calls store directly
74
- - Did add `github.com/google/uuid` dependency without asking — minor assumption
75
-
76
- **Verdict:** Marginal positive effect. Plan B is less presumptuous but both plans made assumptions. Neither explicitly surfaced tradeoffs to the user.
77
-
78
- ### Goal-Driven Execution
79
-
80
- **A (Without):** ✅ Good acceptance criteria with Given/When/Then. Has a `checkpoint: test` on 3/4 tasks and `checkpoint: done` on the last task.
81
-
82
- **B (With):** ✅ Good acceptance criteria. Has `checkpoint: test` on 3 tasks, `checkpoint: done` on 1, and no checkpoint on 2 simpler tasks. Added a full lifecycle integration test in Task 6 that wasn't in A.
83
-
84
- **Verdict:** Roughly equivalent. Both plans have strong acceptance criteria (required by the base skill). The lifecycle test in B is a nice bonus that catches integration issues.
85
-
86
- ---
87
-
88
- ## Unrelated Observations (noise, not guidelines)
89
-
90
- | Observation | A (Without) | B (With) |
91
- |---|---|---|
92
- | Pagination style | Cursor-based (more complex) | Offset-based (simpler) |
93
- | External deps | None | `google/uuid` |
94
- | Handler method naming | `Create`, `Delete`, `List`, `Search` | `CreateBookmark`, `DeleteBookmark`, `ListBookmarks`, `SearchBookmarks` |
95
- | Test structure | Single `TestXxx` with `t.Run` subtests | Separate top-level test functions |
96
- | `make([]T, 0, len)` usage | Yes (mem store candidates) | Yes (list handler, search handler) |
97
-
98
- ---
99
-
100
- ## Overall Assessment
101
-
102
- | Guideline | Effect | Evidence |
103
- |---|---|---|
104
- | **Simplicity First** | ✅ Strong positive | B builds incrementally; A front-loads the full store interface |
105
- | **Surgical Changes** | ✅ Positive | B touches fewer files per task (1-4 vs 7 in Task 1) |
106
- | **Think Before Coding** | ⚠️ Marginal | B made fewer silent assumptions but neither surfaced tradeoffs explicitly |
107
- | **Goal-Driven Execution** | ≈ Neutral | Both strong; base skill already enforces acceptance criteria |
108
-
109
- **Bottom line (iteration 1):** The guidelines measurably improved the plan. The biggest win is **Simplicity First** — Plan B's incremental interface growth (adding methods to `Store` as each task needs them) is clearly better than Plan A's upfront full-contract approach. This is exactly the kind of thing "no abstractions for single-use code" catches.
110
-
111
- **Weakness:** Neither plan explicitly called out assumptions or asked clarifying questions — the "Think Before Coding" guideline had the weakest signal. The guidelines alone may not be enough to overcome the model's tendency to fill gaps silently.
112
-
113
- ---
114
-
115
- ## Iteration 2: Revised Guidelines
116
-
117
- ### What changed
118
-
119
- The guidelines were reworked from 4 generic coding rules to 3 planning-specific principles:
120
-
121
- | v1 (Generic) | v2 (Planning-Specific) | Why |
122
- |---|---|---|
123
- | Think Before Coding | **Surface Assumptions** | v1 said "ask" — the agent ignores this when told not to ask. v2 says "annotate in the plan" with a concrete `> **Assumption:** ...` format and examples of what to annotate. |
124
- | Simplicity First | **Build Only What Each Task Needs** | Kept the same core principle but added the specific anti-pattern from the v1 A/B test: "don't define interface methods that no task exercises yet." |
125
- | Surgical Changes | **One Task, One Change** | Reframed from "don't touch adjacent code" to "each task should trace to exactly one user-facing behavior" with a concrete guardrail (max 4 new files). |
126
- | Goal-Driven Execution | *(removed)* | Redundant — the base skill already enforces Given/When/Then acceptance criteria. |
127
-
128
- ### Iteration 2 Plan (v2 guidelines) vs Iteration 1 Plans
129
-
130
- | Dimension | A (No guidelines) | B1 (v1 guidelines) | B2 (v2 guidelines) |
131
- |---|---|---|---|
132
- | **Total tasks** | 4 | 6 | 4 |
133
- | **Max files/task** | 7 (Task 1) | 4 | 4 |
134
- | **Assumptions annotated** | 0 | 0 | **4** (header below) |
135
- | **External deps** | None | `google/uuid` | None |
136
- | **Store interface** | 4 methods upfront in Task 1 | 1 method per task | 1 method per task |
137
- | **Service layer** | Yes (unjustified) | No | No |
138
-
139
- ### The big win: Surface Assumptions
140
-
141
- Plan B2 opens with four explicit assumption annotations:
142
-
143
- ```
144
- > **Assumption:** User identification via X-User-ID request header since
145
- > no auth system exists in the project.
146
-
147
- > **Assumption:** Bookmarks include a Note field so users can annotate
148
- > bookmarks. The design says "search by keyword" but doesn't specify
149
- > the field.
150
-
151
- > **Assumption:** Offset/limit pagination (not cursor-based).
152
-
153
- > **Assumption:** In-memory store behind a Store interface.
154
- ```
155
-
156
- None of the previous plans (A or B1) did this. The v1 "Think Before Coding" guideline was completely invisible in output. The v2 "Surface Assumptions" guideline produced visible, reviewable annotations on the first run.
157
-
158
- ### Iteration 2 Assessment
159
-
160
- | Guideline | v1 Effect | v2 Effect | Improvement |
161
- |---|---|---|---|
162
- | **Surface Assumptions** (was Think Before Coding) | ⚠️ Invisible | ✅ 4 explicit annotations | Complete turnaround — concrete format + examples fixed the weakest signal |
163
- | **Build Only What's Needed** (was Simplicity First) | ✅ Strong | ✅ Strong | Maintained — interface still grows incrementally |
164
- | **One Task, One Change** (was Surgical Changes) | ✅ Positive | ✅ Positive | Maintained — max 4 files/task |
165
-
166
- **Bottom line (iteration 2):** The v2 guidelines fixed the weakest signal from v1. "Surface Assumptions" went from invisible to producing 4 explicit, reviewable annotations. The other two principles maintained their positive effect. The removal of "Goal-Driven Execution" (redundant) reduced noise without losing signal.
@@ -1,50 +0,0 @@
1
- # Checkpoint Review Gates for Task Execution
2
-
3
- ## Problem
4
-
5
- Executing-tasks runs through tasks without pausing. There's no way for the human to review tests before implementation, or review implementation before committing. The TDD labels in plans are advisory, not enforceable. There's no configuration for review gates.
6
-
7
- ## Design
8
-
9
- Add optional `checkpoint` labels to individual tasks in the implementation plan. Executing-tasks pauses at checkpoint boundaries for human review.
10
-
11
- ## Checkpoint labels
12
-
13
- Each task can optionally include a `checkpoint` label:
14
-
15
- - **`checkpoint: test`** — pause after writing the failing test, before implementing
16
- - **`checkpoint: done`** — pause after implementation + tests pass, before committing
17
- - **No label** — auto-advance, no pause
18
-
19
- The label is orthogonal to the TDD scenario. A "new feature" task with `checkpoint: test` means: write failing test → pause → implement → run tests → commit. Without a checkpoint, the same task flows straight through.
20
-
21
- ## Who sets checkpoints
22
-
23
- The agent decides which tasks get checkpoints during plan writing, based on complexity and risk. The user reviews the plan before execution and can add, remove, or change checkpoints.
24
-
25
- ## Changes
26
-
27
- ### writing-plans/SKILL.md
28
-
29
- Add `checkpoint` as an optional field in the task format section, with the two values and the "no label means auto-advance" rule. Update the TDD table to show how checkpoints interact with each scenario. Add guidance for the agent on when to use each checkpoint value.
30
-
31
- ### executing-tasks/SKILL.md
32
-
33
- Update the per-task lifecycle to handle checkpoints:
34
-
35
- - **No checkpoint** — existing flow unchanged
36
- - **`checkpoint: test`** — write failing test → show diff → pause for review → proceed based on human input → implement → run tests → fix if needed → commit
37
- - **`checkpoint: done`** — implement → run tests → fix if needed → show diff → pause for review → proceed based on human input → commit
38
-
39
- The pause is a simple conversation stop — the agent shows what was done and the diff, then waits. The human can say anything: change the test, tweak the implementation, approve, revert, adjust the plan. No rigid menu.
40
-
41
- Pause message format:
42
-
43
- ```
44
- ⏸ Paused at checkpoint: [test|done] for task [N]
45
-
46
- **What was done:** [brief summary]
47
- **Diff:** [show relevant diff]
48
-
49
- Review and let me know how to proceed.
50
- ```