@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,121 @@
1
+ # Review lenses: what to ask, what a finding looks like
2
+
3
+ Read this during the first reviews in a repo, and whenever a lens feels thin. Each lens lists
4
+ the questions to ask of the plan and a typical finding with its usual severity. Severity is a
5
+ starting point: raise it when the consequence is worse in this codebase.
6
+
7
+ ## Coverage and end state
8
+
9
+ - Walk the phases in order. At the end, is change.md Intent true for the user it names?
10
+ - Could every Done-when criterion pass while the goal is unmet? (Tests prove the rule, nothing
11
+ ever calls it.)
12
+ - Does the plan do 90% and stop: data written but never shown, a job built but never scheduled,
13
+ a setting saved but never read?
14
+ - Is every roadmap Unknown and research risk answered by a phase or a mitigation?
15
+
16
+ Typical: "The job is implemented and tested, but no step registers it with the scheduler."
17
+ CRITICAL.
18
+
19
+ ## Slicing
20
+
21
+ - After each phase, do the gates pass and could it be deployed alone?
22
+ - Do phases follow layers (all schema, then all logic, then all UI)?
23
+ - Does a later phase quietly fix something an earlier phase leaves broken?
24
+
25
+ Typical: "Phase 1 changes the column type, but the code that reads it is only updated in
26
+ phase 3; the app is broken between the two." CRITICAL.
27
+
28
+ ## Verifiability
29
+
30
+ - Could a stranger check each criterion with a command, a query or a precise look?
31
+ - Are there "works", "correctly", "looks good", "handles errors", "is fast" without a measure?
32
+ - Is each criterion an end state rather than an activity ("implement X")?
33
+
34
+ Typical: "2.3 'Errors are handled' names neither the error nor the visible result." WARNING.
35
+
36
+ ## Data and migrations
37
+
38
+ - Is the migration in the configured folder, ordered correctly against the code that needs it?
39
+ - Does it lock a large table (adding a non-null column with a default, a new index without a
40
+ concurrent build)? How many rows does research say the table has?
41
+ - Is the backfill separate and restartable? What happens if it stops halfway?
42
+ - Rollback or "forward-only, because..."? Does rollback lose data written since?
43
+ - Does a criterion read real rows after the change?
44
+ - Does another in-flight change touch the same tables or migration numbers?
45
+
46
+ Typical: "A non-null column with a backfill in the same migration, on a table research sized at
47
+ 2 million rows; no restart path." CRITICAL.
48
+
49
+ ## Tests
50
+
51
+ - TDD where the logic has clear inputs and outputs (money, dates, parsing, permissions, state)?
52
+ - Are the edge cases named: empty, null, boundary values, duplicates, concurrency, failures?
53
+ - Is a user-visible outcome covered end to end, or only by unit tests of its parts?
54
+ - For a bug fix: is there a test that fails without the fix?
55
+
56
+ Typical: "The eligibility rule has a test per happy path but none for the day boundary in a
57
+ non-UTC zone, which research named as a risk." WARNING.
58
+
59
+ ## Security
60
+
61
+ - Does every new route, server action, job input or webhook check authorisation, not just a
62
+ session?
63
+ - Is external input validated at the boundary?
64
+ - Are secrets read from the environment, and never logged?
65
+ - Do error messages stay free of stack traces, internal paths and other users' data?
66
+
67
+ Typical: "The new action takes `clientId` from the form and updates it without checking the
68
+ user owns the client." CRITICAL.
69
+
70
+ ## Lean
71
+
72
+ - Remove the phase or step in your head. Is the goal still met? Then it is not needed.
73
+ - Is there an abstraction with one or two users (a provider system for two config sources)?
74
+ - Is there "while we are here" work that change.md does not ask for?
75
+
76
+ Typical: "Phase 1 builds a generic notification channel layer; the change sends one kind of
77
+ email." WARNING.
78
+
79
+ ## Fit
80
+
81
+ - Does the plan introduce a second way to do something the codebase already does (a second
82
+ retry helper, a second date library, a second form pattern)?
83
+ - Do dependencies point the right way (domain code importing UI, a shared module importing a
84
+ feature)?
85
+ - Does it change a shared utility used in many places, and does it list those callers?
86
+ - Are there vague steps ("refactor as needed", "update the callers accordingly")?
87
+
88
+ Typical: "'Update format_amount as needed': research shows 14 importers across 5 areas; the
89
+ plan names none." WARNING.
90
+
91
+ ## Cost and defaults
92
+
93
+ - What does this cost at the expected volume: paid API calls, emails, compute, storage?
94
+ - Does a changed default alter behaviour for existing users or data without them asking?
95
+ - Does a new background job run often enough to matter, and is that intended?
96
+
97
+ Typical: "The job runs every minute and calls the exchange-rate API per invoice; at current
98
+ volume that is 40,000 calls a day on a 1,000-a-day plan." CRITICAL.
99
+
100
+ ## Scope
101
+
102
+ - Does any phase do something outside change.md Intent?
103
+ - Does it touch files that change.md Constraints or the roadmap assign to another change?
104
+ - Does an out-of-scope item from the plan's own goal reappear in a phase?
105
+
106
+ ## Reuse
107
+
108
+ - Does a SOFTURE module cover what the plan builds by hand (WORKFLOW.md §10)? If it almost
109
+ covers it, is the gap recorded as an issue instead of a local re-implementation?
110
+ - Does the codebase already have a helper for this?
111
+
112
+ ## Lessons
113
+
114
+ - For each lesson whose "Applies to" matches the touched paths: does the plan follow it?
115
+ - Quote the lesson id in the finding. A finding backed by a lesson is at least a WARNING.
116
+
117
+ ## Progress format
118
+
119
+ - Result of the mechanics check: one Progress section, last; matching phase titles; one item
120
+ per criterion; no checkboxes elsewhere; gates item last in every phase.
121
+ - Any defect here is CRITICAL: softure-implement resumes from this section.
@@ -0,0 +1,184 @@
1
+ # Worked example: a plan review
2
+
3
+ Read this before writing your first review in a repo, or when unsure how specific a finding
4
+ should be. It reviews the first draft of the `overdue-invoice-reminders` plan; the plan after
5
+ these fixes is `softure-plan/references/plan-example.md`. Paths are illustrative.
6
+
7
+ ## The draft, in short
8
+
9
+ - Phase 1: migration adding `invoices.reminder_sent_at` and `clients.reminders_enabled`; a
10
+ query `findInvoicesDueForReminder` comparing `due_on + 3` with `current_date`.
11
+ - Phase 2: a job that sends the email for each selected invoice, then sets
12
+ `reminder_sent_at = now()`. A `NotificationChannel` interface "so SMS can be added later".
13
+ Criterion 2.2: "Reminders work."
14
+ - Phase 3: a client settings toggle and a `setRemindersEnabled(clientId, enabled)` action.
15
+
16
+ ## The saved review: `reviews/plan-review.md`
17
+
18
+ ```markdown
19
+ # Plan review: overdue-invoice-reminders
20
+
21
+ Reviewed: plan.md @ 2026-10-02. Mode: deep. Verdict: ready after fixes.
22
+ Findings: 2 critical, 2 warning, 1 suggestion.
23
+ Grounding: 11/11 paths, 5/6 symbols (getAccountTimeZone does not exist), 3/3 commands
24
+
25
+ ## Lenses
26
+ | Lens | Result |
27
+ | --- | --- |
28
+ | Coverage and end state | WARN (W1) |
29
+ | Slicing | PASS |
30
+ | Verifiability | WARN (W2) |
31
+ | Data and migrations | FAIL (C1) |
32
+ | Tests | WARN (W1) |
33
+ | Security | FAIL (C2) |
34
+ | Lean | WARN (S1) |
35
+ | Fit | PASS |
36
+ | Cost and defaults | PASS |
37
+ | Scope | PASS |
38
+ | Reuse | PASS |
39
+ | Lessons | PASS |
40
+ | Progress format | PASS |
41
+
42
+ ## Findings
43
+
44
+ ### C1 [CRITICAL] Overlapping job runs send the same reminder twice
45
+ **Effort:** medium. **Lens:** Data and migrations. **Where:** Phase 2, step 1 (plan.md) · `src/jobs/registry.ts:8`
46
+ **Problem:** The job sends first and marks `reminder_sent_at` afterwards. Research §Risks
47
+ records that the scheduler starts a new instance before the old one stops during deploys, so
48
+ two runs can select the same invoice and both send. The Goal promises exactly one reminder.
49
+ **Fix A (Recommended):** claim each invoice with `UPDATE ... SET reminder_sent_at = now() WHERE
50
+ id = $1 AND reminder_sent_at IS NULL RETURNING id`, send only when a row is returned, release
51
+ the claim on a failed send. Strength: one statement, correct across any number of instances,
52
+ same pattern as `claimPayout` in `src/payouts/claim.ts:20`. Trade-off: a crash between claim
53
+ and send loses that reminder. Confidence: high, the pattern already runs in production. Blind
54
+ spot: crash frequency of the job runner is unmeasured.
55
+ **Fix B:** wrap the whole job in a database advisory lock. Strength: no change to the send
56
+ logic. Trade-off: a stuck run blocks all reminders until the lock is released. Confidence:
57
+ medium, the project has no advisory-lock helper yet. Blind spot: lock behaviour with the
58
+ connection pooler is unverified.
59
+ **Decision:** Fix now (applied, Fix A) - phase 2 step 1 rewritten as claim, send, release;
60
+ test "two concurrent runs send one email" added; Critical details added under Approach.
61
+
62
+ ### C2 [CRITICAL] The new action does not check that the user owns the client
63
+ **Effort:** low. **Lens:** Security. **Where:** Phase 3, step 1
64
+ **Problem:** `setRemindersEnabled(clientId, enabled)` takes the id from the form. Any signed-in
65
+ user could switch reminders off for another account's client.
66
+ **Fix:** check ownership the way `updateClientAction` does (`src/app/clients/[id]/actions.ts:31`)
67
+ and add criterion 3.2 "rejects a client the user does not own".
68
+ **Decision:** Fix now (applied)
69
+
70
+ ### W1 [WARNING] "Three days after the due date" is computed in UTC
71
+ **Effort:** low. **Lens:** Tests. **Where:** Phase 1, step 3 · grounding miss
72
+ **Problem:** The query compares with `current_date`, which is the database's UTC date. Accounts
73
+ east of UTC get the reminder up to a day late, accounts west of UTC up to a day early. The plan
74
+ cites `getAccountTimeZone`, which does not exist; the zone is the column `accounts.time_zone`
75
+ (`src/db/schema.ts:64`).
76
+ **Fix:** compute the local date of `now` from `accounts.time_zone` in the query; add the test
77
+ "account where now is still the previous day: not selected".
78
+ **Decision:** Fix now (applied)
79
+
80
+ ### W2 [WARNING] Criterion 2.2 "Reminders work" cannot be checked
81
+ **Effort:** low. **Lens:** Verifiability. **Where:** Phase 2, Done when; Progress 2.2
82
+ **Problem:** Nobody can tell when it is true, and it does not read any data.
83
+ **Fix:** replace with "after one run on the dev database, the reminded count equals the
84
+ eligible count taken before the run; a second run sends 0".
85
+ **Decision:** Fix now (applied)
86
+
87
+ ### S1 [SUGGESTION] Drop the NotificationChannel interface
88
+ **Effort:** low. **Lens:** Lean. **Where:** Phase 2, step 2
89
+ **Problem:** The interface has one implementation; SMS is out of scope in the plan's own Goal.
90
+ **Fix:** call the mail module directly; introduce an abstraction when a second channel exists.
91
+ **Decision:** Fix now (applied)
92
+
93
+ ## Triage summary
94
+ Fixed: C1 (Fix A), C2, W1, W2, S1. Accepted: -. Deferred: -. Dismissed: -.
95
+ Verdict before triage: not ready (2 critical open; the fixes are local, so not back to plan). After: ready after fixes.
96
+ ```
97
+
98
+ ## The same review, presented in the terminal
99
+
100
+ ```text
101
+ PLAN REVIEW: overdue-invoice-reminders (deep, 2026-10-02)
102
+ Findings: 2 critical, 2 warning, 1 suggestion
103
+ Grounding: 11/11 paths, 5/6 symbols, 3/3 commands
104
+
105
+ Data and migrations FAIL (C1)
106
+ Security FAIL (C2)
107
+ Tests WARN (W1)
108
+ Verifiability WARN (W2)
109
+ Lean WARN (S1)
110
+ 8 other lenses PASS
111
+ Verdict: ready after fixes, if C1 and C2 are fixed
112
+
113
+ CRITICAL
114
+ C1 Overlapping job runs send the same reminder twice
115
+ Severity: CRITICAL
116
+ Effort: medium (a real trade-off between two fixes)
117
+ Lens: Data and migrations
118
+ Where: Phase 2, step 1
119
+ Problem: sends first, marks afterwards; the scheduler overlaps during deploys
120
+ Fix A (Recommended): claim with a conditional UPDATE, send, release on failure
121
+ Fix B: advisory lock around the job
122
+ ...
123
+
124
+ Triage now (Recommended) / Save and triage later?
125
+ ```
126
+
127
+ ## A triage exchange
128
+
129
+ > **C1 of 5 - Overlapping job runs send the same reminder twice.** (details as above)
130
+ >
131
+ > 1. Apply Fix A (Recommended)
132
+ > 2. Apply Fix B
133
+ > 3. Fix differently
134
+ > 4. Accept risk
135
+ > 5. Defer
136
+ > 6. Dismiss
137
+
138
+ User: "Accept risk, deploys are rare."
139
+
140
+ Reviewer: "Understood. The consequence: every deploy that overlaps the 15-minute run can send a
141
+ duplicate to every invoice due that day, which is what the Goal rules out. Recording it as
142
+ accepted by you." Then the reviewer writes `**Decision:** Accept risk - duplicates possible
143
+ during deploys; accepted by owner`, keeps C1 open as a CRITICAL that is not fixed, and therefore
144
+ leaves the status at `planned` with the reason in the report. (In the saved review above, the
145
+ owner chose Fix A instead.)
146
+
147
+ Before applying a fix, the reviewer shows the edit:
148
+
149
+ ```text
150
+ Phase 2, step 1
151
+ - before: For each selected invoice, send the reminder, then set reminder_sent_at = now().
152
+ + after: For each selected invoice, claim it with UPDATE ... WHERE reminder_sent_at IS NULL
153
+ + RETURNING id; send only when a row came back; on a failed send, set it back to null.
154
+ ```
155
+
156
+ ## Good and bad findings
157
+
158
+ | Bad | Why | Good |
159
+ | --- | --- | --- |
160
+ | "Consider concurrency." | no evidence, no decision possible | "Two runs can select the same invoice (scheduler overlap, research §Risks); C1 with two fixes." |
161
+ | "Security could be improved." | which entry point, which hole? | "`setRemindersEnabled` trusts `clientId` from the form; any user can change another account's client." |
162
+ | "Tests might be insufficient." | which case is missing? | "No test for an account whose local date is still yesterday; the query uses the UTC date." |
163
+ | WARNING: "Rename `rem` to `reminder`." | a naming nit inflated to a warning | leave it out, or one SUGGESTION at most |
164
+ | SUGGESTION: "Maybe add a rollback." | a real risk hidden as a nicety | WARNING or CRITICAL with the rollback path as the fix |
165
+
166
+ ## A sound plan
167
+
168
+ When nothing is wrong, the review is short:
169
+
170
+ ```markdown
171
+ # Plan review: invoice-pdf-footer
172
+
173
+ Reviewed: plan.md @ 2026-10-02. Mode: quick. Verdict: ready.
174
+ Findings: 0 critical, 0 warning, 0 suggestion.
175
+ Grounding: 3/3 paths, 2/2 symbols, 3/3 commands
176
+
177
+ ## Lenses
178
+ | Lens | Result |
179
+ | --- | --- |
180
+ | all 13 lenses | PASS |
181
+
182
+ ## Findings
183
+ None. One phase, test-after, criteria read the generated PDF text.
184
+ ```
@@ -1,17 +1,22 @@
1
1
  ---
2
2
  name: softure-prd
3
3
  description: >
4
- Write or revise `context/foundation/prd.md` from accepted shape notes: goals and
5
- non-goals, users, functional requirements with stable IDs (FR-1…), non-functional
6
- requirements, success metrics, risks and out-of-scope, with a version that is bumped on
7
- every edit. Use after softure-shape, or when the product direction changes. Triggers:
8
- "write the PRD", "update the PRD", "turn the shape into requirements",
9
- "write down the requirements".
10
- argument-hint: "[--revise] [--auto]"
4
+ Write or revise `context/foundation/prd.md` from accepted shape notes (or, with a
5
+ warning, from raw notes): summary and insight, goals and non-goals, users, access
6
+ control, the primary flow, the core business rule, functional requirements with stable
7
+ IDs (FR-1…) and testable acceptance, measurable non-functional requirements, success
8
+ metrics with guardrails, risks, out-of-scope and open questions. Greenfield and
9
+ brownfield variants (brownfield marks every requirement new / modified / preserved /
10
+ removed). Challenges each must-have requirement, lints out implementation detail, never
11
+ invents what the input lacks, and bumps the version with a changelog on every revision.
12
+ Use after softure-shape, or when the product direction changes. Triggers: "write the PRD",
13
+ "update the PRD", "turn the shape into requirements", "write down the requirements".
14
+ argument-hint: "[--revise] [--from <notes-path>] [--auto]"
11
15
  allowed-tools:
12
16
  - Read
13
17
  - Glob
14
18
  - Grep
19
+ - Bash
15
20
  - Write
16
21
  - Edit
17
22
  - AskUserQuestion
@@ -25,100 +30,148 @@ The PRD is the contract between *why* (shape notes) and *in what order* (roadmap
25
30
  what must be true for users, with stable IDs that roadmap items, plans and reviews can cite.
26
31
  It does not say how to implement.
27
32
 
33
+ The skill turns decisions already made into requirements. It **never invents** a business
34
+ rule, a goal, a priority, a target or a non-goal the input does not contain: a gap becomes
35
+ an open question, visibly, so the owner can close it. Its interactive part is narrow: close
36
+ the gaps that change a requirement, and challenge the requirements before they are locked.
37
+
28
38
  ## Inputs
29
39
 
30
- - `context/foundation/shape-notes.md` with `status: accepted`. If it is missing or still a
31
- draft, stop and point to `softure-shape` (or ask the user to accept the draft).
32
- - An existing `prd.md` means **revise mode**: keep the IDs, bump `version`, and log the change
33
- (see Versioning).
34
- - For brownfield work, read the code paths the shape notes mention, so that requirements are
35
- stated relative to what exists.
40
+ - `context/workflow.json`. If missing, stop and point to `softure-init`.
41
+ - `context/foundation/shape-notes.md` with `status: accepted`. If it is missing, stop and
42
+ point to `softure-shape`. If it is a draft, show what is unfinished and ask whether to
43
+ accept it as is (Recommended: finish shaping first).
44
+ - `--from <path>`: raw notes instead of shape notes (a brief, a feedback dump). Allowed, but
45
+ run the input check below and say plainly that a PRD from unshaped notes carries many
46
+ gaps. Record `source: <path> (unshaped notes)`.
47
+ - An existing `prd.md` means **revise mode** (see Versioning).
48
+ - Brownfield: read the code paths the shape notes mention, so that requirements are stated
49
+ relative to what exists. Do not audit the code.
50
+
51
+ ## Input check
52
+
53
+ Before writing, score the input on six signals, one point each, and show the result:
54
+
55
+ ```
56
+ Input check (6 signals):
57
+ [x] Problem with evidence <found | missing>
58
+ [x] Primary person named (a role) <found | missing>
59
+ [ ] First flow as steps <found | missing>
60
+ [x] Core rule in one sentence <found | missing> (brownfield technical work: "No domain rule change" counts)
61
+ [x] No-gos listed <found | missing>
62
+ [ ] Success signal with a threshold <found | missing>
63
+ Score: 4/6
64
+ ```
65
+
66
+ Below 4, name each missing signal with its consequence for the PRD ("no first flow: the
67
+ primary flow and its FRs will be open questions"), never a generic "the input is thin".
68
+ Offer: shape first (Recommended) / write the PRD anyway, with the gaps as open questions /
69
+ cancel. `--auto`: write anyway and record the score under `## Decisions (auto)`.
36
70
 
