@softure-ai/skills 0.2.1 → 0.4.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 (53) hide show
  1. package/README.md +4 -0
  2. package/WORKFLOW.md +30 -3
  3. package/package.json +1 -1
  4. package/skills/softure-archive/SKILL.md +76 -24
  5. package/skills/softure-archive/references/example-archive.md +106 -0
  6. package/skills/softure-code-review/SKILL.md +68 -18
  7. package/skills/softure-code-review/references/example-review.md +108 -0
  8. package/skills/softure-frame/SKILL.md +129 -40
  9. package/skills/softure-frame/references/diagnostic-lens.md +85 -0
  10. package/skills/softure-frame/references/examples.md +111 -0
  11. package/skills/softure-frame/references/pushback.md +38 -0
  12. package/skills/softure-impl-review/SKILL.md +138 -76
  13. package/skills/softure-impl-review/references/example-review.md +127 -0
  14. package/skills/softure-impl-review/references/rubric.md +120 -0
  15. package/skills/softure-impl-review/references/triage.md +124 -0
  16. package/skills/softure-implement/SKILL.md +116 -49
  17. package/skills/softure-implement/references/phase-commit.md +214 -0
  18. package/skills/softure-implement/references/worked-example.md +201 -0
  19. package/skills/softure-init/SKILL.md +59 -41
  20. package/skills/softure-init/references/example.md +96 -0
  21. package/skills/softure-init/references/templates.md +73 -0
  22. package/skills/softure-lesson/SKILL.md +47 -19
  23. package/skills/softure-lesson/references/examples.md +65 -0
  24. package/skills/softure-new/SKILL.md +100 -43
  25. package/skills/softure-new/references/example-change.md +149 -0
  26. package/skills/softure-new/references/placement.md +60 -0
  27. package/skills/softure-plan/SKILL.md +182 -50
  28. package/skills/softure-plan/references/plan-example.md +206 -0
  29. package/skills/softure-plan/references/progress-format.md +56 -2
  30. package/skills/softure-plan/references/questioning.md +162 -0
  31. package/skills/softure-plan-review/SKILL.md +211 -83
  32. package/skills/softure-plan-review/references/lenses.md +121 -0
  33. package/skills/softure-plan-review/references/review-example.md +184 -0
  34. package/skills/softure-prd/SKILL.md +130 -71
  35. package/skills/softure-prd/references/example-prd.md +233 -0
  36. package/skills/softure-prd/references/leak-lint.md +43 -0
  37. package/skills/softure-prd/references/prd-template.md +219 -0
  38. package/skills/softure-research/SKILL.md +73 -33
  39. package/skills/softure-research/references/example-research.md +106 -0
  40. package/skills/softure-research/references/fan-out.md +61 -0
  41. package/skills/softure-roadmap/SKILL.md +215 -65
  42. package/skills/softure-roadmap/references/example-roadmap.md +203 -0
  43. package/skills/softure-roadmap/references/interview.md +132 -0
  44. package/skills/softure-roadmap/references/slicing.md +118 -0
  45. package/skills/softure-rule-review/SKILL.md +83 -19
  46. package/skills/softure-rule-review/references/example-report.md +73 -0
  47. package/skills/softure-rule-review/references/scorecard.md +129 -0
  48. package/skills/softure-shape/SKILL.md +163 -53
  49. package/skills/softure-shape/references/example-shape-notes.md +192 -0
  50. package/skills/softure-shape/references/question-bank.md +248 -0
  51. package/skills/softure-worktree/SKILL.md +11 -3
  52. package/skills/softure-worktree/scripts/wt-integration.sh +27 -3
  53. package/skills/softure-worktree-manager/SKILL.md +24 -4
