baldart 3.41.0 → 4.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.
- package/CHANGELOG.md +34 -0
- package/VERSION +1 -1
- package/framework/.claude/agents/REGISTRY.md +72 -24
- package/framework/.claude/agents/api-perf-cost-auditor.md +12 -5
- package/framework/.claude/agents/code-reviewer.md +30 -23
- package/framework/.claude/agents/codebase-architect.md +47 -43
- package/framework/.claude/agents/coder.md +29 -18
- package/framework/.claude/agents/doc-reviewer.md +55 -28
- package/framework/.claude/agents/plan-auditor.md +77 -12
- package/framework/.claude/agents/prd-card-writer.md +43 -13
- package/framework/.claude/agents/prd.md +22 -3
- package/framework/.claude/agents/qa-sentinel.md +33 -15
- package/framework/.claude/agents/security-reviewer.md +65 -10
- package/framework/.claude/agents/senior-researcher.md +8 -1
- package/framework/.claude/agents/ui-expert.md +22 -7
- package/framework/.claude/commands/check.md +31 -11
- package/framework/.claude/commands/codexreview.md +48 -29
- package/framework/.claude/commands/new.md +29 -330
- package/framework/.claude/commands/qa.md +57 -37
- package/framework/.claude/skills/context-primer/SKILL.md +29 -8
- package/framework/.claude/skills/doc-writing-for-rag/SKILL.md +36 -36
- package/framework/.claude/skills/frontend-design/SKILL.md +10 -8
- package/framework/.claude/skills/new/SKILL.md +409 -302
- package/framework/.claude/skills/prd/SKILL.md +67 -38
- package/framework/.claude/skills/prd/assets/card-template.yml +22 -26
- package/framework/.claude/skills/prd/assets/epic-template.yml +5 -5
- package/framework/.claude/skills/prd/assets/state-template.md +25 -3
- package/framework/.claude/skills/prd/references/api-perf-gate.md +143 -33
- package/framework/.claude/skills/prd/references/audit-phase.md +48 -34
- package/framework/.claude/skills/prd/references/backlog-phase.md +38 -11
- package/framework/.claude/skills/prd/references/discovery-phase.md +121 -44
- package/framework/.claude/skills/prd/references/impact-analysis.md +127 -23
- package/framework/.claude/skills/prd/references/prd-add-phase.md +18 -214
- package/framework/.claude/skills/prd/references/prd-writing-phase.md +52 -42
- package/framework/.claude/skills/prd/references/research-phase.md +105 -19
- package/framework/.claude/skills/prd/references/ui-design-phase.md +20 -8
- package/framework/.claude/skills/prd/references/validation-phase.md +97 -72
- package/framework/.claude/skills/prd-add/SKILL.md +70 -20
- package/framework/.claude/skills/simplify/SKILL.md +22 -12
- package/framework/.claude/skills/ui-design/SKILL.md +26 -7
- package/framework/.claude/skills/webapp-testing/SKILL.md +6 -4
- package/framework/.claude/skills/worktree-manager/SKILL.md +206 -143
- package/framework/agents/coding-standards.md +85 -0
- package/framework/agents/skills-mapping.md +85 -82
- package/framework/agents/testing.md +6 -4
- package/framework/templates/baldart.config.template.yml +29 -7
- package/package.json +1 -1
- package/src/commands/configure.js +43 -9
- package/framework/.claude/skills/prd-add/references/impact-analysis.md +0 -233
|
@@ -1,214 +1,18 @@
|
|
|
1
|
-
# /prd-add — Change Request Phase
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Detection signal: the user's answer introduces NEW entities (endpoints, collections,
|
|
20
|
-
pages, roles, flows) that were not part of the original feature scope.
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## Execution model
|
|
25
|
-
|
|
26
|
-
Sequential, single-turn analysis + selective multi-turn re-execution.
|
|
27
|
-
|
|
28
|
-
| Step | Phase | Description |
|
|
29
|
-
|------|-------|-------------|
|
|
30
|
-
| 0 | Session Locate | Find active PRD state file |
|
|
31
|
-
| 1 | Intake | Capture and classify change request |
|
|
32
|
-
| 2 | Impact Analysis | ICIAS protocol (3 phases) |
|
|
33
|
-
| 3 | Verdict | Present impact matrix, ask confirmation |
|
|
34
|
-
| 4 | Selective Execution | Re-run only PATCH/REDO phases |
|
|
35
|
-
| 5 | Delta Commit | Commit changes with `[PRD-ADD]` prefix |
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
## Hard rules
|
|
40
|
-
|
|
41
|
-
1. NEVER start from scratch. Always build on the existing PRD session.
|
|
42
|
-
2. Read the state file and PRD before any analysis.
|
|
43
|
-
3. Follow ICIAS protocol exactly — read [impact-analysis.md](impact-analysis.md).
|
|
44
|
-
4. Present verdict BEFORE executing changes. Wait for user confirmation.
|
|
45
|
-
5. When re-running phases, follow the SAME reference files as `/prd` (discovery-phase.md, etc.).
|
|
46
|
-
6. Update the state file with a `## Change Requests` section tracking all CR history.
|
|
47
|
-
7. Commit with format: `[PRD-ADD] <slug>: <brief CR description>`
|
|
48
|
-
8. **Every message MUST end with the CR Progress Bar.**
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## Step 0 — Session Locate
|
|
53
|
-
|
|
54
|
-
1. List `${paths.prd_dir}/sessions/` for state files.
|
|
55
|
-
2. If exactly ONE active session (status != `completed`): use it.
|
|
56
|
-
3. If multiple active sessions: ask user which one.
|
|
57
|
-
4. If zero sessions: inform user, suggest `/prd` instead.
|
|
58
|
-
5. Read the state file AND the PRD document (if exists).
|
|
59
|
-
|
|
60
|
-
---
|
|
61
|
-
|
|
62
|
-
## Step 1 — Intake
|
|
63
|
-
|
|
64
|
-
1. If change description provided as argument: use it.
|
|
65
|
-
2. If not: ask the user to describe the change.
|
|
66
|
-
|
|
67
|
-
**Classify the change type** (from CIA literature):
|
|
68
|
-
|
|
69
|
-
- **Addition**: new entity (endpoint, collection, page, role, flow)
|
|
70
|
-
- **Modification**: change to existing entity (new field, changed behavior)
|
|
71
|
-
- **Deletion**: removal of planned entity
|
|
72
|
-
|
|
73
|
-
Record in state file under `## Change Requests`:
|
|
74
|
-
|
|
75
|
-
```markdown
|
|
76
|
-
### CR-N: <title>
|
|
77
|
-
- Type: Addition | Modification | Deletion
|
|
78
|
-
- Description: <user's description verbatim>
|
|
79
|
-
- Date: YYYY-MM-DD
|
|
80
|
-
- Status: analyzing
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
**Immediately proceed to Step 2.**
|
|
84
|
-
|
|
85
|
-
---
|
|
86
|
-
|
|
87
|
-
## Step 2 — Impact Analysis (ICIAS Protocol)
|
|
88
|
-
|
|
89
|
-
**Read [impact-analysis.md](impact-analysis.md) for the full protocol.**
|
|
90
|
-
|
|
91
|
-
Quick summary — 3 phases executed in sequence:
|
|
92
|
-
|
|
93
|
-
### Phase 1: Semantic Scan
|
|
94
|
-
|
|
95
|
-
Evaluate each of the 10 dimensions against the change request.
|
|
96
|
-
For each dimension, assign an initial impact assessment (0=none, 1-3=depth).
|
|
97
|
-
|
|
98
|
-
### Phase 2: Structural Propagation
|
|
99
|
-
|
|
100
|
-
Apply the coupling matrix to find transitive impacts.
|
|
101
|
-
Max 2 hops, confidence degrades per hop.
|
|
102
|
-
|
|
103
|
-
### Phase 3: ICIAS Scoring
|
|
104
|
-
|
|
105
|
-
For each impacted dimension: `Score = I x C x A`
|
|
106
|
-
|
|
107
|
-
- I = Impact depth (1=cosmetic, 2=logic, 3=structural)
|
|
108
|
-
- C = Confidence (1=inferred, 2=probable, 3=certain)
|
|
109
|
-
- A = Artifact Stakes (pre-assigned per dimension)
|
|
110
|
-
|
|
111
|
-
Classify: **SKIP** (score <= 3), **PATCH** (4-9), **REDO** (>= 10)
|
|
112
|
-
|
|
113
|
-
---
|
|
114
|
-
|
|
115
|
-
## Step 3 — Verdict
|
|
116
|
-
|
|
117
|
-
Present the impact matrix to the user:
|
|
118
|
-
|
|
119
|
-
```text
|
|
120
|
-
### Impact Analysis — CR-N: <title>
|
|
121
|
-
|
|
122
|
-
| # | Dimension | Direct | Cascade | I | C | A | Score | Verdict |
|
|
123
|
-
|---|-----------|--------|---------|---|---|---|-------|---------|
|
|
124
|
-
| D1 | Target users | - | - | 0 | - | 1 | 0 | SKIP |
|
|
125
|
-
| D2 | User journey | yes | - | 2 | 3 | 2 | 12 | REDO |
|
|
126
|
-
| D3 | Data model | - | D4->D3 | 1 | 2 | 3 | 6 | PATCH |
|
|
127
|
-
| ... | ... | ... | ... | ... | ... | ... | ... | ... |
|
|
128
|
-
|
|
129
|
-
**Fasi da rieseguire:**
|
|
130
|
-
- Discovery: PATCH (D2, D4 da aggiornare)
|
|
131
|
-
- UI Design: REDO (nuovo flow)
|
|
132
|
-
- PRD: PATCH (sezioni 4, 6, 9)
|
|
133
|
-
- Backlog Cards: PATCH (nuove cards + update esistenti)
|
|
134
|
-
|
|
135
|
-
Vuoi procedere con questa analisi?
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
**STOP.** Wait for user confirmation.
|
|
139
|
-
|
|
140
|
-
If user disagrees with any verdict, adjust manually and re-present.
|
|
141
|
-
|
|
142
|
-
---
|
|
143
|
-
|
|
144
|
-
## Step 4 — Selective Execution
|
|
145
|
-
|
|
146
|
-
Execute ONLY phases with PATCH or REDO verdict, in original phase order.
|
|
147
|
-
|
|
148
|
-
### For Discovery dimensions (PATCH/REDO)
|
|
149
|
-
|
|
150
|
-
- **PATCH**: Run `codebase-architect` on affected dimensions only.
|
|
151
|
-
Update state file checklist entries. No user questions unless ambiguous.
|
|
152
|
-
- **REDO**: Full re-discovery for that dimension (same as /prd Step 2 loop
|
|
153
|
-
but scoped to affected dimensions only). May require user questions.
|
|
154
|
-
|
|
155
|
-
### For UI Design (PATCH/REDO)
|
|
156
|
-
|
|
157
|
-
- **PATCH**: Describe changes needed to existing design.html. Ask user
|
|
158
|
-
if they want a full design refresh or text-only update to PRD.
|
|
159
|
-
- **REDO**: Re-run full UI Design phase (Steps 3a-3d from /prd).
|
|
160
|
-
|
|
161
|
-
### For PRD (PATCH/REDO)
|
|
162
|
-
|
|
163
|
-
- **PATCH**: Edit specific PRD sections. Add/modify user stories, API
|
|
164
|
-
contracts, data model, acceptance criteria as needed. Preserve
|
|
165
|
-
unchanged sections verbatim.
|
|
166
|
-
- **REDO**: Rewrite major PRD sections (rare — only when change
|
|
167
|
-
fundamentally alters the feature).
|
|
168
|
-
|
|
169
|
-
### For Backlog Cards (PATCH/REDO)
|
|
170
|
-
|
|
171
|
-
- **PATCH**: Create new cards for new work. Update `depends_on` in
|
|
172
|
-
existing cards if dependencies changed. Do NOT rewrite existing cards
|
|
173
|
-
unless acceptance criteria changed.
|
|
174
|
-
- **REDO**: Regenerate affected cards via `prd-card-writer` agent.
|
|
175
|
-
Preserve cards that are unaffected.
|
|
176
|
-
|
|
177
|
-
### For ISA (always re-scan if any PATCH/REDO exists)
|
|
178
|
-
|
|
179
|
-
Run a delta ISA scan focused on the new requirement. Merge new
|
|
180
|
-
touchpoints into existing ISA table. Assign new ISA-N IDs.
|
|
181
|
-
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
## Step 5 — Delta Commit
|
|
185
|
-
|
|
186
|
-
1. Update state file:
|
|
187
|
-
- CR status: `applied`
|
|
188
|
-
- Update comprehension checklist with changes
|
|
189
|
-
- Update `## Change Requests` with summary of what was done
|
|
190
|
-
2. Re-run API Performance Gate (Step 4.5) if API/data model changed.
|
|
191
|
-
3. Stage ONLY modified files (explicit names).
|
|
192
|
-
4. Commit: `[PRD-ADD] <slug>: <CR description>`
|
|
193
|
-
|
|
194
|
-
---
|
|
195
|
-
|
|
196
|
-
## CR Progress Bar — mandatory on every message
|
|
197
|
-
|
|
198
|
-
```text
|
|
199
|
-
---
|
|
200
|
-
Change Request: <slug> — CR-N
|
|
201
|
-
|
|
202
|
-
| # | Fase | Verdict | Stato |
|
|
203
|
-
|---|------|---------|-------|
|
|
204
|
-
| 1 | Intake | - | pending/done |
|
|
205
|
-
| 2 | Impact Analysis | - | pending/running/done |
|
|
206
|
-
| 3 | Verdict & conferma | - | pending/running/done |
|
|
207
|
-
| 4a | Discovery (delta) | SKIP/PATCH/REDO | pending/running/done/skipped |
|
|
208
|
-
| 4b | UI Design (delta) | SKIP/PATCH/REDO | pending/running/done/skipped |
|
|
209
|
-
| 4c | PRD (delta) | SKIP/PATCH/REDO | pending/running/done/skipped |
|
|
210
|
-
| 4d | Backlog Cards (delta) | SKIP/PATCH/REDO | pending/running/done/skipped |
|
|
211
|
-
| 5 | Delta Commit | - | pending/done |
|
|
212
|
-
|
|
213
|
-
Prossimo passo: <what happens next>
|
|
214
|
-
```
|
|
1
|
+
# /prd-add — Change Request Phase (redirect stub)
|
|
2
|
+
|
|
3
|
+
> **This file is NOT the implementation.** It used to carry a hand-maintained,
|
|
4
|
+
> worktree-UNAWARE copy of the Change Request flow that silently diverged from the
|
|
5
|
+
> real skill (it scanned `sessions/` in the main repo and operated on the wrong
|
|
6
|
+
> location for every worktree-isolated PRD session since v3.22.0).
|
|
7
|
+
>
|
|
8
|
+
> The authoritative, worktree-aware Change Request implementation is the **`prd-add`
|
|
9
|
+
> skill**: [`../../prd-add/SKILL.md`](../../prd-add/SKILL.md)
|
|
10
|
+
> (installed as `.claude/skills/prd-add/`).
|
|
11
|
+
|
|
12
|
+
When a Change Request is triggered — manually (`/prd-add`) or auto-triggered by `/prd`
|
|
13
|
+
discovery when an answer reveals new out-of-scope entities — invoke the `prd-add` skill
|
|
14
|
+
and follow it. The ICIAS impact-analysis protocol it uses is defined once in
|
|
15
|
+
[`impact-analysis.md`](impact-analysis.md) (the canonical SSOT).
|
|
16
|
+
|
|
17
|
+
Do not re-introduce the CR flow steps here — they live in exactly one place so they
|
|
18
|
+
cannot drift again.
|
|
@@ -14,28 +14,25 @@ Mark task 3 as `in_progress`.
|
|
|
14
14
|
3. **Resolve canonical sources** before writing:
|
|
15
15
|
- Read `${paths.references_dir}/ssot-registry.md` to identify the macro feature and any
|
|
16
16
|
existing canonical docs.
|
|
17
|
-
-
|
|
17
|
+
- If a Canonical Ownership Matrix exists for this project, check the path defined in
|
|
18
|
+
`.baldart/overlays/prd.md § Canonical Ownership Matrix`; if absent, skip with a note.
|
|
18
19
|
- Identify which existing PRDs, ADRs, reference docs, or backlog cards are canonical
|
|
19
20
|
for this feature area.
|
|
20
21
|
- **Mockup-derived canonical sources** (when `mockups.status` ∈ {`provided`, `partial`}
|
|
21
22
|
in state file): treat `${paths.prd_dir}/<slug>/mockups/` as a canonical visual
|
|
22
23
|
reference. Add a row to the PRD Canonical Sources table:
|
|
23
|
-
`|
|
|
24
|
+
`| Original mockups | ${paths.prd_dir}/<slug>/mockups/ |`. If chat images were
|
|
24
25
|
analyzed without being copied to disk, add: `| Mockup chat | inline in PRD session — see Design Reference section |`.
|
|
25
|
-
3. **Incorporate research findings** (if `## Research Findings` in state file is populated):
|
|
26
|
-
- Reference best practices in data model, API, and architecture decisions.
|
|
27
|
-
- Cite sources in PRD rationale sections.
|
|
28
|
-
- Add anti-patterns from research to "Edge cases and failure modes" table.
|
|
29
|
-
- If regulatory findings exist: add a dedicated "Compliance Requirements" section.
|
|
30
|
-
- Include a "Research-Informed Decisions" subsection listing decisions influenced
|
|
31
|
-
by research, with brief rationale and source reference.
|
|
32
26
|
3.5. **Schema Verification Gate (MANDATORY if feature touches the persistence layer)**
|
|
33
27
|
|
|
34
28
|
Read `stack.database` from `baldart.config.yml`. If empty AND the feature
|
|
35
29
|
description mentions data persistence, ASK the user which database is in
|
|
36
|
-
use
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
use (once). If the user's answer is not a recognized database type or they
|
|
31
|
+
answer "I don't know", log a one-line diagnostic, degrade to the universal
|
|
32
|
+
vocabulary (`entity`/`field`), and proceed — do NOT loop. Persist a valid
|
|
33
|
+
answer to `baldart.config.yml` (offer `npx baldart configure` if multiple
|
|
34
|
+
keys are missing). Skip this gate when `stack.database: none` or the feature
|
|
35
|
+
is stateless.
|
|
39
36
|
|
|
40
37
|
The vocabulary in this gate adapts to `stack.database`:
|
|
41
38
|
- Firestore / MongoDB / DynamoDB → "collections" / "documents" / "fields"
|
|
@@ -60,9 +57,9 @@ Mark task 3 as `in_progress`.
|
|
|
60
57
|
3. Build a `## Schema Verification` section in the PRD (see template below).
|
|
61
58
|
4. Mark each {field}: `✅ existing` | `🆕 new` | `❌ NOT FOUND`.
|
|
62
59
|
5. **GATE**: if ANY {field} is `❌ NOT FOUND` and NOT marked as `🆕 new`:
|
|
63
|
-
- STOP — do not advance to Section 5 (
|
|
60
|
+
- STOP — do not advance to Section 5 (Data Model).
|
|
64
61
|
- Ask the user: "Is `{fieldName}` in {entity} `{entityName}` a new {field} or a naming error?"
|
|
65
|
-
- If new: add full schema definition in PRD Section 5 and mark `🆕`.
|
|
62
|
+
- If new: add full schema definition in PRD Section 5 (Data Model) and mark `🆕`.
|
|
66
63
|
- If error: correct the name.
|
|
67
64
|
|
|
68
65
|
**Template `## Schema Verification`** (insert after PRD Acceptance Criteria section):
|
|
@@ -89,14 +86,21 @@ Mark task 3 as `in_progress`.
|
|
|
89
86
|
`updatedAt`/`updated_at` are universal in their stack — do not require
|
|
90
87
|
verification.
|
|
91
88
|
|
|
92
|
-
4.
|
|
89
|
+
4. **Incorporate research findings** (if `## Research Findings` in state file is populated):
|
|
90
|
+
- Reference best practices in data model, API, and architecture decisions.
|
|
91
|
+
- Cite sources in PRD rationale sections.
|
|
92
|
+
- Add anti-patterns from research to "Edge cases and failure modes" table.
|
|
93
|
+
- If regulatory findings exist: add a dedicated "Compliance Requirements" section.
|
|
94
|
+
- Include a "Research-Informed Decisions" subsection listing decisions influenced
|
|
95
|
+
by research, with brief rationale and source reference.
|
|
96
|
+
5. Write `docs/prd/<slug>/PRD.md` using the template from `assets/prd-template.md`.
|
|
93
97
|
|
|
94
98
|
### PRD sections checklist
|
|
95
99
|
|
|
96
100
|
Every PRD MUST include these sections (remove only when genuinely N/A):
|
|
97
101
|
|
|
98
102
|
- Problem statement
|
|
99
|
-
-
|
|
103
|
+
- Strategic rationale (Section 1b — from `## Business Rationale` in state file)
|
|
100
104
|
- Goals / non-goals
|
|
101
105
|
- Personas
|
|
102
106
|
- User stories
|
|
@@ -105,18 +109,20 @@ Every PRD MUST include these sections (remove only when genuinely N/A):
|
|
|
105
109
|
table** — MANDATORY if any compound query / multi-column index exists. Pick
|
|
106
110
|
the variant matching `stack.database`: Firestore Composite, Postgres B-tree,
|
|
107
111
|
MongoDB compound, DynamoDB GSI/LSI. See `assets/prd-template.md § 5`.)
|
|
108
|
-
- API contract changes (endpoints
|
|
112
|
+
- API contract changes (ALL endpoints — new routes are NOT exempt — request/response, validation)
|
|
109
113
|
- **Design Reference & Mockup Inventory** (if UI impact ≠ N/A — populate from
|
|
110
114
|
`mockups.*`, `mockup_analysis.*`, `step_3_mode`, and `screens_in_scope[]` in
|
|
111
115
|
the state file. Include the screen inventory table, the component mapping
|
|
112
116
|
table when `features.has_design_system: true`, and the source-files
|
|
113
117
|
traceability list. When `mockups.status: none`, the section is still present
|
|
114
|
-
with the table empty and a note "Design
|
|
115
|
-
- UI specifications (if applicable —
|
|
116
|
-
state file
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
with the table empty and a note "Design generated in Step 3 — see design.html".)
|
|
119
|
+
- UI specifications (if applicable — when `## UI Element Inventory` is present in the
|
|
120
|
+
state file, include the full inventory table verbatim and map each UI element to
|
|
121
|
+
the requirement it satisfies; when `step_3_mode: skipped` the inventory is absent —
|
|
122
|
+
populate this section from `mockups/` directory contents or, if no mockups exist,
|
|
123
|
+
write a placeholder noting "UI design deferred — populate before implementation".
|
|
124
|
+
Reference `design.html` path when available. Do NOT duplicate the screen list from
|
|
125
|
+
the Design Reference section above — link to it.)
|
|
120
126
|
- i18n specification (dictionary keys, locale files)
|
|
121
127
|
- Acceptance criteria (grouped by area: one group per persona drawn from
|
|
122
128
|
`identity.audience_segments[]`, plus cross-cutting groups: API, i18n,
|
|
@@ -142,7 +148,6 @@ Before presenting the PRD:
|
|
|
142
148
|
|
|
143
149
|
- Verify canonical sources resolve through ssot-registry or valid backlog links.
|
|
144
150
|
- Flag any `REGISTRY_GAP` (feature not yet in ssot-registry).
|
|
145
|
-
- Flag stale shared-hub markers if `Last updated` conflicts with `git log -1`.
|
|
146
151
|
- Remove temp/local/absolute paths from canonical sections.
|
|
147
152
|
|
|
148
153
|
## Step 4.5 — API Performance Gate
|
|
@@ -152,32 +157,37 @@ Before presenting the PRD:
|
|
|
152
157
|
Before presenting the PRD to the user, run the API Performance Gate to catch
|
|
153
158
|
cost and performance anti-patterns while they are still cheap to fix.
|
|
154
159
|
|
|
155
|
-
**
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
160
|
+
**Delegated to the `api-perf-cost-auditor` agent** — `api-perf-gate.md` is its gate
|
|
161
|
+
specification, not an inline checklist the orchestrator runs itself.
|
|
162
|
+
|
|
163
|
+
### Procedure
|
|
164
|
+
|
|
165
|
+
1. **Spawn the `api-perf-cost-auditor` agent** via the Task tool (`subagent_type: api-perf-cost-auditor`,
|
|
166
|
+
`mode: bypassPermissions`). Pass it: (a) the PRD path, (b) the instruction to run the
|
|
167
|
+
full 5-gate protocol defined in `framework/.claude/skills/prd/references/api-perf-gate.md`
|
|
168
|
+
as its spec, and (c) the resolved `stack.database` / `stack.deployment` from
|
|
169
|
+
`baldart.config.yml` for the pricing/cost model. Gate 5 (Text Scan) ALWAYS runs; Gates 1-4
|
|
170
|
+
(Data Model, Query & Index, Serverless, Caching) run when Gate 5 matches OR the PRD has
|
|
171
|
+
API/data-model sections — otherwise the agent records the Gate 5 result and notes the 1-4 skip.
|
|
172
|
+
2. **Read the agent's returned findings** (severity-tagged: CRITICAL/HIGH/MEDIUM/LOW).
|
|
173
|
+
3. Apply the findings to the PRD (the orchestrator owns the edits — the agent only reports):
|
|
174
|
+
- CRITICAL/HIGH: edit the PRD directly (add NFR, modify API contract, add edge case) before
|
|
175
|
+
the user sees it.
|
|
176
|
+
- MEDIUM: add to the edge-cases table.
|
|
168
177
|
- LOW: note in state file only.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
178
|
+
4. If CRITICAL findings were resolved, add a `### Performance-Informed Decisions` subsection to the PRD.
|
|
179
|
+
5. Update state file `## API Performance Gate` (status + findings) so the card-level audit
|
|
180
|
+
(audit-phase Step 6) can read prior gate verdicts.
|
|
172
181
|
|
|
173
|
-
**Gate:** all CRITICAL findings resolved in PRD
|
|
182
|
+
**Gate (BLOCKING):** all CRITICAL findings must be resolved in the PRD before Present & Confirm —
|
|
183
|
+
do NOT present a PRD with an unresolved CRITICAL performance/cost finding.
|
|
174
184
|
|
|
175
185
|
## Present and Confirm
|
|
176
186
|
|
|
177
187
|
1. Update state file `## Confirmed Specs` with FR/NFR lists.
|
|
178
188
|
2. Present structured summary to user: all FR + NFR + visual specs.
|
|
179
189
|
3. If API Performance Gate ran, include a brief summary:
|
|
180
|
-
`**Performance Gate**: N findings
|
|
190
|
+
`**Performance Gate**: N findings integrated in PRD (X critical resolved, Y high as NFR).`
|
|
181
191
|
|
|
182
192
|
**STOP.** Wait for user confirmation. If user requests changes, edit PRD.md and
|
|
183
193
|
re-present. Do NOT proceed to backlog cards without explicit user approval.
|
|
@@ -8,10 +8,17 @@ for complex/novel features.
|
|
|
8
8
|
|
|
9
9
|
## Trigger Evaluation
|
|
10
10
|
|
|
11
|
-
Evaluate research need when comprehension reaches **~75%**
|
|
12
|
-
dimensions covered
|
|
11
|
+
Evaluate research need when comprehension reaches **~75%** of non-test
|
|
12
|
+
dimensions covered. The discovery model has **COMPREHENSION_DIMENSION_COUNT = 11**
|
|
13
|
+
dimensions (0–10). Dimension 10 (Test strategy) is the single test dimension;
|
|
14
|
+
the remaining 10 are non-test. The 75% threshold is therefore **8/10 non-test
|
|
15
|
+
dimensions covered**. This allows background research to run while the last
|
|
13
16
|
discovery questions are being asked.
|
|
14
17
|
|
|
18
|
+
<!-- COMPREHENSION_DIMENSION_COUNT = 11 (dims 0-10); non-test = 10 (dims 0-9);
|
|
19
|
+
75% threshold = 8 non-test dims covered. Update this constant if discovery-phase.md
|
|
20
|
+
adds or removes dimensions. -->
|
|
21
|
+
|
|
15
22
|
### Complexity Signals
|
|
16
23
|
|
|
17
24
|
Scan discovery answers and codebase-architect findings for these signals:
|
|
@@ -22,14 +29,14 @@ Scan discovery answers and codebase-architect findings for these signals:
|
|
|
22
29
|
| S2 | Regulatory/compliance requirement | GDPR consent, PCI-DSS, accessibility WCAG, food allergen regulations |
|
|
23
30
|
| S3 | External service/API never integrated | New payment provider, new SMS gateway, new OCR service |
|
|
24
31
|
| S4 | UX pattern not in the app | Drag-and-drop, real-time collaboration, complex data visualization |
|
|
25
|
-
| S5 | User explicitly signaled uncertainty | "non so come", "best practice", "come fanno gli altri", "devo capire" |
|
|
32
|
+
| S5 | User explicitly signaled uncertainty **about a TECHNICAL or ARCHITECTURAL topic** (not naming/wording/preferences) | "non so come implementare X", "best practice per Y", "come fanno gli altri con Z", "devo capire quale approccio" |
|
|
26
33
|
| S6 | Architecture decision with multiple valid approaches | Polling vs WebSocket, CQRS vs simple CRUD, edge vs server |
|
|
27
34
|
|
|
28
35
|
### Confidence Classification
|
|
29
36
|
|
|
30
37
|
| Confidence | Condition | Action |
|
|
31
38
|
|------------|-----------|--------|
|
|
32
|
-
| **ALTA** | 2+ signals match, OR S2 (regulatory) matches alone, OR S5 (user uncertainty) matches alone | Launch research **in background immediately** — no user prompt |
|
|
39
|
+
| **ALTA** | 2+ signals match, OR S2 (regulatory) matches alone, OR S5 (user uncertainty) matches alone **on a TECHNICAL/ARCHITECTURAL topic** | Launch research **in background immediately** — no user prompt |
|
|
33
40
|
| **MEDIA** | Exactly 1 non-S2/S5 signal matches | Ask user at discovery exit |
|
|
34
41
|
| **NESSUNA** | No signals match | Skip research, proceed to next phase |
|
|
35
42
|
|
|
@@ -56,18 +63,30 @@ Trigger as soon as confidence is HIGH (typically at ~75% comprehension).
|
|
|
56
63
|
|
|
57
64
|
Examples of research questions (substitute {stack_signature} at runtime):
|
|
58
65
|
- S1: "Best practices for implementing [pattern] on a {stack_signature} stack"
|
|
59
|
-
- S2: "Regulatory requirements for [topic] in {{identity.
|
|
66
|
+
- S2: "Regulatory requirements for [topic] in {{identity.jurisdiction}} (jurisdiction), implementation checklist"
|
|
67
|
+
<!-- identity.jurisdiction is not a standard config key; if absent, ASK the user: "Which country/jurisdiction does this feature target?" and persist the answer as a note in the state file. identity.language (BCP-47 tag) is NOT a jurisdiction name. -->
|
|
60
68
|
- S3: "Integration patterns for [service], comparison of approaches, gotchas"
|
|
61
69
|
- S4: "UX best practices for [pattern], accessibility considerations, mobile"
|
|
62
70
|
- S6: "Trade-offs of [approach A] vs [approach B] for [use case]"
|
|
63
71
|
|
|
64
|
-
2. **Launch `senior-researcher` agent in background:**
|
|
72
|
+
2. **Launch `senior-researcher` agent in background via Task tool:**
|
|
73
|
+
|
|
74
|
+
> **Background execution constraint**: When run in background, the
|
|
75
|
+
> senior-researcher agent MUST skip its FIRST MESSAGE TEMPLATE preamble
|
|
76
|
+
> (clarifying questions / search-plan acknowledgment loop) because no user
|
|
77
|
+
> is available to respond. The prompt below MUST include the explicit
|
|
78
|
+
> `BACKGROUND_RUN=true` directive so the agent knows to begin research
|
|
79
|
+
> immediately. Add this as the first line of the prompt.
|
|
80
|
+
|
|
65
81
|
```
|
|
66
|
-
|
|
67
|
-
subagent_type: "senior-researcher"
|
|
68
|
-
run_in_background: true
|
|
69
|
-
|
|
70
|
-
|
|
82
|
+
Task tool:
|
|
83
|
+
subagent_type: "senior-researcher"
|
|
84
|
+
run_in_background: true
|
|
85
|
+
prompt: |
|
|
86
|
+
BACKGROUND_RUN=true — skip the FIRST MESSAGE TEMPLATE preamble entirely.
|
|
87
|
+
Begin research immediately without waiting for acknowledgment.
|
|
88
|
+
|
|
89
|
+
Research the following topics for a PRD we're writing for feature
|
|
71
90
|
'<slug>'. Context: <1-2 line feature summary>.
|
|
72
91
|
|
|
73
92
|
Project stack (from baldart.config.yml):
|
|
@@ -86,8 +105,14 @@ Trigger as soon as confidence is HIGH (typically at ~75% comprehension).
|
|
|
86
105
|
- Key gotchas or anti-patterns to avoid
|
|
87
106
|
- If applicable: regulatory checklist or compliance requirements
|
|
88
107
|
|
|
89
|
-
|
|
90
|
-
|
|
108
|
+
OUTPUT CONTRACT (mandatory):
|
|
109
|
+
Write your complete research report to the file:
|
|
110
|
+
${paths.prd_dir}/<slug>/research-<slug>-<session-id>.md
|
|
111
|
+
where <session-id> is a short UUID you generate at start.
|
|
112
|
+
Log the exact output path as the FIRST line of your report:
|
|
113
|
+
RESEARCH_OUTPUT_PATH: <full path>
|
|
114
|
+
This path is how the PRD orchestrator will read your findings.
|
|
115
|
+
Be concise but thorough.
|
|
91
116
|
```
|
|
92
117
|
|
|
93
118
|
3. **Continue discovery** — do NOT wait for the researcher. Ask remaining
|
|
@@ -100,18 +125,39 @@ Trigger as soon as confidence is HIGH (typically at ~75% comprehension).
|
|
|
100
125
|
Signals: S1 (pattern X), S5 (user said "non so come")
|
|
101
126
|
Topics: [list]
|
|
102
127
|
Status: in-progress
|
|
128
|
+
LaunchTime: <ISO-8601 timestamp>
|
|
129
|
+
ResearchOutputPath: (populated by researcher — checked at discovery exit)
|
|
103
130
|
```
|
|
104
131
|
|
|
105
132
|
5. **At discovery exit**, check if researcher has returned:
|
|
106
|
-
- **Returned**: process findings (see "Processing Findings" below)
|
|
107
|
-
- **Not returned yet
|
|
133
|
+
- **Returned (output file exists)**: process findings (see "Processing Findings" below).
|
|
134
|
+
- **Not returned yet (output file absent, status in-progress)**: inform user
|
|
135
|
+
and wait up to **10 minutes** from the launch time recorded in the state file.
|
|
136
|
+
Display waiting message:
|
|
108
137
|
```
|
|
109
138
|
Discovery completata. La ricerca sulle best practice e ancora in corso,
|
|
110
139
|
aspetto i risultati prima di procedere.
|
|
111
140
|
```
|
|
141
|
+
- **Timed out (output file absent after 10-minute window)**: record
|
|
142
|
+
`Status: timed-out` in state file and surface:
|
|
143
|
+
```
|
|
144
|
+
La ricerca in background non ha restituito risultati entro il tempo atteso.
|
|
145
|
+
Opzioni:
|
|
146
|
+
A) Procedi senza ricerca (i risultati potrebbero essere parziali)
|
|
147
|
+
B) Riprova a lanciare la ricerca in foreground (l'utente aspetta)
|
|
148
|
+
```
|
|
149
|
+
**STOP.** Wait for user response. If A: mark `Status: timed-out`, proceed.
|
|
150
|
+
If B: launch foreground (see MEDIUM path below) and set `Status: in-progress`.
|
|
151
|
+
- **Failed (agent returned error)**: record `Status: failed` in state file and
|
|
152
|
+
surface the same A/B choice as the timed-out case above.
|
|
112
153
|
|
|
113
154
|
### MEDIUM Confidence — Ask User
|
|
114
155
|
|
|
156
|
+
> **Guard**: Only fire this prompt when state file `Status` is blank/absent (not
|
|
157
|
+
> yet asked). After presenting the question, immediately set `Status: asked` in
|
|
158
|
+
> the state file. This prevents the question from being re-presented on
|
|
159
|
+
> context-compression resume or multi-turn re-evaluation.
|
|
160
|
+
|
|
115
161
|
At discovery exit (comprehension >= 99%), before proceeding to next phase:
|
|
116
162
|
|
|
117
163
|
```
|
|
@@ -124,16 +170,28 @@ Vuoi che lanci una ricerca su:
|
|
|
124
170
|
- <topic 1>
|
|
125
171
|
- <topic 2>
|
|
126
172
|
|
|
127
|
-
Questo aggiunge
|
|
173
|
+
Questo aggiunge qualche minuto ma produce decisioni piu informate.
|
|
128
174
|
|
|
129
175
|
**A)** Si, lancia la ricerca <- consigliato
|
|
130
176
|
**B)** No, procedi direttamente
|
|
131
177
|
```
|
|
132
178
|
|
|
179
|
+
<!-- [CALIBRATION-NEEDED: foreground senior-researcher run time — empirically 5-15 min
|
|
180
|
+
depending on tool latency and search depth; update the user-facing estimate once
|
|
181
|
+
measured across representative PRD sessions.] -->
|
|
182
|
+
|
|
133
183
|
**STOP.** Wait for user response.
|
|
134
184
|
|
|
135
|
-
- If **A**: launch `senior-researcher` in **foreground** (user is
|
|
136
|
-
|
|
185
|
+
- If **A**: launch `senior-researcher` via Task tool in **foreground** (user is
|
|
186
|
+
waiting; do NOT use `run_in_background: true`). Include `BACKGROUND_RUN=false`
|
|
187
|
+
as the first line of the prompt so the agent follows its normal preamble flow.
|
|
188
|
+
Log `Status: in-progress` in state file.
|
|
189
|
+
|
|
190
|
+
**STOP.** Wait for the foreground Task tool to return. Do NOT continue to the
|
|
191
|
+
next phase or issue additional tool calls until findings are returned.
|
|
192
|
+
|
|
193
|
+
When the Task tool returns: verify the output file exists at the path logged by
|
|
194
|
+
the researcher, then process findings (see "Processing Findings" below).
|
|
137
195
|
- If **B**: mark research as "skipped" in state file. Proceed to next phase.
|
|
138
196
|
|
|
139
197
|
---
|
|
@@ -210,7 +268,8 @@ The research phase adds/updates these sections in the state file:
|
|
|
210
268
|
|
|
211
269
|
Confidence: ALTA | MEDIA | NESSUNA
|
|
212
270
|
Signals: [matched signals]
|
|
213
|
-
Status: launched | in-progress | completed | skipped
|
|
271
|
+
Status: launched | in-progress | asked | completed | skipped | timed-out | failed
|
|
272
|
+
ResearchOutputPath: <path written by researcher, or empty>
|
|
214
273
|
Topics: [research questions]
|
|
215
274
|
|
|
216
275
|
## Research Findings
|
|
@@ -224,6 +283,33 @@ Topics: [research questions]
|
|
|
224
283
|
|
|
225
284
|
---
|
|
226
285
|
|
|
286
|
+
## Context Recovery — Resuming with In-Progress Research
|
|
287
|
+
|
|
288
|
+
When **Step 0 (Context Recovery)** in `discovery-phase.md` finds `Status: in-progress`
|
|
289
|
+
in the `## Research` section of the state file, apply this resolution logic:
|
|
290
|
+
|
|
291
|
+
1. **Check for the output file**: read `ResearchOutputPath` from the state file.
|
|
292
|
+
- If the path is populated and the file exists → researcher already completed.
|
|
293
|
+
Set `Status: completed`. Process findings normally (see "Processing Findings").
|
|
294
|
+
- If the path is empty or the file does not exist → researcher did not complete
|
|
295
|
+
before the previous session ended.
|
|
296
|
+
|
|
297
|
+
2. **If researcher did not complete**: surface to the user:
|
|
298
|
+
```
|
|
299
|
+
La ricerca precedentemente lanciata non ha prodotto risultati (sessione
|
|
300
|
+
interrotta). Opzioni:
|
|
301
|
+
A) Rilancia la ricerca in foreground ora
|
|
302
|
+
B) Procedi senza ricerca
|
|
303
|
+
```
|
|
304
|
+
**STOP.** Wait for user response. Set `Status: failed` if B, or re-launch
|
|
305
|
+
foreground (MEDIUM path) if A.
|
|
306
|
+
|
|
307
|
+
3. **Never silently proceed with `Status: in-progress`** — an unresolved
|
|
308
|
+
in-progress state means either findings are available and unread, or
|
|
309
|
+
the background run was lost. Always resolve explicitly.
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
227
313
|
## Integration with PRD Writing
|
|
228
314
|
|
|
229
315
|
During Step 4 (PRD Writing), if `## Research Findings` is populated:
|