37
71
  ## Procedure
38
72
 
39
- 1. **Extract.** From the shape notes, list the candidate goals, users, capabilities and
40
- constraints. Mark anything the notes do not support as an open question. Do not fill gaps
41
- by invention.
42
- 2. **Resolve open questions**, one per message, each with a recommended answer. Ask only those
43
- that change a requirement. Everything else goes to `## Open questions` with an owner.
44
- 3. **Write the requirements:**
73
+ 1. **Context type.** Take `context_type` from the shape notes. Without it, detect it as
74
+ `softure-shape` does (git history, lockfiles, source folders) and confirm it with one
75
+ question (`--auto`: take the detected value).
76
+ 2. **Extract and map.** Map each shape-notes section to its PRD section (mapping table in
77
+ `references/prd-template.md`). Keep the user's wording; change only the form the PRD
78
+ requires (FR sentences, given/when/then, tables). Carry every open question, `UNKNOWN`
79
+ and `(accepted gap)` over word for word. Where the input has nothing, write
80
+ `TODO: <what is missing> (OQ-<n>)` and add the open question. A missing core rule is a
81
+ **blocking** question; never infer a rule from the nouns in the sketch.
82
+ 3. **Resolve open questions**, one per message, each with a recommended answer and why. Ask
83
+ only those that change a `must` requirement or the core rule. Everything else stays in
84
+ `## Open questions` with an owner.
85
+ 4. **Write the requirements:**
45
86
  - Each FR is one **observable behaviour**: "When <trigger>, <actor> can/sees <result>".