@@ -0,0 +1,124 @@
1
+ # Triage: talking the findings through with the user
2
+
3
+ The user decides; the skill recommends. Every question puts the recommended answer first and
4
+ says why in a few words. In `--auto` none of this is asked: the `--auto` rules in SKILL.md pick
5
+ the decision, and each one is recorded under `## Decisions (auto)`.
6
+
7
+ ## 1. Chat summary (before any question)
8
+
9
+ Plain text, short, readable without the report open. Each level is printed with its meaning.
10
+
11
+ ```
12
+ Implementation review: invoice-late-fees (full, 3 phases, commits 51e0a7c..c93b2d4)
13
+ Gates: typecheck pass · lint pass · test pass (588 tests)
14
+
15
+ Plan adherence PASS
16
+ Scope WARNING 1 finding
17
+ Progress honesty FAIL 1 finding
18
+ Correctness FAIL 1 finding
19
+ Tests PASS
20
+ Data and migrations WARNING 1 finding
21
+ Security PASS
22
+ Architecture and patterns WARNING 1 finding
23
+ Lessons PASS
24
+
25
+ Findings: 2 critical, 3 warnings, 1 suggestion
26
+
27
+ F1 CRITICAL MEDIUM impact (a real trade-off) a rerun of the job charges the fee twice
28
+ F2 CRITICAL LOW impact (obvious, narrow fix) 1.2 "rounds half-up" ticked without a test that rounds
29
+ F3 WARNING LOW impact (obvious, narrow fix) late_fee column added to the CSV export, not in the plan
30
+ F4 WARNING MEDIUM impact (a real trade-off) job scheduled with setInterval instead of the job registry
31
+ F5 WARNING LOW impact (obvious, narrow fix) no index for the overdue scan
32
+ F6 SUGGESTION LOW impact (obvious, narrow fix) test names say "works"
33
+ ```
34
+
35
+ Dimensions that pass appear only in the table, never as findings.
36
+
37
+ ## 2. How to proceed
38
+
39
+ Ask once:
40
+ - **"Decide one by one"**: recommended when there is any CRITICAL or HIGH-impact finding.
41
+ - **"Take every recommendation"**: recommended when all findings are LOW or MEDIUM impact and
42
+ none is CRITICAL. CRITICAL and HIGH-impact findings are still asked one by one; the rest are
43
+ decided as recommended, then listed.
44
+ - **"Save and decide later"**: write the report with `**Decision:** pending (recommended: …)`,
45
+ commit the report alone as `docs(<change-id>): impl review` so it survives the session, and
46
+ print the path and `softure-impl-review <change-id> --triage`. Status stays as it was.
47
+
48
+ ## 3. One question per finding
49
+
50
+ Order: CRITICAL first, then by impact. The question carries the whole finding, so the user does
51
+ not have to scroll:
52
+
53
+ ```
54
+ F1 of 6: a rerun of the job charges the fee twice
55
+ CRITICAL · MEDIUM impact (a real trade-off) · Correctness · invoices/apply-late-fee.ts:41
56
+
57
+ The job inserts a fee row without checking for an existing one. It runs hourly and is retried
58
+ on failure, so a second run in the same day adds the fee again (reproduced on the test database:
59
+ two runs, two rows for invoice 1042).
60
+
61
+ Fix A (recommended): unique constraint on (invoice_id, fee_date) plus ON CONFLICT DO NOTHING
62
+ Strength: the database enforces it for every writer, including the retry path
63
+ Trade-off: one migration; existing duplicates must be checked first (query: none today)
64
+ Confidence: HIGH, the payments table uses the same pattern
65
+ Fix B: check for an existing row in the job before inserting
66
+ Strength: no migration
67
+ Trade-off: two concurrent runs still race between the check and the insert
68
+ Confidence: MEDIUM, the retry runs in parallel with the next hourly run
69
+ ```
70
+
71
+ Options, with two fixes: "Apply Fix A (recommended)", "Apply Fix B", "Defer", "Record as lesson".
72
+ Options, with one fix: the recommended decision first (usually "Fix now"), then "Fix
73
+ differently", "Defer", "Record as lesson". "Accept" and "withdraw" come through the free-text
74
+ answer, which is always available.
75
+
76
+ ## 4. Handling the answer
77
+
78
+ - **Fix now / Apply Fix A or B**: for MEDIUM or HIGH impact, show the exact before/after and
79
+ ask "Apply this?"; for LOW impact, apply directly. Record `fix now: <what changed> (Fix A)`;
80
+ the SHA is added after the fix commit.
81
+ - **Fix differently**: ask how, apply that, record it as the user's fix.
82
+ - **Defer**: ask where to (recommended: the backlog topic file that matches, or the roadmap's
83
+ "Owner decisions and checks" when the owner must decide). Write the entry there and record
84
+ the target.
85
+ - **Free text "accept" / "keep it"**: record `accept: <the user's reason> (accepted by owner)`.
86
+ If the user gives no reason, ask once for one line.
87
+ - **Free text "that is not a bug" / "wrong"**: look at the argument. If it holds, record
88
+ `withdrawn: <why>`. If it does not, say what evidence contradicts it once, then record what the
89
+ user decides.
90
+ - **Skip without a decision**: there is no skip. Offer "Defer" or "Accept" instead.
91
+ - **Record as lesson**: draft the rule in one line from the finding (the mechanism, not the
92
+ incident), show it, and hand off to `softure-lesson --from <change-id>#F<n>`. Then **always**
93
+ ask "Also fix the code now?" (recommended: yes, unless the lesson is purely about process).
94
+ Never decide that on the user's behalf, however small or large the fix looks. Record
95
+ `record as lesson + fix now` or `record as lesson`.
96
+
97
+ Keep momentum: the user has read the summary, so do not repeat it between questions. After each
98
+ decision, update the report file if it is already written.
99
+
100
+ ## 5. Triage summary
101
+
102
+ Printed at the end and written into `## Triage summary`:
103
+
104
+ ```
105
+ Triage complete: invoice-late-fees
106
+
107
+ Fixed: F1 (Fix A), F2, F4, F6 (4)
108
+ Lessons: F1 (also fixed) (1)
109
+ Deferred: F5 -> context/backlog/performance.md (1)
110
+ Accepted: F3 (owner asked for the column) (1)
111
+ Withdrawn: none
112
+
113
+ Fix commit: 8d2e4f1 · Gates after fixes: typecheck pass · lint pass · test pass (594 tests)
114
+ Verdict: Ready after fixes
115
+ Next: softure-lesson (F1), then softure-archive invoice-late-fees
116
+ ```
117
+
118
+ ## 6. Resuming a saved triage
119
+
120
+ `--triage`, or a report found with pending decisions: read `reviews/impl-review.md` (or
121
+ `impl-review-p<N>.md`), collect the `### F` sections whose `**Decision:**` starts with `pending`,
122
+ and continue at step 3 with them. When none is pending, say "every finding is decided" and go to
123
+ the commit step. Before applying a deferred-then-resumed fix, re-read the code at its location:
124
+ it may have changed since the report was written.
@@ -2,10 +2,11 @@
2
2
  name: softure-implement