46
- It never names an implementation ("use Redis", "add a table").
87
+ It never names an implementation ("use a queue", "add a table").
47
88
  - Each FR gets acceptance criteria someone else could test: given/when/then, or a short
48
- bullet list.
89
+ list. Cover the empty case and the failure case where they exist.
49
90
  - Priority: `must` (the release fails without it), `should`, `could`. Roughly 60% of
50
91
  effort or less should be `must`.
51
- - NFRs are measurable (latency p95, availability, data retention, accessibility level,
52
- supported locales), and only where they matter.
53
- 4. **Mark generic capabilities.** For FRs that a SOFTURE module covers (WORKFLOW §10), add
92
+ - The primary flow lists the first flow's steps, each pointing at the FR behind it.
93
+ - Brownfield: every FR carries `Change: new | modified | preserved | removed`, and every
94
+ line of preserved behaviour in the shape notes becomes a `preserved` FR with its own
95
+ acceptance, not a non-goal.
96
+ - NFRs are measurable (response time a user perceives, availability, retention,
97
+ accessibility level, supported browsers or locales), and only where they matter.
98
+ 5. **Challenge the must FRs.** For each `must` FR, one message: the strongest
99
+ counter-argument specific to this FR, as 2 or 3 options plus "It stands as written" last
100
+ (so the challenge is considered before it is dismissed). Possible outcomes: keep, split,
101
+ demote, drop. Record the outcome under the FR as `Challenge: <argument> → <resolution>`.
102
+ With more than eight `must` FRs, challenge them in batches of up to four per message.
103
+ 6. **Mark generic capabilities.** For FRs that a SOFTURE module covers (WORKFLOW §10), add
54
104
  `Module: @softure-ai/<name>` so the roadmap and plan reuse it instead of rebuilding it.