3
3
  description: >
4
4
  Execute a reviewed plan phase by phase: write the code and tests for one phase, run the
5
- project gates, verify the criteria for real, tick ## Progress and commit once per phase.
6
- Resumes from the first open item. Use after softure-plan-review. Triggers: "implement
7
- phase N", "continue implementation", "/softure-implement",
8
- "execute the plan", "next phase".
5
+ project gates, verify the criteria for real (manual ones too, where a machine can), pause
6
+ for the user's manual checks, tick ## Progress and commit once per phase with the SHA
7
+ recorded safely. Resumes from the first open item, including after a half-finished commit.
8
+ Use after softure-plan-review. Triggers: "implement phase N", "continue implementation",
9
+ "/softure-implement", "execute the plan", "next phase".
9
10
  argument-hint: "<change-id> [phase N | next] [--auto]"
10
11
  allowed-tools:
11
12
  - Read
@@ -24,83 +25,140 @@ Implementation follows the plan. It does not redesign it. Each phase ends in a s
24
25
  whose ticked boxes are **true**: they were checked, not assumed. `## Progress` in `plan.md` is
25
26
  the only state, so anyone can stop and anyone can resume.
26
27
 
28
+ Contract: `WORKFLOW.md` §4 (status), §6 (Progress and the SHA rule), §8 (`--auto`), §9 (commits).
29
+
30
+ Read when needed:
31
+ - `references/phase-commit.md`: the phase-end commit sequence step by step, with the edge cases
32
+ (hook failure, no diff, unrelated dirty paths, issue references, resuming a half-done commit)
33
+ and good and bad commit messages. Read before the first commit of a run.
34
+ - `references/worked-example.md`: a complete two-phase run on a booking app, with every message
35
+ the user sees. Read when unsure what a gate message or a mismatch report should look like.
36
+ - `softure-plan/references/progress-format.md`: the Progress notation.
37
+
27
38
  ## Required inputs
28
39
 
29
40
  - `context/changes/<id>/plan.md` and `change.md` with `status: plan_reviewed` or `implementing`.
30
- If the status is `planned`, run `softure-plan-review` first.
41
+ If the status is `planned`, run `softure-plan-review` first. If the path resolves under
42
+ `context/archive/`, refuse: archived changes are closed; open a new one with `softure-new`.
31
43
  - `context/workflow.json`, which provides the gates and `mainBranch`.
32
44
  - `context/foundation/lessons.md`, when present.
33
45
  - A clean working tree, apart from files this change owns. Unrelated uncommitted changes:
34
- in interactive mode, ask; in `--auto`, stop and escalate. Never stash or discard them.
46
+ in interactive mode, list them and ask (recommended: continue and never stage them); in
47
+ `--auto`, stop and escalate. Never stash or discard them.
48
+
49
+ **No argument.** Interactive: list the folders in `context/changes/` whose status is
50
+ `plan_reviewed` or `implementing`, recommend the most recently `updated` one, and ask. If
51
+ there is none, say which skill comes next for each change and stop. `--auto`: a change-id is
52
+ mandatory; stop with an error.
35
53
 
36
54
  ## Procedure
37
55
 
38
56
  1. **Locate the phase.**
39
57
  - `phase N` → that phase.
40
- - `next` or no argument → the phase holding the first `- [ ]` in an Automated group.
41
- - Every automated item ticked → go to step 9.
58
+ - `next` or no phase → the phase holding the first `- [ ]` in an Automated group.
59
+ - Every automated item ticked → go to step 10.
42
60
 
43
61
  Refuse to skip ahead over an unfinished earlier phase unless the user explicitly says so.
62
+ Before starting, run the **resume check** in `references/phase-commit.md` ("Resuming"): a
63
+ previous run may have committed without writing the SHA, or ticked items without committing.
44
64
 
45
65
  2. **Load context fresh.** Re-read the phase section, its Progress items, change.md Constraints,
46
- relevant research sections, and the lessons whose "Applies to" matches the phase's files.
47
- Set `status: implementing` (and `updated`) on the first run.
66
+ the research sections the phase relies on, and the lessons whose "Applies to" matches the
67
+ phase's files. Read files in full, not in slices. Set `status: implementing` (and `updated`)
68
+ on the first run. Start the phase's **touched-file set**: the paths you edit or create during
69
+ this phase, plus `plan.md`. In phase 1 it also includes the change folder's own uncommitted
70
+ artifacts (change.md, research.md, plan.md, reviews/), so they land in the first commit.
48
71
 
49
72
  3. **Reconcile plan and code.** Before editing, confirm that the files and symbols the phase names
50
- exist and look as research described. When they differ:
51
- - **Small drift** (renamed symbol, moved file, an extra call site): adapt and record it under
52
- `## Decisions (auto)` in plan.md, or ask in interactive mode.
73
+ exist and look as research described. When they differ, describe it in this shape:
74
+
75
+ ```
76
+ Mismatch in phase N, step S
77
+ Plan says: <what the plan expects>
78
+ Code has: <what is actually there, with path:line>
79
+ Why it matters: <what goes wrong if we follow the plan literally>
80
+ Recommendation: <adapt | drop the step | re-plan>, because <reason>
81
+ ```
82
+
83
+ - **Small drift** (renamed symbol, moved file, an extra call site): interactive, ask with the
84
+ options "Adapt and continue" (recommended), "Drop this step", "Stop and re-plan"; `--auto`,
85
+ adapt. Either way record it in plan.md (`## Decisions (auto)` in `--auto`, a note under the
86
+ phase otherwise) and in the commit body.
87
+ - **A step is no longer needed:** mark its item `- [x] ~~N.M text~~ — dropped: <reason>`.
53
88
  - **The approach no longer holds** (a wrong assumption about data, an API that does not exist,
54
- the Constraints would be violated): stop. Do not improvise a new design. Report what is
55
- wrong and recommend `softure-plan` (re-plan) for the remaining phases.
89
+ the Constraints would be violated): stop in both modes. Do not improvise a new design. Report
90
+ the mismatch and recommend `softure-plan` for the remaining phases; landed phases and their
91
+ SHAs stay.
56
92
 
57
93
  4. **Implement with the phase's discipline.**
58
- - **TDD:** write the failing test first and run it to see it red for the right reason.
59
- Then implement until green, then refactor.
94
+ - **TDD:** write the failing test first and run it to see it red for the right reason (the
95
+ assertion, not an import error). Then implement until green, then refactor.
60
96
  - **Test-after:** implement, then write the tests named in the criteria.
61
97
 
62
98
  Follow the project conventions (AGENTS.md / CLAUDE.md). Keep changes inside the phase's
63
- files. If a necessary file is outside the list, add it and record why.
99
+ files. If a necessary file is outside the list, add it and record why. For unfamiliar code or
100
+ a stubborn failure, a read-only subagent may explore; the main thread keeps the plan.
64
101
 
65
- 5. **Run the gates** from `workflow.json` (`typecheck`, `lint`, `test`), all of them, every phase.
102
+ 5. **Run the gates** from `workflow.json` (`gates.*`), all of them, every phase.
66
103
  - A red gate is fixed, never skipped.
67
104
  - A failure that existed before your change must be proven to pre-exist: check out
68
105
  `mainBranch` in a scratch worktree and run the same command. Then report it. Do not silence it.
69
106
 
70
- 6. **Verify the criteria for real.**
107
+ 6. **Verify the criteria for real**, ticking each Progress item the moment it is proven.
71
108
  - Automated items: run the exact command or test and read its output.
72
109
  - Data criteria: read the database (a query against dev or test data), never only the
73
110
  rendered UI.