55
- 5. **Check consistency:**
56
- - every goal has at least one FR;
57
- - every `must` FR traces to a problem in the shape notes;
58
- - every success metric is measurable with something that exists or is planned in an FR;
59
- - nothing in *Out of scope* contradicts an FR.
60
- 6. Show the FR table, ask "Accept? (Recommended: accept)", then apply corrections and write.
105
+ 7. **Self-review before writing:**
106
+ - *Structure:* every section of the template for this `context_type`, in order, with the
107
+ frontmatter keys present; no data-model, architecture, testing or deployment section.
108
+ - *Consistency:* every goal has at least one FR; every `must` FR traces to a problem in
109
+ the shape notes; every primary-flow step has an FR; every success metric is measurable
110
+ with something that exists or is planned in an FR; nothing in *Out of scope* or
111
+ *Non-goals* contradicts an FR; every `TODO:` has its open question.
112
+ - *Leak lint:* scan for vendors, data-model notation, runtime locations, enforcement
113
+ mechanisms, protocols and components acting as the rule (`references/leak-lint.md`).
114
+ Show each hit with a proposed outside-observable rewrite; never rewrite silently.
115
+ 8. Show the summary, the FR table and the open questions (blocking first), and ask
116
+ "Accept? (Recommended: accept)". A PRD with a blocking `TODO:` cannot be accepted:
117
+ recommend keeping it as `draft` and say which questions block. Apply corrections, set
118
+ `status` and `updated`, and write.
61
119
 
62
120
  ## Output: `context/foundation/prd.md`
63
121
 
64
- ```markdown
65
- ---
66
- project: "<name>"
67
- version: 1
68
- status: draft | accepted
69
- created: <YYYY-MM-DD>
70
- updated: <YYYY-MM-DD>
71
- source: shape-notes.md (session <n>)
72
- ---
122
+ Section order (greenfield): Summary, Goals, Non-goals, Users, Access control, Primary flow,
123
+ Business rules, Functional requirements, Non-functional requirements, Success metrics (with
124
+ Guardrails), Risks, Out of scope, Open questions, Changelog, Decisions (auto). Brownfield
125
+ adds `## Current system` after Summary and `## Compatibility and preserved behaviour` after
126
+ the non-functional requirements, and frames every section as a delta.
73
127
 
74
- # PRD v<version>: <theme>
75
-
76
- ## Summary (5 lines: problem, who, outcome, appetite, release boundary)
77
- ## Goals (G-1…, each measurable)
78
- ## Non-goals
79
- ## Users (primary / secondary / not for; link to shape notes)
80
- ## Current system (brownfield: what stays as is, explicitly)
81
- ## Functional requirements
82
- | ID | Requirement (observable behaviour) | Priority | Goal | Module |
83
- |---|---|---|---|---|
84
- | FR-1 | When …, … can … | must | G-1 | @softure-ai/auth |
85
-
86
- ### FR-1: <short name>
87
- Acceptance:
88
- - Given …, when …, then …
89
- Notes: edge cases, copy constraints, data rules.
90
-
91
- ## Non-functional requirements (NFR-1…, each with a number)
92
- ## Success metrics (metric → baseline → target → how measured → when checked)
93
- ## Risks (risk → likelihood → impact → mitigation)
94
- ## Out of scope
95
- ## Open questions (question → owner → needed by)
96
- ## Changelog (v<n> <date>: what changed and why)
97
- ```
128
+ The full templates, the rules per section, what a PRD never contains and the shape-notes
129
+ mapping: read `references/prd-template.md` before drafting. A complete greenfield PRD, the
130
+ brownfield parts, a revision and bad requirements with fixes: read
131
+ `references/example-prd.md`.
98
132
 
99
- Write in `workflow.json` → `language`. IDs stay in this ASCII form whatever the language.
133
+ Write in `workflow.json` → `language`. Headings and IDs (`G-`, `FR-`, `NFR-`, `OQ-`) stay in
134
+ this ASCII form whatever the language.
100
135
 
101
136
  ## Versioning
102
137
 
103
138
  - A new PRD starts at `version: 1`. Every revise run increments `version` and adds a
104
- `## Changelog` line.
139
+ `## Changelog` line: what changed, why, and which roadmap items cite the changed FRs.
140
+ - Before revising an `accepted` PRD, copy it to
141
+ `context/foundation/archive/<YYYY-MM-DD>-prd.md` (same day: `-2`, `-3`), so the accepted
142
+ version stays readable next to the new draft. A new revision starts as `status: draft`.
105
143
  - IDs are **never reused or renumbered**. A dropped FR stays, with its row struck through