74
- - Manual items: try to verify them yourself where a machine can stand in for the eye, for
75
- example screenshots at the stated widths and themes, a recorded request/response, or a DB
76
- read. Tick such an item with `(verified by agent: <how>)`. Anything that needs the owner's
77
- judgement stays `- [ ]`.
78
-
79
- 7. **Commit the phase.**
80
- - Stage only this change's files and check `git status` before committing.
81
- - One commit per phase, with message `<type>(<change-id>): <phase title> (p<N>)`, where type
82
- is `feat`, `fix`, `refactor`, `test`, `docs` or `chore`.
83
- - Then tick the verified boxes and append ` — <short sha>` of that commit. Do **not** amend the
84
- Progress edit into it: amending changes the SHA you just recorded. The edit rides with the
85
- next commit of the change (next phase, review fix, archive); after the last phase, or when the
86
- branch is about to be pushed, commit it as `docs(<change-id>): progress p<N>`. Never push, tag,
87
- release or deploy.
88
-
89
- 8. **Continue or pause.** In interactive mode, report the phase result and ask whether to continue
90
- to the next phase. In `--auto`, continue until all phases are done or an escalation is hit.
91
-
92
- 9. **Finish.** When every Automated item is ticked:
93
- - set `status: implemented` and update `updated`;
94
- - list the open Manual items for the owner;
95
- - recommend `softure-impl-review <change-id>`.
111
+ - Manual items: first try to verify them yourself where a machine can stand in for the eye:
112
+ screenshots at the stated widths and themes, a recorded request/response, a DB read. Tick
113
+ such an item with `(verified by agent: <how>)`. Anything that needs the owner's judgement
114
+ stays `- [ ]`.
115
+
116
+ 7. **Manual gate** (interactive only). When manual items remain open, pause before committing
117
+ and show the gate message (format and options in `references/phase-commit.md`): what passed
118
+ automatically, what you verified yourself and how, and what the user should check now. In the
119
+ **final phase**, add the open manual items of earlier phases ("still waiting from earlier
120
+ phases"). Recommend checking now when a later phase builds on the result; otherwise recommend
121
+ committing and leaving the items open. A problem the user reports is fixed inside this phase
122
+ before the commit. `--auto`: no pause; open items stay `- [ ]` and are listed at the end.
123
+
124
+ 8. **Commit the phase**, following `references/phase-commit.md`: stage the touched-file set by
125
+ path, check for unrelated dirty paths, propose the message
126
+ `<type>(<change-id>): <phase title> (p<N>)` (interactive: approve, edit or replace it;
127
+ `--auto`: use it), commit, then append ` — <short sha>` to every item ticked in this phase.
128
+ Never amend that edit into the phase commit: it rides with the next commit of the change
129
+ (next phase, review fix, archive), or becomes `docs(<change-id>): progress p<N>` when nothing
130
+ follows. Never `--no-verify`, never `--amend`. Never push, tag, release or deploy.
131
+
132
+ 9. **Continue or pause.** Interactive: report the phase (items ticked, open manual items,
133
+ progress `done/total`) and ask:
134
+ - "Continue to phase N+1" (recommended while the context is still small);
135
+ - "Stop here, resume later": print `softure-implement <change-id> next` for a fresh session;
136
+ - "Review this phase first": run `softure-impl-review <change-id> phase N`, then ask again
137
+ without this option.
138
+
139
+ When the user asked for several phases at once, skip the question between them. `--auto`:
140
+ continue until all phases are done or an escalation is hit.
141
+
142
+ 10. **Finish.** When every Automated item is ticked:
143
+ - re-scan Progress and list any open item as `N.M text`, grouped Automated / Manual. An open
144
+ Automated item means the plan is not done: go back to step 1;
145
+ - set `status: implemented` and update `updated`;
146
+ - commit the trailing Progress SHA edit and the status change together as
147
+ `docs(<change-id>): progress p<N>` (stage plan.md and change.md by path; skip when nothing
148
+ is staged; never write this commit's own SHA anywhere);
149
+ - print the completion summary: phases with their SHAs, key files changed, open Manual items
150
+ for the owner, decisions recorded;
151
+ - interactive: ask whether to run `softure-impl-review <change-id>` now (recommended) or
152
+ later. `--auto`: hand off.
96
153
 
97
154
  ## Progress rules (short form)
98
155
 
99
156
  Use the format in `softure-plan/references/progress-format.md`:
100
- - tick only verified items;
101
- - never rename or delete items;
102
- - add new items with the next free number;
103
- - mark dropped ones `~~text~~ — dropped: <reason>`.
157
+ - tick only verified items; edit only `## Progress`, never the phase sections above it;
158
+ - never rename or delete items; add new items with the next free number;
159
+ - mark dropped ones `~~text~~ — dropped: <reason>`;
160
+ - "where am I" is derived, never stored: the first open Automated item is the next step, and
161
+ `count([x]) / count(all)` is the progress.
104
162
 
105
163
  ## Status transitions
106
164
 
@@ -109,12 +167,16 @@ Use the format in `softure-plan/references/progress-format.md`:
109
167
 
110
168
  ## `--auto`
111
169
 
112
- - Never ask. Run all remaining phases in order.
170
+ - Never ask. Run all remaining phases in order, with no manual gate and no question between phases.
113
171
  - Apply small drift and record it under `## Decisions (auto)` in plan.md.
114
- - Stage only files you touched for this change.
172
+ - Stage only files you touched for this change. A dirty path the phase's own commands produced
173
+ (generated types, a lockfile, a snapshot) joins the touched-file set; any other unknown path is
174
+ an escalation.
175
+ - Use the proposed commit message as is.
115
176
  - Escalate (stop with a report) when:
116
177
  - the approach is invalid (re-plan needed);
117
178
  - a gate stays red after a reasonable fix attempt and you cannot prove the failure pre-exists;
179
+ - a hook rejects the commit and the cause lies outside the change;
118
180
  - a destructive or irreversible operation is needed;
119
181
  - a secret or access is missing.
120
182
 
@@ -124,8 +186,10 @@ Use the format in `softure-plan/references/progress-format.md`:
124
186
  - [ ] Gates are green at every phase commit.
125
187
  - [ ] The diff follows the language rule in AGENTS.md (when the project carries one).
126
188
  - [ ] There is one commit per phase with the WORKFLOW §9 message, and nothing unrelated is staged.
189
+ - [ ] Every ticked item carries its phase SHA, and no Progress edit was amended into its own commit.
127
190
  - [ ] TDD phases show a red test before the implementation.
128
191
  - [ ] Drift is recorded. No silent design changes.
192
+ - [ ] Open Manual items are listed for the owner, not ticked on the user's behalf.
129
193
  - [ ] Nothing was pushed, tagged, released or deployed.
130
194
 
131
195
  ## Anti-patterns
@@ -136,8 +200,11 @@ Use the format in `softure-plan/references/progress-format.md`:
136
200
  - `git add -A` with unrelated files in the tree.
137
201
  - Quietly redesigning when the plan is wrong, instead of stopping for a re-plan.
138
202
  - Bundling several phases into one commit.
203
+ - Amending after a failed hook: the failed commit never happened, so `--amend` rewrites the
204
+ previous phase.
205
+ - Handing every manual item to the user when a screenshot or a query would have settled it.
139
206
 
140
207
  ## Handoff
141
208
 
142
209
  Next: `softure-impl-review <change-id>`. Open manual items go to the owner. In a roadmap, they
143
- are listed under "Owner decisions and checks".
210
+ are listed under "Owner decisions and checks" at archive time.
@@ -0,0 +1,214 @@
1
+ # Phase-end commit: the sequence and its edge cases
2
+
3
+ Every phase ends the same way. The order matters: the SHA can only be written after the commit
4
+ exists, and it must never be amended back into that commit (`WORKFLOW.md` §6).
5
+
6
+ ```
7
+ verify → manual gate → staging set → dirty-path check → stage by path → message
8
+ → commit → confirm HEAD → write SHA into Progress → bump change.md → reset the set
9
+ ```
10
+
11
+ ## 1. The touched-file set
12
+
13
+ Keep a list, in working memory, of every path you create or edit during the phase. It is the
14
+ only input to `git add`. `git status` is used to find what is *outside* the set, never to decide
15
+ what goes in.
16
+
17
+ - `plan.md` is always in the set: ticks happen in every phase, and the previous phase's SHA
18
+ edit is waiting in it.
19
+ - Phase 1 also takes the change folder's uncommitted artifacts (`change.md`, `research.md`,
20
+ `frame.md`, `plan.md`, `reviews/plan-review.md`), so planning output lands with the first code.
21
+ - Files that the phase's own commands regenerate (generated types, a lockfile after an install
22
+ the plan asked for, a migration snapshot) join the set when you see them appear.
23
+ - The set is cleared after the commit. The next phase starts with `plan.md` only.
24
+
25
+ When the project's rules prescribe a different staging policy (for example "commit the whole
26
+ tree", or a dedicated worktree where every path is the change's), follow the project. Its rules
27
+ outrank this default.
28
+
29
+ ## 2. Manual gate (interactive)
30
+
31
+ Skip it when the phase has no open Manual item. Otherwise show one message and wait:
32
+
33
+ ```
34
+ Phase 2 of 3 is ready to commit: Reminder email 24 hours before a booking
35
+
36
+ Passed automatically:
37
+ - 2.1 reminder job selects bookings starting in 23-25 h (test "selects only the next-day window")
38
+ - 2.2 a cancelled booking gets no reminder (test "skips cancelled bookings")
39
+ - 2.4 Gates green: typecheck, lint, test (412 tests)
40
+
41
+ Verified by me:
42
+ - 2.5 email renders in light and dark mail themes (screenshots in reviews/p2-email-*.png)
43
+
44
+ Please check:
45
+ - 2.6 the reminder wording reads naturally to a customer (preview: GET /dev/mail/reminder)
46
+
47
+ Still waiting from earlier phases:
48
+ - 1.5 calendar badge colour matches the design file
49
+ ```
50
+
51
+ The last block appears only in the **final** phase, and only when earlier phases left Manual
52
+ items open. List them as `N.M text`, without the checkbox and without any SHA.
53
+
54
+ Ask with three options:
55
+ - **"Checked, all good"**: tick the items the user confirmed (plain `- [x]`, no "verified by
56
+ agent" note), then commit.
57
+ - **"Commit now, check later"**: commit with the items still `- [ ]`. They are carried to the
58
+ owner at archive time and never block the next phase.
59
+ - **"Found a problem"**: take the description, fix it inside this phase, re-run the gates and
60
+ the affected criteria, then show the gate again.
61
+
62
+ Recommend "Checked, all good" when a later phase builds on what the item checks (a layout the
63
+ next phase extends, a data shape the next phase reads); otherwise recommend "Commit now, check
64
+ later". `--auto`: no gate; open items stay open and go into the final summary.
65
+
66
+ ## 3. Dirty paths outside the set
67
+
68
+ Run `git status --porcelain` and remove every path in the touched-file set. Whatever is left
69
+ is someone else's, or something you forgot.
70
+
71
+ - Something you forgot (a file you did edit): add it to the set. This is the most common case
72
+ after a long phase; check before blaming anyone else.
73
+ - Interactive, otherwise: show the paths and ask "Leave them out" (recommended), "Include them
74
+ in this commit" (the user takes responsibility for the wider scope) or "Stop" (the user tidies
75
+ first, then the sequence restarts here).
76
+ - `--auto`: leave out paths that were already dirty when the run started (they were reported
77
+ then); any new unknown path is an escalation, because something wrote where it should not.
78
+
79
+ Never stash, reset or check out a path that is not yours.
80
+
81
+ ## 4. Stage by path
82
+
83
+ ```bash
84
+ git add -- <path> <path> ...
85
+ git diff --cached --stat
86
+ ```
87
+
88
+ Read the staged stat once. A file you do not recognise in it means the set is wrong; fix the set,
89
+ not the stat. `git add -A` and `git add .` are not used unless the project's rules say so.
90
+
91
+ **A phase with no code diff** (a verification-only phase, or one whose steps were all dropped)
92
+ still gets its commit: the staged diff is `plan.md` itself (the ticks, the dropped markers, the
93
+ previous phase's SHA). Use type `test` or `chore` and say in the body why there is no code. This
94
+ keeps every ticked item carrying a SHA. If even `git diff --cached --quiet` reports nothing
95
+ (the ticks were already committed by a previous run), there is nothing to commit: say so and
96
+ go to step 8 with the existing phase commit.
97
+
98
+ ## 5. The message
99
+
100
+ Subject: `<type>(<change-id>): <phase title> (p<N>)`, the phase title as written in plan.md.
101
+
102
+ | type | when |
103
+ |---|---|
104
+ | `feat` | new behaviour a user or caller can observe |
105
+ | `fix` | corrects behaviour that was wrong |
106
+ | `refactor` | structure changes, behaviour does not |
107
+ | `test` | only tests, or a verification-only phase |
108
+ | `docs` | only documentation or artifacts |
109
+ | `chore` | tooling, config, dependencies, prompts |
110
+
111
+ Body, a few lines:
112
+ - what the phase delivers and anything a reviewer would otherwise ask about: adaptations,
113
+ dropped steps, a pre-existing red test you proved and reported;
114
+ - the touched paths, grouped when there are many;
115
+ - `Refs: <ids>` when the conversation contains issue or task references for this work (a
116
+ tracker key such as `BOOK-214`, a GitHub `#87`, a full issue URL). Copy them exactly, comma
117
+ separated on one line, and repeat them on every commit of the change unless the user tied one to
118
+ a single phase. Never derive a reference from the branch name, the change-id or a file name.
119
+ - the trailers the project's rules ask for (co-author, sign-off), and nothing else.
120
+
121
+ Interactive: show the message and ask "Use as proposed" (recommended), "Edit the subject" or
122
+ "Replace it". `--auto`: use it.
123
+
124
+ Good:
125
+
126
+ ```
127
+ feat(booking-reminders): Reminder email 24 hours before a booking (p2)
128
+
129
+ Adds the hourly reminder job and the reminder template. The plan named
130
+ jobs/scheduler.ts; the scheduler moved to jobs/registry.ts in a refactor
131
+ after research, so the job is registered there (recorded in plan.md).
132
+
133
+ Files: jobs/registry.ts, jobs/send-reminders.ts, jobs/send-reminders.test.ts,
134
+ mail/templates/reminder.tsx, context/changes/booking-reminders/plan.md
135
+ Refs: BOOK-214
136
+ ```
137
+
138
+ Bad, and why:
139
+ - `wip` / `phase 2 done`: no type, no change-id, no phase; nobody can map it back to the plan.
140
+ - `feat(booking-reminders): phases 2 and 3 (p2)`: two phases in one commit; one of them cannot
141
+ be reverted alone.
142
+ - `feat: add reminder job and fix the timezone bug in invoices`: the second half belongs to
143
+ another change; split it out or leave it.
144
+ - `docs(booking-reminders): progress p2` on a commit that also carries code: the bookkeeping
145
+ subject is only for a commit that carries nothing but Progress and status edits.
146
+
147
+ ## 6. Commit, and what to do when a hook refuses
148
+
149
+ ```bash
150
+ git commit -F - <<'EOF'
151
+ feat(booking-reminders): Reminder email 24 hours before a booking (p2)
152
+
153
+ ...
154
+ EOF
155
+ ```
156
+
157
+ Never `--no-verify`, never `--amend`, never a flag that skips signing.
158
+
159
+ When a hook fails, **the commit did not happen**. HEAD is still the previous phase's commit,
160
+ so `--amend` now would rewrite that phase. Instead:
161
+ - read the hook output and fix the cause in the change's own files;
162
+ - a formatter hook that rewrote files: re-add those files (they are already in the set);
163
+ - re-run the gates the fix could affect, then create the commit again, as a new commit;
164
+ - the cause lies outside the change (someone else's work in progress breaks a tree-wide
165
+ typecheck): use the bypass the project's rules document for that situation, if any, and say so
166
+ in the body; otherwise ask the user (interactive) or escalate (`--auto`).
167
+
168
+ ## 7. Confirm HEAD before trusting the SHA
169
+
170
+ ```bash
171
+ git log -1 --format='%h %s'
172
+ ```
173
+
174
+ The subject must be the one you just proposed. If it is the previous phase's subject, the commit
175
+ silently failed: go back to step 6. Only then take `%h` as the phase SHA.
176
+
177
+ ## 8. Write the SHA into Progress
178
+
179
+ For every item ticked in this phase that has no suffix yet:
180
+
181
+ ```
182
+ - [x] 2.1 reminder job selects bookings starting in 23-25 h
183
+ → - [x] 2.1 reminder job selects bookings starting in 23-25 h — 7c41e0b
184
+ - [x] 2.5 email renders in light and dark mail themes (verified by agent: screenshots in reviews/)
185
+ → - [x] 2.5 email renders in light and dark mail themes — 7c41e0b (verified by agent: screenshots in reviews/)
186
+ ```
187
+
188
+ Skip items that already carry a SHA; a re-entered sequence must not append twice. Dropped items
189
+ (`~~…~~ — dropped: …`) take no SHA. This edit stays uncommitted on purpose: it rides with the
190
+ next commit of the change. When nothing follows (last phase, or the branch is about to be pushed),
191
+ commit plan.md and change.md as `docs(<change-id>): progress p<N>`, and never record that commit's
192
+ own SHA.
193
+
194
+ ## 9. Bump change.md, reset
195
+
196
+ Set `updated: <today>` (status stays `implementing` until the finish step). Clear the
197
+ touched-file set.
198
+
199
+ ## Resuming
200
+
201
+ At the start of every run, read Progress and `git log --format='%h %s' <mainBranch>..HEAD`
202
+ before writing anything. Match what you find:
203
+
204
+ | What you find | What happened | What to do |
205
+ |---|---|---|
206
+ | Items of phase N ticked with a SHA, plan.md edit uncommitted | normal end of a phase | continue; the edit rides with the next commit |
207
+ | Items of phase N ticked without a SHA, and a commit `(pN)` exists | committed, then the run stopped before step 8 | write that commit's SHA (from the log, not HEAD, if later commits exist), then continue |
208
+ | Items of phase N ticked without a SHA, no `(pN)` commit, code changes in the tree | work done, never committed | re-run the gates and re-check the ticked items (they were never proven at a commit), then run the sequence from step 2 |
209
+ | Items ticked without a SHA, no commit, no code changes | ticks without work | re-check each one; untick what is not true and implement it |
210
+ | Some items of phase N carry a SHA, others do not, all in one commit | the write-back was interrupted | append the same SHA to the rest |
211
+ | Earlier phases fully ticked with SHAs | done | trust them; re-verify only if the gates are red at the start |
212
+
213
+ When a row does not fit any line, describe what you see and ask (interactive) or escalate
214
+ (`--auto`). Never guess a SHA.