106
144
  (`~~FR-7~~`) and a reason. New FRs take the next free number.
145
+ - Revise only what the new input changes; do not rephrase accepted FRs on the way through.
107
146
  - If a roadmap exists with `prd_version` lower than the new version, say which items cite
108
147
  changed FRs and recommend running `softure-roadmap --revise`.
109
148
 
110
149
  ## `--auto`
111
150
 
112
- Write only what the shape notes support. Unsupported or ambiguous points go to
113
- `## Open questions`. Leave `status: draft` and record each interpretation under
114
- `## Decisions (auto)`.
151
+ Write only what the input supports, and never ask:
152
+ - draft shape notes or a low input-check score: proceed, record it under
153
+ `## Decisions (auto)`;
154
+ - unsupported or ambiguous points go to `## Open questions` with `TODO:` markers; a missing
155
+ core rule stays a blocking question;
156
+ - challenge round: write the strongest counter-argument under each `must` FR, but keep the
157
+ FR as the input states it (never drop or demote without the owner), and record it;
158
+ - leak lint: apply the outside-observable rewrites, list the original phrases as forward
159
+ notes in the handoff, and record each one;
160
+ - revise mode: archive the accepted version first, as above;
161
+ - leave `status: draft` and record each interpretation under `## Decisions (auto)`.
115
162
 
116
163
  ## Quality bar
117
164
 
118
- - [ ] No FR names a technology or a table.
165
+ - [ ] No FR or NFR names a technology, a vendor, a table or a mechanism (Module column and
166
+ brownfield `## Current system` excepted).
119
167
  - [ ] Every FR has acceptance criteria a tester could run without asking the author.
120
- - [ ] Goals and success metrics have numbers or explicit yes/no checks.
168
+ - [ ] Every primary-flow step has an FR, and every goal has at least one FR.
169
+ - [ ] The core rule is one sentence, or a blocking open question.
170
+ - [ ] Goals and success metrics have numbers or explicit yes/no checks; guardrails exist.
171
+ - [ ] Access control is stated, even for a single-user tool.
121
172
  - [ ] Out of scope is non-empty. If nothing is excluded, the scope is not shaped yet.
173
+ - [ ] Brownfield: every preserved behaviour is a `preserved` FR with acceptance.
174
+ - [ ] Every `TODO:` has a matching `OQ-<n>`; nothing was invented to fill a gap.
122
175
  - [ ] IDs are stable across versions.
123
176
 
124
177
  ## Do not
@@ -126,7 +179,13 @@ Write only what the shape notes support. Unsupported or ambiguous points go to
126
179
  - Do not slice the work into milestones. That is `softure-roadmap`.
127
180
  - Do not copy the shape notes wholesale. Link to them and keep the PRD about requirements.
128
181
  - Do not silently change an accepted FR. Every change goes through the changelog.
182
+ - Do not write a data model, architecture, test strategy or deployment plan. Such content in
183
+ the input is listed in the handoff as forward notes, never dropped silently.
184
+ - Do not run `softure-roadmap` yourself; the owner reviews the PRD first.
129
185
 
130
186
  ## Handoff
131
187
 
132
- Accepted PRD → `softure-roadmap`.
188
+ Report: the path and version, context type, sections complete vs with `TODO:`, the number of
189
+ open questions (blocking first), the challenges that changed an FR, and forward notes from
190
+ the input that are not in the PRD (stack hints, data-model ideas, implementation notes) so
191
+ the plan can pick them up. Then: accepted PRD → `softure-roadmap`.