@juicesharp/rpiv-pi 0.12.6 → 0.13.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/package.json +1 -1
- package/skills/design2/SKILL.md +453 -0
- package/skills/discover/SKILL.md +2 -0
- package/skills/plan2/SKILL.md +367 -0
- package/skills/research/SKILL.md +26 -13
package/package.json
CHANGED
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: design2
|
|
3
|
+
description: Design features through architectural grill-me + per-slice grill-me with Slice Contract specification. Walks a decision-DAG to exhaustion at architectural scope, then per slice. Produces design artifacts in thoughts/shared/designs/ — contracts, not code. For complex multi-component features touching 6+ files across multiple layers. Always requires a research artifact.
|
|
4
|
+
argument-hint: "[research artifact path] [discover artifact path] [task description]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Design
|
|
8
|
+
|
|
9
|
+
You are tasked with designing how code will be shaped for a feature or change. This grill-me variant walks a decision-DAG architecturally to fix architectural decisions, decomposes the feature into vertical slices, then walks each slice's decision-DAG to fix Slice Contracts. The design produces contracts — no code generation. The plan skill synthesizes contract-fulfilling code at plan-time.
|
|
10
|
+
|
|
11
|
+
**How it works**:
|
|
12
|
+
- Read input and key source files into context (Step 1)
|
|
13
|
+
- Spawn targeted research agents for depth analysis (Step 2)
|
|
14
|
+
- Architectural grill-me — walk the decision-DAG to exhaustion, fixing architectural decisions (Step 3)
|
|
15
|
+
- Decompose into vertical slices holistically (Step 4)
|
|
16
|
+
- Per-slice grill-me — interview the developer per slice and draft Slice Contracts (Step 5)
|
|
17
|
+
- Verify cross-slice integration consistency (Step 6)
|
|
18
|
+
- Finalize the design artifact (Step 7)
|
|
19
|
+
- Review and iterate with the developer (Step 8)
|
|
20
|
+
|
|
21
|
+
The final artifact is plan-compatible. Plan extracts Slice Contracts and Q/A pairs to dispatch per-slice pattern-finder agents and synthesize contract-fulfilling code.
|
|
22
|
+
|
|
23
|
+
## Step 1: Input Handling
|
|
24
|
+
|
|
25
|
+
When this command is invoked:
|
|
26
|
+
|
|
27
|
+
1. **Read research artifact**:
|
|
28
|
+
|
|
29
|
+
**Research artifact provided** (argument contains a path to a `.md` file in `thoughts/`):
|
|
30
|
+
- Read the research artifact FULLY using the Read tool WITHOUT limit/offset
|
|
31
|
+
- Extract: Summary, Code References, Integration Points, Architecture Insights, Developer Context, Open Questions
|
|
32
|
+
- **Read the key source files from Code References** into the main context — especially hooks, shared utilities, and integration points the design will depend on. Read them FULLY. This ensures you have complete understanding before proceeding.
|
|
33
|
+
- These become starting context — no need to re-discover what exists
|
|
34
|
+
- Research Developer Context Q/As = inherited decisions (record in Decisions, never re-ask); Open Questions = starting ambiguity queue, filtered by dimension in Step 3
|
|
35
|
+
- If a discover artifact is also provided, read it for additional discovery context
|
|
36
|
+
|
|
37
|
+
**No arguments provided**:
|
|
38
|
+
```
|
|
39
|
+
I'll design a feature iteratively from a research artifact. Please provide:
|
|
40
|
+
|
|
41
|
+
`/skill:design2 [research artifact] [discover] [task description]`
|
|
42
|
+
|
|
43
|
+
Research artifact is required. Discover and task description are optional, in any order.
|
|
44
|
+
```
|
|
45
|
+
Then wait for input.
|
|
46
|
+
|
|
47
|
+
2. **Read any additional files mentioned** — tickets, related designs, existing implementations. Read them FULLY before proceeding.
|
|
48
|
+
|
|
49
|
+
## Step 2: Targeted Research
|
|
50
|
+
|
|
51
|
+
This is NOT a discovery sweep. Focus on DEPTH (how things work, what patterns to follow) not BREADTH (where things are).
|
|
52
|
+
|
|
53
|
+
1. **Dispatch all agents below as parallel `subagent` tool calls in the same assistant message** — multiple tool_use blocks in one response, not one call per turn. Each call matches this shape: `subagent({ agent: "<agent-name>", task: "<task>", context: "fresh", artifacts: false })`. Wait for all to return before proceeding.
|
|
54
|
+
|
|
55
|
+
- Use **codebase-pattern-finder** to find existing implementations to model after — the primary template for code shape
|
|
56
|
+
- Use **codebase-analyzer** to understand HOW integration points work in detail
|
|
57
|
+
- Use **integration-scanner** to map the wiring surface — inbound refs, outbound deps, config/DI/event registration
|
|
58
|
+
- Use **precedent-locator** to find similar past changes in git history — what commits introduced comparable features, what broke, and what lessons apply to this design. Only when `git_commit` is available (not `no-commit`); otherwise skip and note "git history unavailable" in Verification Notes.
|
|
59
|
+
|
|
60
|
+
**Novel work** (new libraries, first-time patterns, no existing codebase precedent):
|
|
61
|
+
- Add **web-search-researcher** for external documentation, API references, and community patterns
|
|
62
|
+
- Instruct it to return LINKS with findings — include those links in the final design artifact
|
|
63
|
+
|
|
64
|
+
Agent prompts should focus on (labeled by target agent):
|
|
65
|
+
- **codebase-pattern-finder**: "Find the implementation pattern I should model after for [feature type]"
|
|
66
|
+
- **codebase-analyzer**: "How does [integration point] work in detail"
|
|
67
|
+
- **integration-scanner**: "What connects to [component] — inbound refs, outbound deps, config"
|
|
68
|
+
|
|
69
|
+
NOT: "Find all files related to X" — that's discovery's job, upstream of this skill.
|
|
70
|
+
|
|
71
|
+
2. **Read all key files identified by agents** into the main context — especially the pattern templates you'll model after.
|
|
72
|
+
|
|
73
|
+
3. **Wait for ALL agents to complete** before proceeding.
|
|
74
|
+
|
|
75
|
+
4. **Analyze and verify understanding**:
|
|
76
|
+
- Cross-reference research findings with actual code read in Step 1
|
|
77
|
+
- Identify any discrepancies or misunderstandings
|
|
78
|
+
- Note assumptions that need verification
|
|
79
|
+
- Determine true scope based on codebase reality
|
|
80
|
+
|
|
81
|
+
## Step 3: Architectural Grill-Me
|
|
82
|
+
|
|
83
|
+
The architectural grill-me is a relentless interview that walks the design's decision-DAG to exhaustion. It absorbs the dimension sweep, holistic self-critique, and grounded-questions checkpoint into one phase. The dimensions seed the DAG; the walk produces fixed architectural decisions recorded with full Q/A trace.
|
|
84
|
+
|
|
85
|
+
### Decision-DAG seeded by dimensions
|
|
86
|
+
|
|
87
|
+
Six architectural dimensions seed the initial DAG roots (each contributes 0-N root questions):
|
|
88
|
+
|
|
89
|
+
- **Data model** — types, schemas, entities
|
|
90
|
+
- **API surface** — signatures, exports, routes
|
|
91
|
+
- **Integration wiring** — mount points, DI, events, config
|
|
92
|
+
- **Scope** — in / explicitly deferred
|
|
93
|
+
- **Verification** — tests, assertions, risk-bearing behaviors
|
|
94
|
+
- **Performance** — load paths, caching, N+1 risks
|
|
95
|
+
|
|
96
|
+
Add **migration** as a seventh dimension if the feature changes persisted schema.
|
|
97
|
+
|
|
98
|
+
For each dimension, walk Step 2 findings, inherited research Q/As, and carried Open Questions. Classify findings as **simple decisions** (one valid option, obvious from codebase — record in Decisions with `file:line` evidence, do not ask) or **DAG nodes** (multiple valid options, conflicting patterns, scope questions, novel choices — feed into the grill-me walk). Inherited research Q/As land as simple; Open Questions filter by dimension — architectural survives, implementation-detail defers.
|
|
99
|
+
|
|
100
|
+
Pre-validate every option against research constraints and runtime code behavior. Eliminate or caveat options that contradict Steps 1-2 evidence.
|
|
101
|
+
|
|
102
|
+
### Grill-me walk
|
|
103
|
+
|
|
104
|
+
Walk the DAG dependency-topologically. The lead question is the topologically earliest one — the node with the most downstream dependents. Each answer becomes a fixed architectural decision recorded in the artifact's Decisions section with full Q/A trace.
|
|
105
|
+
|
|
106
|
+
**Question rules** (preserved from grounded-questions pattern):
|
|
107
|
+
- Reference real findings with `file:line` evidence
|
|
108
|
+
- Present concrete options (not abstract choices)
|
|
109
|
+
- Pull a DECISION from the developer, not confirm what you already found
|
|
110
|
+
- Ask ONE question at a time. Wait for the answer before asking the next.
|
|
111
|
+
|
|
112
|
+
**Question patterns by ambiguity type** (preserved):
|
|
113
|
+
|
|
114
|
+
- **Pattern conflict**: "Found 2 patterns for [X]: [pattern A] at `file:line` and [pattern B] at `file:line`. They differ in [specific way]. Which should the new [feature] follow?"
|
|
115
|
+
- **Missing pattern**: "No existing [pattern type] in the codebase. Options: (A) [approach] modeled after [external reference], (B) [approach] extending [existing code at file:line]. Which fits the project's direction?"
|
|
116
|
+
- **Scope boundary**: "The [research/description] mentions both [feature A] and [feature B]. Should this design cover both, or just [feature A] with [feature B] deferred?"
|
|
117
|
+
- **Integration choice**: "[Feature] can wire into [point A] at `file:line` or [point B] at `file:line`. [Point A] matches the [existing pattern] pattern. Agree, or prefer [point B]?"
|
|
118
|
+
- **Novel approach**: "No existing [X] in the project. Options: (A) [library/pattern] — [evidence/rationale], (B) [library/pattern] — [evidence/rationale]. Which fits?"
|
|
119
|
+
|
|
120
|
+
**Question format choice** (preserved):
|
|
121
|
+
- **`ask_user_question` tool** — when your question has 2-4 concrete options from code analysis. The user can always pick "Other" for free-text.
|
|
122
|
+
- **Free-text with ❓ Question: prefix** — when the question is open-ended and options can't be predicted (discovery, "what am I missing?", corrections).
|
|
123
|
+
|
|
124
|
+
**Per-question check** (absorbs holistic self-critique):
|
|
125
|
+
After each answer, before the next question, ask yourself:
|
|
126
|
+
- Does this answer reveal new DAG branches that weren't seeded by the dimensions?
|
|
127
|
+
- Does this answer conflict with a prior answer? If so, surface the conflict explicitly (see Evidence-driven reopen below).
|
|
128
|
+
- Does this answer cover a multi-faceted concern that should split into sub-questions?
|
|
129
|
+
|
|
130
|
+
Add new branches to the DAG when discovered. Resolve conflicts proactively. Split multi-faceted nodes.
|
|
131
|
+
|
|
132
|
+
### FIXED-decision rule with evidence-driven reopen
|
|
133
|
+
|
|
134
|
+
Decisions stay FIXED within a single branch traversal — no oscillation. When a downstream branch surfaces evidence that an upstream answer was wrong-framed, the grill-me PROACTIVELY surfaces the conflict as one explicit reopen question:
|
|
135
|
+
|
|
136
|
+
> "❓ Question: Decision D1 (use pattern A at `file:line`) was framed assuming [X], but D5 just established [Y] which means D1 needs to be reopened. Do you want to: (A) revise D1 in light of D5, (B) revise D5's premise, or (C) accept the inconsistency for now and document the tension in Verification Notes?"
|
|
137
|
+
|
|
138
|
+
This activates the existing "no revisiting unless the developer explicitly asks" clause proactively. Mirrors the cascade-revision pattern from later phases moved earlier in the lifecycle.
|
|
139
|
+
|
|
140
|
+
### Two-gate exit
|
|
141
|
+
|
|
142
|
+
The grill-me phase exits when BOTH gates hold:
|
|
143
|
+
|
|
144
|
+
- **Gate 1 (depth)**: Every DAG node has a recorded answer or simple-decision classification. No unresolved children.
|
|
145
|
+
- **Gate 2 (breadth)**: Coverage check — every dimension is addressed. Silent-resolved is valid (a dimension whose findings all classified as simple decisions counts as addressed). Skipped-unchecked does NOT count as addressed.
|
|
146
|
+
|
|
147
|
+
If Migration was added as the seventh dimension, it gates Gate 2 conditionally on persisted-schema changes.
|
|
148
|
+
|
|
149
|
+
### Classify each response
|
|
150
|
+
|
|
151
|
+
**Decision** (e.g., "use pattern A", "yes, follow that approach"):
|
|
152
|
+
- Record in Decisions section under heading `### D<N>: <title>` (sequential D1, D2, … — IDs are mandatory; plan2 references them by ID) with full Q/A trace inline (Ambiguity → Explored → Decision format).
|
|
153
|
+
- Update `architectural_qa_count` frontmatter counter.
|
|
154
|
+
|
|
155
|
+
**Correction** (e.g., "no, there's a third option you missed", "check the events module"):
|
|
156
|
+
- Spawn targeted rescan: **codebase-analyzer** on the new area (max 1-2 agents).
|
|
157
|
+
- Merge results. Update DAG and re-walk affected branches.
|
|
158
|
+
|
|
159
|
+
**Scope adjustment** (e.g., "skip the UI, backend only", "include tests"):
|
|
160
|
+
- Record in Developer Context (non-Q/A interaction). Adjust Scope section.
|
|
161
|
+
|
|
162
|
+
### Exit gate
|
|
163
|
+
|
|
164
|
+
After both Gate 1 and Gate 2 hold, present a brief design summary (under 15 lines):
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
Design: [feature name]
|
|
168
|
+
Approach: [1-2 sentence summary of chosen architecture]
|
|
169
|
+
|
|
170
|
+
Decisions:
|
|
171
|
+
- [Decision 1]: [choice] — modeled after `file:line`
|
|
172
|
+
- [Decision 2]: [choice]
|
|
173
|
+
- [Decision 3]: [choice]
|
|
174
|
+
|
|
175
|
+
Scope: [what's in] | Not building: [what's out]
|
|
176
|
+
Slices: [N] preliminary slices identified | Files: [N] new, [M] modified
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Use the `ask_user_question` tool to confirm. Question: "[Summary from design brief above]. Ready to proceed to decomposition?". Header: "Design". Options: "Proceed" (Decompose into vertical slices, then per-slice grill-me); "Adjust decisions" (Revisit one or more architectural decisions above); "Change scope" (Add or remove items from the building/not-building lists).
|
|
180
|
+
|
|
181
|
+
## Step 4: Feature Decomposition
|
|
182
|
+
|
|
183
|
+
After the architectural grill-me exit gate confirms, decompose the feature into vertical slices. Each slice is a self-contained unit: types + impl + wiring for one concern. Decomposition is one shot — define ALL slices, dependencies, and ordering before per-slice grill-me begins.
|
|
184
|
+
|
|
185
|
+
1. **Decompose holistically** — define ALL slices, dependencies, and ordering before any per-slice grill-me runs:
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
Feature Breakdown: [feature name]
|
|
189
|
+
|
|
190
|
+
Slice 1: [name] — [what this slice delivers]
|
|
191
|
+
Files: path/to/file.ext (NEW), path/to/file.ext (MODIFY)
|
|
192
|
+
Depends on: nothing (foundation)
|
|
193
|
+
|
|
194
|
+
Slice 2: [name] — [what this slice delivers]
|
|
195
|
+
Files: path/to/file.ext (NEW), path/to/file.ext (MODIFY)
|
|
196
|
+
Depends on: Slice 1
|
|
197
|
+
|
|
198
|
+
Slice 3: [name] — [what this slice delivers]
|
|
199
|
+
Files: path/to/file.ext (NEW)
|
|
200
|
+
Depends on: Slice 2
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
2. **Slice properties**:
|
|
204
|
+
- End-to-end vertical: each slice is a complete cross-section of one concern (types + impl + wiring)
|
|
205
|
+
- ~512-1024 tokens per slice contract block
|
|
206
|
+
- Sequential. 5a/5b drafting may be done internally for sibling slices in any order, but Step 5c micro-checkpoints are strictly one slice at a time — never batched, never parallel from the developer's view.
|
|
207
|
+
- Foundation first when applicable: if the feature has shared types/interfaces, they're typically Slice 1
|
|
208
|
+
- Encode `depends_on` per slice — drives both per-slice grill-me parallelization eligibility and plan's parallel-phase eligibility
|
|
209
|
+
|
|
210
|
+
3. **Confirm decomposition** using the `ask_user_question` tool. Question: "[N] slices for [feature]. Slice 1: [name] (foundation). Slices 2-N: [brief]. Approve decomposition?". Header: "Slices". Options: "Approve" (Proceed to per-slice grill-me); "Adjust slices" (Reorder, merge, or split slices before grill-me); "Change scope" (Add or remove files from the decomposition).
|
|
211
|
+
|
|
212
|
+
4. **Create skeleton artifact** — immediately after decomposition is approved:
|
|
213
|
+
- Determine metadata: filename `thoughts/shared/designs/YYYY-MM-DD_HH-MM-SS_topic.md`, repository name from git root, branch and commit from the git context injected at the start of the session (fallbacks: "no-branch" / "no-commit"), designer from the injected User (fallback: "unknown")
|
|
214
|
+
- Write skeleton using the Write tool with `status: in-progress` in frontmatter
|
|
215
|
+
- **Include all prose sections filled** from Steps 1-3: Summary, Requirements, Current State Analysis, Scope, Decisions (architectural Q/A trace inline), Desired End State, File Map, Ordering Constraints, Verification Notes, Performance Considerations, Migration Notes, Pattern References, Developer Context, References
|
|
216
|
+
- **Slice Contracts section**: one `### Slice N: [name] — Contract` heading per slice from the decomposition, each with empty placeholders for the seven required contract fields plus a `#### Q/A` placeholder
|
|
217
|
+
- **Design History section**: list all slices with `— pending` status
|
|
218
|
+
- This is the living artifact — all subsequent writes use the Edit tool
|
|
219
|
+
|
|
220
|
+
**Artifact template sections** (all required in skeleton):
|
|
221
|
+
|
|
222
|
+
- **Frontmatter**: standard metadata (date, designer, git_commit, branch, repository, topic, tags, `status: in-progress`, research_source, last_updated, last_updated_by) plus contract-validation counters initialized at skeleton write: `architectural_qa_count: <Step 3 final total>`, `per_slice_qa_count: 0` (5d increments), `slice_count: <N>`, `unresolved_qa_count: 0` (sentinel; two-gate exit guarantees), `unresolved_contract_count: <slice_count>` (5d decrements; 0 to complete), `slices: [{name, contract_status: pending, qa_count: 0, files, depends_on}]` (status → approved/revised in 5d), `contract_fields_required: [inputs, outputs, types, integration_anchors, invariants, verification_hooks]`.
|
|
223
|
+
- **# Design: [Feature Name]**
|
|
224
|
+
- **## Summary**: 2-3 sentences — what we're building and the chosen architectural approach. Settled decision, not a discussion.
|
|
225
|
+
- **## Requirements**: Bullet list from ticket, research, or developer input.
|
|
226
|
+
- **## Current State Analysis**: What exists now, what's missing, key constraints. Include `### Key Discoveries` with `file:line` references, patterns to follow, constraints to work within.
|
|
227
|
+
- **## Scope**: `### Building` — concrete deliverables. `### Not Building` — developer-stated exclusions AND likely scope-creep vectors (alternative architectures not chosen, nearby code that looks related but shouldn't be touched).
|
|
228
|
+
- **## Decisions**: `### D<N>: <title>` per architectural decision (sequential D1, D2, … — IDs are mandatory; plan2 references them by ID). Complex: Ambiguity → Explored (Option A/B with `file:line` + pro/con) → Decision. Simple: just state decision with evidence. Each `### D<N>:` includes inline Q/A trace per decision.
|
|
229
|
+
- **## Slice Contracts**: `###` per slice with `Slice N: [name] — Contract` heading. Required field bullets in order: Inputs, Outputs, Types/Data Model, Integration anchors, Invariants, Verification hooks, Files touched. `#### Q/A` subsection embeds the per-slice grill-me transcript. No implementation code. (Filled progressively in Step 5d.)
|
|
230
|
+
- **## Desired End State**: Usage examples showing the feature in use from a consumer's perspective — concrete code, not prose.
|
|
231
|
+
- **## File Map**: `path/to/file.ext # NEW/MODIFY — purpose` per line. Stays at artifact level as the canonical flat list. NEW/MODIFY labels also appear inside each slice contract's Files touched field (slice-scoped duplicate is intentional).
|
|
232
|
+
- **## Ordering Constraints**: What must come before what. What can run in parallel. Drives plan's phase eligibility.
|
|
233
|
+
- **## Verification Notes**: Carry forward from research — known risks, build/test warnings, precedent lessons. Format as verifiable checks (commands, grep patterns, visual inspection). plan converts these to success criteria.
|
|
234
|
+
- **## Performance Considerations**: Any performance implications or optimizations.
|
|
235
|
+
- **## Migration Notes**: If applicable — existing data, schema changes, rollback strategy, backwards compatibility. Empty if not applicable.
|
|
236
|
+
- **## Pattern References**: one entry per reference, formatted as `path/to/similar.ext:line-range — Slice <N> (<slice name>): <one-line reason>`. Each entry MUST tag at least one slice it serves; references that serve multiple slices repeat across multiple lines, one tag per line. Plan dispatches `codebase-pattern-finder` per slice using the references tagged for that slice.
|
|
237
|
+
- **## Developer Context**: Non-Q/A interactions — corrections (rescans triggered by codebase-analyzer correction path), scope adjustments, mid-walk redirects. Q/A pairs live inside `## Decisions` (architectural) and `## Slice Contracts` `#### Q/A` (per-slice).
|
|
238
|
+
- **## Design History**: Slice contract approval/revision log. `- Slice N: [name] — pending/approved as drafted/revised: [what changed]`. plan ignores this section AND the `#### Q/A` subsections inside Slice Contracts.
|
|
239
|
+
- **## References**: Research artifacts, tickets, similar implementations.
|
|
240
|
+
|
|
241
|
+
**Slice contract block format in skeleton**:
|
|
242
|
+
- `### Slice N: [name] — Contract` heading
|
|
243
|
+
- Required field bullets with TBD placeholders:
|
|
244
|
+
- `**Inputs**: TBD`
|
|
245
|
+
- `**Outputs**: TBD`
|
|
246
|
+
- `**Types/Data Model**: TBD`
|
|
247
|
+
- `**Integration anchors**: TBD`
|
|
248
|
+
- `**Invariants**: TBD`
|
|
249
|
+
- `**Verification hooks**: TBD`
|
|
250
|
+
- `**Files touched**: TBD`
|
|
251
|
+
- `#### Q/A` heading with empty body
|
|
252
|
+
- Filled in Step 5d via Edit when the slice's contract is approved.
|
|
253
|
+
|
|
254
|
+
## Step 5: Per-Slice Grill-Me
|
|
255
|
+
|
|
256
|
+
Walk each slice's decision-DAG to draft its Slice Contract. Each per-slice grill-me runs after holistic decomposition is locked. The developer is a serial resource — Step 5c micro-checkpoints are strictly one slice at a time. Slices are NEVER batched at the checkpoint, regardless of `depends_on` independence.
|
|
257
|
+
|
|
258
|
+
**For each slice in the decomposition (strictly sequential at the developer checkpoint):**
|
|
259
|
+
|
|
260
|
+
### 5a. Draft contract internally
|
|
261
|
+
|
|
262
|
+
**Commitments before drafting.** Before populating contract fields, scan the slice for any choice where two reasonable implementers reading the same spec would diverge in their code — those divergence points are architectural commitments, not local logic. Pull each as a Q/A in the slice's `#### Q/A` before drafting. If you catch yourself choosing between alternatives during drafting, stop and pull the Q/A first.
|
|
263
|
+
|
|
264
|
+
Walk the slice's decision-DAG. Reuse the grounded-questions pattern from Step 3, scoped to this slice. The slice's contract walk seeds DAG roots from the seven required fields:
|
|
265
|
+
|
|
266
|
+
- **Inputs** — what does this slice receive? Function/route parameters with types, request shapes, event payloads.
|
|
267
|
+
- **Outputs** — what does this slice produce? Return types, response shapes, side effects.
|
|
268
|
+
- **Types/Data Model** — what new entities/schemas does this slice introduce?
|
|
269
|
+
- **Integration anchors** — where does this slice mount? `file:line` for DI calls, route registration, event subscription, hook installation.
|
|
270
|
+
- **Invariants** — what cross-cutting properties must this slice preserve? Transaction boundaries, ordering guarantees.
|
|
271
|
+
- **Verification hooks** — how do we prove the contract holds? Test names with intent, grep patterns, observable behaviors.
|
|
272
|
+
- **Files touched** — which files does this slice create or modify? `path (NEW)` or `path:line-range (MODIFY)`.
|
|
273
|
+
|
|
274
|
+
Walk the DAG dependency-topologically. Resolve each node before drafting the dependent contract field. If additional context is needed, spawn a targeted **codebase-analyzer** agent (max 1).
|
|
275
|
+
|
|
276
|
+
**Context grounding** (after slice 2): Before drafting, re-read the artifact's Slice Contracts section for prior slices. The artifact is the source of truth — generate contract anchors that align with what's already declared, not what you remember from conversation.
|
|
277
|
+
|
|
278
|
+
### 5b. Self-verify slice contract
|
|
279
|
+
|
|
280
|
+
Before presenting to the developer, cross-check the drafted contract and produce a structured summary:
|
|
281
|
+
|
|
282
|
+
```
|
|
283
|
+
Self-verify Slice N contract:
|
|
284
|
+
- Architectural decisions: [OK / VIOLATION: contract violates decision X — fix applied]
|
|
285
|
+
- Cross-slice: [OK / CONFLICT: integration anchors at file:line clash with prior slice — fix applied]
|
|
286
|
+
- Research: [OK / WARNING: research constraint Y not satisfied by verification hooks — fix applied]
|
|
287
|
+
- Required fields: [all populated / missing: <field list>]
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
If violations found: fix in-place before presenting. Include the self-verify summary in the 5c micro-checkpoint presentation.
|
|
291
|
+
|
|
292
|
+
### 5c. Developer micro-checkpoint
|
|
293
|
+
|
|
294
|
+
Present a **condensed contract review** — the developer reviews the contract shape, not every field's prose. For each contract field, show:
|
|
295
|
+
|
|
296
|
+
1. **Summary** (1-2 sentences): what this slice does, what pattern it follows, what it connects to
|
|
297
|
+
2. **Inputs/Outputs**: the surface — types, parameters, return shapes
|
|
298
|
+
3. **Integration anchors**: `file:line` mount points — the wiring decisions
|
|
299
|
+
4. **Verification hooks**: test names + grep patterns — how we'll know it works
|
|
300
|
+
|
|
301
|
+
**Omit**: full prose for Types/Data Model (named only), Invariants summary line only, Files touched as a path list.
|
|
302
|
+
|
|
303
|
+
**If the developer asks to see the full contract**, show it inline — exception, not default.
|
|
304
|
+
|
|
305
|
+
Use the `ask_user_question` tool to confirm. Question: "Slice [N/M]: [slice name] — [files affected]. [1-line contract summary]. Approve?". Header: "Slice [N]". Options: "Approve" (Lock this slice's contract, write to artifact, proceed to slice [N+1]); "Revise this slice" (Adjust contract before proceeding — describe what to change); "Rethink remaining slices" (This slice reveals a design issue — revisit decomposition).
|
|
306
|
+
|
|
307
|
+
**Checkpoint cadence**:
|
|
308
|
+
- Every slice is presented individually. No batching, no grouping — one slice per `ask_user_question` call. The developer reviews and approves each slice's contract on its own before the next slice's 5a draft begins.
|
|
309
|
+
|
|
310
|
+
### 5d. Incorporate feedback
|
|
311
|
+
|
|
312
|
+
**Approve**: Lock this slice's contract and **Edit the artifact immediately**:
|
|
313
|
+
1. Edit the slice's `### Slice N: [name] — Contract` block to replace TBD placeholders with the drafted contract fields
|
|
314
|
+
2. Append the per-slice grill-me transcript to the slice's `#### Q/A` subsection (one bullet per Q/A pair with `file:line` evidence)
|
|
315
|
+
3. Update the Design History section: `- Slice N: [name] — approved as drafted`
|
|
316
|
+
4. Increment frontmatter `per_slice_qa_count` by the number of new Q/As; decrement `unresolved_contract_count` by 1; update the `slices: [{contract_status}]` entry for this slice from `pending` to `approved`
|
|
317
|
+
- Proceed to next slice
|
|
318
|
+
|
|
319
|
+
**Revise**: Update contract per developer feedback. Re-run self-verify (5b). Re-present the same slice (5c). The artifact is NOT touched — only "Approve" writes to the artifact.
|
|
320
|
+
|
|
321
|
+
**Rethink**: Developer spotted a design issue. If a previously approved slice's contract is affected, flag the conflict and offer cascade revision — developer decides whether to reopen (if yes, Edit artifact entry). Update decomposition (add/remove/reorder remaining slices) and confirm before continuing. If the conflict invalidates an architectural decision from Step 3, surface as evidence-driven reopen at architectural scope.
|
|
322
|
+
|
|
323
|
+
## Step 6: Integration Verification
|
|
324
|
+
|
|
325
|
+
After all slices' contracts are drafted, review cross-slice consistency:
|
|
326
|
+
|
|
327
|
+
1. **Present integration summary** (under 15 lines):
|
|
328
|
+
```
|
|
329
|
+
Integration: [feature name] — [N] slice contracts complete
|
|
330
|
+
|
|
331
|
+
Slices: [brief list of slice names and file counts]
|
|
332
|
+
Cross-slice: [integration anchors consistent / outputs feed inputs / no orphan invariants]
|
|
333
|
+
Research constraints: [all satisfied by verification hooks / N gaps noted]
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
2. **Verify research constraints**: Check each Precedent & Lesson and Verification Note from the research artifact against each slice's verification hooks. List satisfaction status per constraint.
|
|
337
|
+
|
|
338
|
+
3. **Verify cross-slice contract consistency**:
|
|
339
|
+
- Outputs of upstream slices match Inputs of downstream slices that depend on them
|
|
340
|
+
- Integration anchors don't conflict (two slices claiming the same `file:line` for incompatible mount points)
|
|
341
|
+
- No invariant declared in one slice is contradicted by another slice's contract
|
|
342
|
+
|
|
343
|
+
4. **Self-verify and proceed**. If steps 2–3 above pass, proceed directly to Step 7 finalize. If a research constraint is unsatisfied, an integration anchor conflicts, or a slice's outputs don't match a downstream slice's inputs, return to that slice's grill-me (Step 5) — do NOT ask the developer to choose; reopening the affected slice is the only correct action.
|
|
344
|
+
|
|
345
|
+
## Step 7: Finalize Design Artifact
|
|
346
|
+
|
|
347
|
+
The artifact was created as a skeleton in Step 4 and filled progressively in Step 5d. This step verifies completeness and finalizes.
|
|
348
|
+
|
|
349
|
+
1. **Verify every slice contract is fully specified**: Every `### Slice N:` heading has populated Inputs, Outputs, Types/Data Model, Integration anchors, Invariants, Verification hooks, and Files touched fields. Empty TBD placeholders fail. If any are still empty, return to per-slice grill-me for that slice.
|
|
350
|
+
|
|
351
|
+
2. **Verify frontmatter counters**:
|
|
352
|
+
- `unresolved_qa_count == 0`
|
|
353
|
+
- `unresolved_contract_count == 0`
|
|
354
|
+
- `slice_count ==` actual slice count in `## Slice Contracts`
|
|
355
|
+
- `architectural_qa_count` matches Q/A pairs in `## Decisions`
|
|
356
|
+
- `per_slice_qa_count` matches Q/A pairs across all `#### Q/A` subsections
|
|
357
|
+
|
|
358
|
+
If any check fails, return to the relevant grill-me phase. Do NOT flip status to complete.
|
|
359
|
+
|
|
360
|
+
3. **Update frontmatter** via Edit:
|
|
361
|
+
- Set `status: complete`
|
|
362
|
+
- Update `last_updated` to current date
|
|
363
|
+
- Update `last_updated_by` to the User from the injected git context (fallback: "unknown")
|
|
364
|
+
- Update `slices: [{contract_status}]` array — every entry should be `approved` or `revised`
|
|
365
|
+
|
|
366
|
+
4. **Verify template completeness**: Ensure all 16 sections from the template reference in Step 4 are present and filled. Edit to fix any gaps.
|
|
367
|
+
|
|
368
|
+
5. **Slice Contract block format reminder**:
|
|
369
|
+
- Heading: `### Slice N: [name] — Contract`
|
|
370
|
+
- Required field bullets in order: Inputs, Outputs, Types/Data Model, Integration anchors, Invariants, Verification hooks, Files touched
|
|
371
|
+
- File entries inside Files touched carry `(NEW)` or `:line-range (MODIFY)` labels
|
|
372
|
+
- `#### Q/A` subsection logs the per-slice grill-me transcript (one bullet per Q/A pair with `file:line` evidence)
|
|
373
|
+
- No code blocks — contract fields are prose specs
|
|
374
|
+
|
|
375
|
+
## Step 8: Review & Iterate
|
|
376
|
+
|
|
377
|
+
1. **Present the design artifact location**:
|
|
378
|
+
```
|
|
379
|
+
Design artifact written to:
|
|
380
|
+
`thoughts/shared/designs/[filename].md`
|
|
381
|
+
|
|
382
|
+
[N] architectural decisions fixed, [M] slices with full contracts.
|
|
383
|
+
[A] architectural Q/As, [P] per-slice Q/As across the decomposition.
|
|
384
|
+
|
|
385
|
+
Please review and let me know:
|
|
386
|
+
- Are the architectural decisions correct?
|
|
387
|
+
- Do the slice contracts capture the design you envision?
|
|
388
|
+
- Any missing integration points or edge cases?
|
|
389
|
+
|
|
390
|
+
When ready, run `/skill:plan2 thoughts/shared/designs/[filename].md` to synthesize per-slice code into phases.
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
2. **Handle follow-up changes**:
|
|
394
|
+
- Use the Edit tool to update the design artifact in-place
|
|
395
|
+
- Update frontmatter: `last_updated` and `last_updated_by`
|
|
396
|
+
- Add `last_updated_note: "Updated [brief description]"` to frontmatter
|
|
397
|
+
- If the change affects an architectural decision, return to Step 3 (architectural grill-me reopen)
|
|
398
|
+
- If the change affects a slice contract, return to Step 5 (per-slice grill-me for that slice)
|
|
399
|
+
- Update affected frontmatter counters
|
|
400
|
+
|
|
401
|
+
## Guidelines
|
|
402
|
+
|
|
403
|
+
1. **Be Architectural**: Design fixes architectural decisions and shapes contracts; plans synthesize code from contracts. Every architectural decision and every contract field must be grounded in `file:line` evidence from the actual codebase.
|
|
404
|
+
|
|
405
|
+
2. **Be Interactive**: Don't produce the full design in one shot. Walk the architectural decision-DAG to exhaustion first, get buy-in on the approach, decompose into slices, THEN walk each slice's contract DAG.
|
|
406
|
+
|
|
407
|
+
3. **Be Complete**: Slice contracts must be unambiguous enough that plan can synthesize copy-pasteable code from them. No TBD placeholders, no "implementer decides" cop-outs. If you can't fully specify a contract field, an architectural ambiguity wasn't resolved — return to Step 3.
|
|
408
|
+
|
|
409
|
+
4. **Be Skeptical**: Question vague requirements. If an existing pattern doesn't fit the new feature, say so and propose alternatives. Don't force a pattern where it doesn't belong.
|
|
410
|
+
|
|
411
|
+
5. **Resolve Everything**: No unresolved questions in the final artifact. If something is ambiguous, ask during the architectural grill-me or per-slice grill-me. The design must be complete enough that plan can synthesize phase code by reading contracts + Q/A pairs.
|
|
412
|
+
|
|
413
|
+
6. **Present Condensed, Persist Complete**: Micro-checkpoints show the developer condensed contract reviews. The artifact always contains full contract fields. If the developer asks to see the full contract, show it — but never default to walls of contract prose in checkpoints.
|
|
414
|
+
|
|
415
|
+
7. **No code in design**: Source code does NOT appear in the design artifact. The Slice Contracts section specifies inputs/outputs/anchors/invariants/verification, never implementation. Plan synthesizes implementation from the contract.
|
|
416
|
+
|
|
417
|
+
## Subagent Usage
|
|
418
|
+
|
|
419
|
+
| Context | Agents Spawned |
|
|
420
|
+
|---|---|
|
|
421
|
+
| Default (research artifact provided) | codebase-pattern-finder, codebase-analyzer, integration-scanner, precedent-locator |
|
|
422
|
+
| Novel work (new library/pattern) | + web-search-researcher |
|
|
423
|
+
| During architectural grill-me (correction path) | targeted codebase-analyzer for the new area (max 1-2) |
|
|
424
|
+
| During per-slice grill-me (5a clarification) | targeted codebase-analyzer when contract has `file:line` ambiguity (max 1) |
|
|
425
|
+
|
|
426
|
+
When agents are searching for different things, dispatch them as parallel `subagent(...)` tool calls in the same assistant message — multiple tool_use blocks in one response, not one call per turn. Call shape: `subagent({ agent: "<agent-name>", task: "<task>", context: "fresh", artifacts: false })`. Each agent runs in isolation — provide complete context in the prompt, including specific directory paths when the feature targets a known module. Don't write detailed prompts about HOW to search — just tell it what you're looking for and where.
|
|
427
|
+
|
|
428
|
+
## Important Notes
|
|
429
|
+
|
|
430
|
+
- **Always chained**: This skill requires a research artifact produced by the research skill. There is no standalone design mode.
|
|
431
|
+
- **File reading**: Always read research artifacts and referenced files FULLY (no limit/offset) before spawning agents
|
|
432
|
+
- **Critical ordering**: Follow the numbered steps exactly
|
|
433
|
+
- ALWAYS read input files first (Step 1) before spawning agents (Step 2)
|
|
434
|
+
- ALWAYS wait for all agents to complete before architectural grill-me (Step 3)
|
|
435
|
+
- ALWAYS exit architectural grill-me via the two-gate check (depth + breadth) before decomposition (Step 4)
|
|
436
|
+
- ALWAYS complete holistic decomposition before per-slice grill-me (Step 5)
|
|
437
|
+
- ALWAYS create the skeleton artifact immediately after decomposition approval (Step 4)
|
|
438
|
+
- NEVER make architectural commitments during 5a drafting — the orchestrator drafts, the developer decides; pull divergent-implementer choices as Q/As first
|
|
439
|
+
- NEVER leave a slice contract with TBD placeholders after the slice is approved — fill via Edit in Step 5d
|
|
440
|
+
- NEVER skip the architectural grill-me or per-slice grill-me — developer input on architectural decisions and contract shape is the highest-value signal in the design process
|
|
441
|
+
- NEVER edit source files — all output goes into the design document, not the codebase. This skill produces a contract document, not implementation. Source file editing is implement's job; code synthesis is plan's job.
|
|
442
|
+
- **Contract is source of truth** — if the Slice Contracts section conflicts with Decisions prose, the contract fields win. Update the prose to match.
|
|
443
|
+
- **Checkpoint recordings**: Architectural Q/As live inline in `## Decisions` (per-decision Q/A trace). Per-slice Q/As live inside each slice's `#### Q/A` subsection in `## Slice Contracts`. `## Developer Context` records non-Q/A interactions (corrections, scope adjustments, rescans). Plan reads contract fields; plan IGNORES `#### Q/A` subsections (extends the Design History "plan ignores" annotation).
|
|
444
|
+
- **Frontmatter consistency**: Always include frontmatter, use snake_case for multi-word fields, keep tags relevant. Frontmatter counters (`architectural_qa_count`, `per_slice_qa_count`, `slice_count`, `unresolved_qa_count`, `unresolved_contract_count`, `slices: [...]`, `contract_fields_required`) are machine-validatable preflight signals plan uses to STOP on incomplete designs.
|
|
445
|
+
- CC auto-loads CLAUDE.md files when agents read files in a directory — no need to scan for them explicitly
|
|
446
|
+
|
|
447
|
+
## Common Design Patterns
|
|
448
|
+
|
|
449
|
+
- **New Features**: types first → backend logic → API surface → UI last. Research existing patterns first. Each slice's verification hooks include test surface alongside implementation surface.
|
|
450
|
+
- **Modifications**: Read current file FULLY in Step 1. Per-slice contracts capture only the modified portions in Files touched (`path:line-range (MODIFY)`) and Integration anchors. Check integration points for side effects.
|
|
451
|
+
- **Database Changes**: schema/migration → store/repository → business logic → API → client. Migration becomes a seventh dimension in Step 3's seed list. Include rollback strategy in the migration slice's Verification hooks.
|
|
452
|
+
- **Refactoring**: Document current behavior first via research. Plan incremental backwards-compatible changes — each slice contract preserves an invariant ("existing behavior preserved").
|
|
453
|
+
- **Novel Work**: Include approach comparison in Decisions Q/A trace. Ground in codebase evidence OR web research. Get explicit developer sign-off via the architectural grill-me exit gate BEFORE decomposing into slices.
|
package/skills/discover/SKILL.md
CHANGED
|
@@ -23,6 +23,8 @@ Before Step 1, create a todo list tracking every step below (Step 1 through Step
|
|
|
23
23
|
|
|
24
24
|
## Steps
|
|
25
25
|
|
|
26
|
+
**Subagent mode (non-interactive)**: When this skill is invoked from another skill via a subagent (e.g., `research` auto-running discover from a free-text prompt), there is no developer to ask. Skip Step 5 (Developer Checkpoint) entirely, write the artifact (Step 6), and as your final output return ONLY the absolute path to the questions artifact. All other steps run unchanged.
|
|
27
|
+
|
|
26
28
|
### Step 1: Read Mentioned Files
|
|
27
29
|
|
|
28
30
|
- If the user mentions specific files (tickets, docs, JSON), read them FULLY first
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: plan2
|
|
3
|
+
description: Synthesize implementation plans from design artifacts. One design slice maps 1:1 to one plan phase, synthesized in topological order, with per-phase Success Criteria. Produces plans in thoughts/shared/plans/. Use after design.
|
|
4
|
+
argument-hint: [design artifact path]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Write Plan
|
|
8
|
+
|
|
9
|
+
You are tasked with synthesizing implementation plans from design artifacts. The design artifact contains all architectural decisions, per-slice Slice Contracts, and Q/A pairs — but NO source code. Your job is to synthesize contract-fulfilling code one phase at a time in topological order. Each design slice maps 1:1 to a plan phase; the plan artifact is phase-shaped from skeleton-write onward and consumed by `/skill:implement` phase by phase.
|
|
10
|
+
|
|
11
|
+
## Step 1: Read Design Artifact
|
|
12
|
+
|
|
13
|
+
When this command is invoked:
|
|
14
|
+
|
|
15
|
+
1. **Determine input mode**:
|
|
16
|
+
|
|
17
|
+
**Design artifact provided** (path to a `.md` file in `thoughts/shared/designs/`):
|
|
18
|
+
- Read the design artifact FULLY using the Read tool WITHOUT limit/offset
|
|
19
|
+
- Extract: Slice Contracts, Decisions (architectural Q/A trace), File Map, Ordering Constraints, Verification Notes, Performance Considerations, Migration Notes, Scope, Pattern References
|
|
20
|
+
- Architectural decisions and slice contracts are settled — do not re-evaluate them
|
|
21
|
+
- **Two-pass STOP gate**:
|
|
22
|
+
- **Pass A**: Frontmatter `unresolved_qa_count == 0`. If > 0 or missing, STOP — tell the developer to return to design (architectural grill-me or per-slice grill-me has unresolved Q/As).
|
|
23
|
+
- **Pass B**: Frontmatter `unresolved_contract_count == 0` AND every slice in `## Slice Contracts` has populated Inputs, Outputs, Types/Data Model, Integration anchors, Invariants, Verification hooks, Files touched (no TBD placeholders). If any contract is incomplete, STOP — tell the developer to return to design Step 5 for the affected slice.
|
|
24
|
+
- **Pre-restructure designs** (no `slices:` frontmatter array): treat as legacy. STOP with: "This design predates the contract restructure. Re-run /skill:design2 to produce a contract-format artifact." Do NOT attempt to plan a legacy design.
|
|
25
|
+
|
|
26
|
+
**No arguments provided**:
|
|
27
|
+
```
|
|
28
|
+
I'll synthesize an implementation plan from a design artifact. Please provide the path:
|
|
29
|
+
|
|
30
|
+
`/skill:plan2 thoughts/shared/designs/2026-01-20_09-30-00_feature.md`
|
|
31
|
+
|
|
32
|
+
Run `/skill:design2` first to produce the design artifact. There is no standalone path.
|
|
33
|
+
```
|
|
34
|
+
Then wait for input.
|
|
35
|
+
|
|
36
|
+
2. **Read any additional files mentioned** in the design's References — research documents, tickets. Read them FULLY for context.
|
|
37
|
+
|
|
38
|
+
3. **Read each Pattern Reference**: For every `path/to/similar.ext:line-range` in the design's `## Pattern References`, read the cited range FULLY. These are the templates plan synthesizes against.
|
|
39
|
+
|
|
40
|
+
4. **Anchor reverification gate** — runs every plan2 invocation, unconditionally. Source code drifts between runs; a prior `last_updated_note` is an audit entry, not a skip signal. Re-read every anchor every time. For every `file:line` (or `file:line-range`) cited in each slice's `Integration anchors` and `Files touched` fields under `## Slice Contracts`, read the cited range using the Read tool with the line offset.
|
|
41
|
+
- **If the cited range still contains the symbol/text the contract describes** (e.g., the schema, interface, function, or call site referenced in prose): proceed.
|
|
42
|
+
- **If the line range has drifted** (the cited symbol now lives at a different line range in the same file): use the Edit tool to update every occurrence of the stale `file:line` in the design artifact to the correct line range, and bump frontmatter `last_updated` + `last_updated_by` + append a dated audit entry to `last_updated_note` of the form `"<YYYY-MM-DD HH:MM>: anchor reverification adjusted <slice-id>:<old-range> → <new-range> in <file>"`.
|
|
43
|
+
- **If the cited symbol is gone** (renamed, deleted, or moved): STOP — return the developer to /skill:design2 Step 5. Do NOT guess at a corrected anchor.
|
|
44
|
+
|
|
45
|
+
## Step 2: Per-Phase Synthesis Loop
|
|
46
|
+
|
|
47
|
+
Synthesis runs one phase at a time in topological order (`depends_on` of the corresponding design slice). One design slice = one plan phase. Each iteration produces complete, copy-pasteable code for one slice's contract written under `## Phase N` in the plan artifact.
|
|
48
|
+
|
|
49
|
+
1. **Write the phase-shaped skeleton** to `thoughts/shared/plans/YYYY-MM-DD_HH-MM-SS_description.md`:
|
|
50
|
+
- Filename format: `YYYY-MM-DD_HH-MM-SS_description.md` (kebab-case description, ticket prefix optional). Examples: `2026-01-08_14-30-00_ENG-1478-parent-child-tracking.md`, `2026-01-08_14-30-00_improve-error-handling.md`.
|
|
51
|
+
- One phase per design slice, in topological order (`depends_on`). Skeleton includes everything EXCEPT code blocks: frontmatter, Overview, Desired End State, What We're NOT Doing, one `## Phase N: [slice name]` section per slice with `### Overview` (one sentence + parallelism note from `depends_on`), `### Changes Required:` placeholders sourced from the design's `Files touched` and Verification hooks (no code), and `### Success Criteria:` (Automated + Manual placeholders per the Success Criteria Conversion section), Performance Considerations, Migration Notes, References, and a `## Plan History` section listing each phase as `— pending`.
|
|
52
|
+
- Skeleton frontmatter MUST include: `slice_count` (informational, from design), `phase_count` (= `slice_count`), `unresolved_phase_count` (initialized to `phase_count`, decrements as each phase's synthesis is approved).
|
|
53
|
+
|
|
54
|
+
2. **Topological order**: Sort slices by `depends_on` so every slice's prerequisites are already synthesized and written to the artifact before its own synthesis begins.
|
|
55
|
+
|
|
56
|
+
3. **Parallel pre-fetch of pattern-finder for every slice (Step 2.0)**.
|
|
57
|
+
|
|
58
|
+
**Hard rule — fan-out, not loop.** Emit ONE assistant message that contains N `subagent(...)` tool calls, where N = `slice_count`. Every slice's pattern-finder dispatches in the SAME message as a separate `tool_use` block. The model that emits this message MUST list all N tool calls before sending. If you find yourself sending one tool call per assistant turn, STOP — you are violating Step 2.0; restart the message with all N blocks together.
|
|
59
|
+
|
|
60
|
+
Forbidden anti-patterns:
|
|
61
|
+
- One `subagent(...)` call per assistant message, looping through slices serially.
|
|
62
|
+
- Mixing pattern-finder dispatches with synthesis or other tool calls.
|
|
63
|
+
- Dispatching pattern-finder for "the next slice" inside the topological loop (Step 2a) — pattern-finder is pre-fetched ONCE for ALL slices before the loop starts.
|
|
64
|
+
|
|
65
|
+
Required shape — one assistant message with N parallel blocks (illustration for N=3; scale to actual `slice_count`):
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
subagent({ agent: "codebase-pattern-finder", task: "<contract excerpt for Slice 1>", context: "fresh", artifacts: false })
|
|
69
|
+
subagent({ agent: "codebase-pattern-finder", task: "<contract excerpt for Slice 2>", context: "fresh", artifacts: false })
|
|
70
|
+
subagent({ agent: "codebase-pattern-finder", task: "<contract excerpt for Slice 3>", context: "fresh", artifacts: false })
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Each `task` prompt includes that slice's contract excerpt verbatim:
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
"Find code templates I can model the [slice name] implementation after.
|
|
77
|
+
|
|
78
|
+
Contract excerpt from the design artifact:
|
|
79
|
+
Inputs: <slice Inputs field verbatim>
|
|
80
|
+
Outputs: <slice Outputs field verbatim>
|
|
81
|
+
Types/Data Model: <slice Types field verbatim>
|
|
82
|
+
Files touched: <slice Files touched field verbatim>
|
|
83
|
+
Change classification: <NEW module | narrow-edit | replacement | config>
|
|
84
|
+
Pattern References from design: <paths from ## Pattern References that name this slice>
|
|
85
|
+
Integration anchors: <slice Integration anchors verbatim>
|
|
86
|
+
|
|
87
|
+
Return paste-ready snippets that match BOTH the shape and the contract."
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Wait for ALL pattern-finder calls to return before entering the topological loop. Cache results keyed by slice name. The synthesis loop consumes from this cache — do NOT re-dispatch pattern-finder per slice.
|
|
91
|
+
|
|
92
|
+
**For each slice in topological order:**
|
|
93
|
+
|
|
94
|
+
### 2a. Per-phase spot-checks, conditional dispatches, synthesize
|
|
95
|
+
|
|
96
|
+
- **Spot-check anchors**: Re-read every `file:line` in this slice's `Integration anchors` and `Files touched` (the artifact-level reverification ran once in Step 1.4; this catches drift introduced by an earlier slice's MODIFY in this same plan run). If a cited symbol moved, Edit the design artifact to correct the line range. If gone, STOP — return to /skill:design2 Step 5 for this slice.
|
|
97
|
+
- **Read prior phases' synthesized code from the artifact**: For each slice in this slice's `depends_on`, read its `## Phase N` section in the in-progress plan. Imports and types come from the actually-emitted code, not the contract abstraction.
|
|
98
|
+
- **Conditional dispatches** (run in parallel as `subagent(...)` blocks in one assistant message; only those that apply):
|
|
99
|
+
- Any `Files touched` entry is MODIFY → dispatch **integration-scanner** for that file/symbol. Task: "Map current callsites and wiring for [symbol] at [file]. List inbound references that must be preserved or updated, outbound dependencies the new code will inherit, and any config / event registration the symbol participates in."
|
|
100
|
+
- Change classification is replacement (closure / function rewrite > 20 lines) → dispatch **precedent-locator**. Task: "Find prior commits in this repository that performed similar [closure / function] rewrites at comparable size. Return commit SHAs, file paths, and any follow-up fix commits."
|
|
101
|
+
- An Integration anchor's surrounding code shape isn't obvious from the contract → dispatch **codebase-analyzer** (max 1) for that anchor.
|
|
102
|
+
- Pattern-finder cache returned no patterns AND Pattern References are empty → dispatch **web-search-researcher** for external documentation.
|
|
103
|
+
- Wait for all dispatched agents to return before synthesizing.
|
|
104
|
+
|
|
105
|
+
**MODIFY test-cascade.** When integration-scanner reports inbound references inside test files (`*.test.ts`, `*.spec.ts`) for any symbol this slice modifies, those test files become additional MODIFY entries in this slice's `### Changes Required:`. Synthesize updated test code that matches the slice's new signatures so existing test imports do not break. These cascaded test entries are independent of the slice's Verification hooks (which produce NEW test files) — these are pre-existing tests whose imports / type expectations would otherwise break under the modification.
|
|
106
|
+
|
|
107
|
+
After agents return, **synthesize contract-fulfilling code in the orchestrator** for this single slice:
|
|
108
|
+
- Use pattern-finder cache snippets as templates
|
|
109
|
+
- Apply this slice's contract Inputs/Outputs/Types/Integration anchors as the spec
|
|
110
|
+
- Honor architectural Q/A guardrails from `## Decisions` and per-slice Q/A constraints from the slice's `#### Q/A`
|
|
111
|
+
- Resolve imports against prior slices' actually-emitted exports (read from the artifact), not contract prose
|
|
112
|
+
- For MODIFY slices, preserve every callsite and wiring relationship reported by integration-scanner
|
|
113
|
+
- For replacement-class slices, reference precedent-locator findings as the structural template
|
|
114
|
+
- The code MUST fulfill the contract; the orchestrator must NOT invent new design decisions
|
|
115
|
+
|
|
116
|
+
**Tests as first-class entries.** Every test name in this slice's `Verification hooks` becomes a `#### N. <test-name>` entry under `### Changes Required:` with a real Vitest code block that satisfies the copy-pasteable contract (Step 2b). Co-locate `*.test.ts` next to the production source. Grep-pattern hooks → `expect(...)` matchers; observable-behavior hooks → assertions on `render(width)` / return shapes / factory-driver outcomes. If the test cannot be synthesized from the contract alone, STOP and return to /skill:design2 Step 5 — never emit a placeholder.
|
|
117
|
+
|
|
118
|
+
### 2b. Self-verify slice
|
|
119
|
+
|
|
120
|
+
Cross-check this slice's synthesized code and produce a structured summary:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
Self-verify Slice N: [name]
|
|
124
|
+
- Contract fulfillment: [OK / VIOLATION: contract field X not satisfied]
|
|
125
|
+
- Q/A guardrails: [OK / VIOLATION: architectural decision Y violated]
|
|
126
|
+
- Cross-slice: [OK / CONFLICT: imports from Slice M reference symbols not emitted]
|
|
127
|
+
- Research: [OK / WARNING: Verification Note Z not satisfied]
|
|
128
|
+
- Copy-pasteable: [OK / VIOLATION: code block <file> not paste-ready]
|
|
129
|
+
- Decision traceability: [OK / VIOLATION: Decision <D-id> "<title>" has no matching code at <plan-file>:<line-range>]
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**Decision traceability** (mechanical map, not prose). For each entry under the design's `## Decisions` section that this slice is responsible for implementing (a Decision is owned by a slice when its specifics are encoded in any of that slice's contract fields), identify the synthesized lines that implement the Decision's specifics. Record the mapping inline in the self-verify summary as `<D-id>: <plan-file>:<line-range>`. If any owned Decision has no matching code in this slice, the synthesis violated the design — re-synthesize. The point is to grep design Decisions against synthesized output, not to restate them in prose.
|
|
133
|
+
|
|
134
|
+
**Enumerated-set fidelity**. When a slice's contract enumerates a closed set (discriminated-union kinds, mode names, action types, key-binding names, error codes), the synthesized code emits exactly that set. Count the design's enumeration; count the plan's emission; mismatch in either direction is a violation. If synthesis discovers the set is insufficient, STOP and return to /skill:design2 Step 5 — do not silently expand it.
|
|
135
|
+
|
|
136
|
+
**Copy-pasteable contract** (happy-path enforcement). You are writing real implementation, not a sketch. Every code block MUST:
|
|
137
|
+
|
|
138
|
+
- Be paste-into-editor ready — `npm run check` (Biome + `tsc --noEmit`) passes against it. Every value concrete, every signature fully typed, every import resolves to a real export, every literal fully populated (no `{ ... }`, no `[ ... ]`).
|
|
139
|
+
- Stand alone per file — a reader needs nothing beyond the code block and its imports.
|
|
140
|
+
- Include the entire body of any function / method / closure the contract says is replaced — emit the whole thing, never a description.
|
|
141
|
+
- Have function bodies that compute the value their name and contract describe. Hardcoded returns (`return false`, `return constant`, `return param.length`) are stubs unless the contract says the function is a constant.
|
|
142
|
+
- Resolve every identifier to a declaration that precedes it in execution order. No TDZ, no forward-reference of `let` / `const` from inside an arrow that runs at construction time.
|
|
143
|
+
- Contain no deferred-work comment: `// TODO`, `// FIXME`, `// would need`, `// handled at <X>`, `// see <Y>`, `// for now`, `// later`, `// reset method needed`. If you catch yourself writing such a comment, the synthesis is incomplete — STOP and surface the gap.
|
|
144
|
+
- For any block whose contract says a function, closure, switch, or method is replaced, the AFTER state is the executable body itself, not a comment outline of it. Diff narration (`// BEFORE: ... // AFTER: ...`) may precede the block but never substitutes for it. Cases, branches, and statements the contract enumerates appear as real `case` / `if` / statements, not commented placeholders.
|
|
145
|
+
- A symbol marked `// REMOVED: <name>` must not appear in any AFTER body in the same phase. Grep the phase for `<name>`; any surviving reference falsifies the REMOVED claim.
|
|
146
|
+
|
|
147
|
+
If a contract's scope can't fit a single complete code block, the slice was under-decomposed — STOP and return to /skill:design2 Step 5.
|
|
148
|
+
|
|
149
|
+
**Self-heal on violation**: If any line above reports VIOLATION / CONFLICT / WARNING, re-synthesize the affected file once and re-run self-verify. If the second self-verify still reports a violation, STOP and surface the specific violation to the developer with the slice name, file, and the failing check — request guidance before proceeding.
|
|
150
|
+
|
|
151
|
+
### 2c. Write to artifact
|
|
152
|
+
|
|
153
|
+
**One phase, one cycle.** Steps 2a → 2b → 2c are a single transaction for ONE phase. Complete this phase's 2c artifact write before starting phase N+1's 2a. Never:
|
|
154
|
+
- Use the `Write` tool on the artifact (only `Edit`)
|
|
155
|
+
- Batch edits across multiple phase sections in one tool call
|
|
156
|
+
- Synthesize multiple phases' code in memory and then write them together
|
|
157
|
+
- Rewrite the entire artifact "for consistency" — the skeleton is already consistent
|
|
158
|
+
|
|
159
|
+
Each `Edit` call targets exactly one `## Phase N` section. If a single phase needs multiple Edits (one per file in `### Changes Required:`), issue them sequentially to disjoint regions of that phase's section.
|
|
160
|
+
|
|
161
|
+
On clean self-verify (all OK), Edit the artifact in place:
|
|
162
|
+
1. For each file in this phase, replace the phase's `### Changes Required:` placeholders with the synthesized code blocks.
|
|
163
|
+
2. Append to `## Plan History`: `- Phase N: [name] — synthesized`.
|
|
164
|
+
3. Decrement frontmatter `unresolved_phase_count` by 1.
|
|
165
|
+
4. Proceed to the next phase in topological order.
|
|
166
|
+
|
|
167
|
+
**Use this template structure** (the artifact's final shape; phases are written into the skeleton at Step 2.1 and progressively filled by 2c):
|
|
168
|
+
|
|
169
|
+
```markdown
|
|
170
|
+
---
|
|
171
|
+
date: [Current date and time with timezone in ISO format]
|
|
172
|
+
planner: [User from injected git context]
|
|
173
|
+
git_commit: [Current commit hash]
|
|
174
|
+
branch: [Current branch name]
|
|
175
|
+
repository: [Repository name]
|
|
176
|
+
topic: "[Feature/Task Name]"
|
|
177
|
+
tags: [plan, relevant-component-names]
|
|
178
|
+
status: ready
|
|
179
|
+
design_source: "[path to design artifact]"
|
|
180
|
+
slice_count: [S, copied from design frontmatter — informational]
|
|
181
|
+
phase_count: [P, equal to slice_count]
|
|
182
|
+
unresolved_phase_count: [decrements as each phase synthesizes in Step 2; 0 means synthesis complete]
|
|
183
|
+
last_updated: [Current date in YYYY-MM-DD format]
|
|
184
|
+
last_updated_by: [User from injected git context]
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
# [Feature/Task Name] Implementation Plan
|
|
188
|
+
|
|
189
|
+
## Overview
|
|
190
|
+
|
|
191
|
+
[Brief description of what we're implementing and why. Reference design artifact.]
|
|
192
|
+
|
|
193
|
+
## Desired End State
|
|
194
|
+
|
|
195
|
+
[From design artifact's Desired End State / Summary — what "done" looks like and how to verify it]
|
|
196
|
+
|
|
197
|
+
## What We're NOT Doing
|
|
198
|
+
|
|
199
|
+
[From design artifact's Scope → Not Building]
|
|
200
|
+
|
|
201
|
+
## Phase 1: [Descriptive Name]
|
|
202
|
+
|
|
203
|
+
### Overview
|
|
204
|
+
[What this phase accomplishes — fulfills slice [S]; parallelism note from `depends_on`]
|
|
205
|
+
|
|
206
|
+
### Changes Required:
|
|
207
|
+
|
|
208
|
+
#### 1. [Component/File Group]
|
|
209
|
+
**File**: `path/to/file.ext`
|
|
210
|
+
**Changes**: [Summary of changes]
|
|
211
|
+
**Fulfills**: Slice [S] contract Inputs/Outputs/Anchors
|
|
212
|
+
|
|
213
|
+
```[language]
|
|
214
|
+
// Synthesized from Slice [S] contract; pattern source: <pattern-finder file:line>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
#### 2. [Test name from slice's Verification hooks]
|
|
218
|
+
**File**: `path/to/file.test.ext`
|
|
219
|
+
**Fulfills**: Slice [S] Verification hook: `<hook test name>`
|
|
220
|
+
|
|
221
|
+
```[language]
|
|
222
|
+
// Synthesized from Slice [S] Verification hook; pattern source: <existing *.test.ext file:line>
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
(One Changes Required entry per Verification hook test name.)
|
|
226
|
+
|
|
227
|
+
### Success Criteria:
|
|
228
|
+
|
|
229
|
+
#### Automated Verification:
|
|
230
|
+
- [ ] `npm run check` passes
|
|
231
|
+
- [ ] `npm test` passes
|
|
232
|
+
|
|
233
|
+
#### Manual Verification:
|
|
234
|
+
- [ ] [From design's Verification Notes — observable behaviors not expressible as tests]
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Phase 2: [Descriptive Name]
|
|
239
|
+
|
|
240
|
+
[Similar structure...]
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Plan History
|
|
245
|
+
|
|
246
|
+
- Phase 1: [name] — synthesized
|
|
247
|
+
- Phase 2: [name] — synthesized
|
|
248
|
+
|
|
249
|
+
## Performance Considerations
|
|
250
|
+
|
|
251
|
+
[Copied from design artifact.]
|
|
252
|
+
|
|
253
|
+
## Migration Notes
|
|
254
|
+
|
|
255
|
+
[Copied from design artifact, or empty if N/A.]
|
|
256
|
+
|
|
257
|
+
## References
|
|
258
|
+
|
|
259
|
+
- Design: `thoughts/shared/designs/[file].md`
|
|
260
|
+
- Research: `thoughts/shared/research/[file].md`
|
|
261
|
+
- Original ticket (if any): `thoughts/me/tickets/[file].md`
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Step 3: Cross-Phase Integration Verify
|
|
265
|
+
|
|
266
|
+
After all phases are synthesized (`unresolved_phase_count == 0`), verify consistency across the synthesized phases via `claim-verifier`. The orchestrator builds an explicit claim list mechanically from design + skeleton; the agent grounds each claim against the in-progress plan and emits Verified / Weakened / Falsified per row.
|
|
267
|
+
|
|
268
|
+
1. **Build the claim list.** Walk the design + the in-progress plan artifact. For each phase N (which corresponds 1:1 with design slice N), emit one claim row per expected invariant. Use a stable ID scheme: `<phase-id>-<check-id>-<seq>` (e.g., `P3-EXPORT-1`, `P5-IMPORT-2`). Claim categories:
|
|
269
|
+
|
|
270
|
+
- **EXPORT**: each symbol named in the slice's `Outputs` / `Types/Data Model` is exported from the phase's synthesized code at `<plan-file>:<line>`.
|
|
271
|
+
- **IMPORT**: each `depends_on` reference resolves to a real export of the prior phase (cite the import line in this phase and the export line in the prior phase).
|
|
272
|
+
- **FILE-MAP**: each entry in the design's `## File Map` has a synthesized code block in exactly one phase.
|
|
273
|
+
- **TEST-ENTRY**: each test name in the slice's `Verification hooks` has a `#### N. <test-name>` Changes Required entry under that phase.
|
|
274
|
+
- **DECISION-SPEC**: for each Decision owned by this slice, claim its specifics — what symbol does what at which line. Example: "D<N> (<title>) → case `<action>` sets `<flag-A> = true` (NOT a similarly named `<flag-B>`) at `<line>`."
|
|
275
|
+
- **SET-CARDINALITY**: for each closed set the design enumerates, claim the plan emits the same members at the same count. Format: "Slice <N> enumerates {a, b, c} (count=3); plan emits {a, b, c} at `<line>` (count=3)." Extra, missing, or renamed members → Falsified.
|
|
276
|
+
- **MODIFY-BODY**: for each MODIFY entry, claim the AFTER block contains executable statements at `<line>` (real declarations / cases / branches), not commented narration. A block whose AFTER body is `//` lines only → Falsified.
|
|
277
|
+
- **REMOVED-SURVIVOR**: for each `// REMOVED: <name>` annotation, claim `<name>` does not appear in any AFTER body across all phases. Any surviving reference → Falsified.
|
|
278
|
+
- **VERIFICATION-NOTE**: each item in the design's `## Verification Notes` is satisfied by some synthesized code or test (cite the satisfying location).
|
|
279
|
+
- **METHOD-USAGE**: each public method / setter / factory-output member declared on a class or object in any phase has at least one call site in a downstream phase OR is documented as intentionally unused.
|
|
280
|
+
- **COMMENT-REF**: each comment referencing work performed elsewhere ("handled at integration layer", "managed by Slice X", "see Y", "reset in caller") cites a location that actually performs that work.
|
|
281
|
+
- **SEMANTIC-CLAIM**: for each behavior-prescribing `#### Q/A` clause (verb-led: cancels / sets / rebuilds / activates — not noun-led: is / has), claim what the code does at a specific line. Examples:
|
|
282
|
+
- "Slice <N> Q/A '<verb-led behavior clause>' → handler `<name>` performs `<observable mutation>` at `<line>`."
|
|
283
|
+
- "Slice <N> Outputs '<derivation rule citing a domain field>' → mapper uses the domain field (NOT iteration-index `i`) at `<line>`."
|
|
284
|
+
- **ANCHOR**: each `file:line` cited in any slice's `Integration anchors` still matches the symbol it's claimed to anchor in the source repository.
|
|
285
|
+
|
|
286
|
+
2. **Dispatch `claim-verifier`** with the claim list:
|
|
287
|
+
|
|
288
|
+
```
|
|
289
|
+
subagent({
|
|
290
|
+
agent: "claim-verifier",
|
|
291
|
+
task: "Verify each claim below against <plan artifact path> and <design artifact path>. Ground non-ANCHOR claims in the plan artifact's '## Phase N' code blocks; ANCHOR claims in the cited source file. Emit one row per claim:
|
|
292
|
+
|
|
293
|
+
FINDING <id> | <Verified|Weakened|Falsified> | <one-line justification with file:line>
|
|
294
|
+
|
|
295
|
+
Claims:
|
|
296
|
+
<id-1> | <category> | <claim text with cited <file:line> evidence the orchestrator expects to see>
|
|
297
|
+
<id-2> | <category> | ...
|
|
298
|
+
...",
|
|
299
|
+
context: "fresh",
|
|
300
|
+
artifacts: false
|
|
301
|
+
})
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
3. **Present integration summary** (under 15 lines):
|
|
305
|
+
```
|
|
306
|
+
Integration: [feature name] — [P] phases synthesized
|
|
307
|
+
Phases: [brief list of phase names and file counts]
|
|
308
|
+
Claims verified: [N] | Weakened: [W] | Falsified: [F]
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
4. **On any Falsified or Weakened row**: parse the phase from the claim ID, return to Step 2 for that phase, re-synthesize once, then rebuild the claim list and re-dispatch `claim-verifier`. If any row is still Falsified/Weakened after one auto-resynthesis cycle, STOP and surface those rows to the developer for guidance.
|
|
312
|
+
|
|
313
|
+
5. **On all Verified**: proceed directly to finalize.
|
|
314
|
+
|
|
315
|
+
6. **Finalize**: Set frontmatter `status: ready`, `unresolved_phase_count: 0`. Present:
|
|
316
|
+
|
|
317
|
+
```
|
|
318
|
+
Implementation plan written to: thoughts/shared/plans/[filename].md
|
|
319
|
+
[P] phases synthesized, [F] total file changes.
|
|
320
|
+
Run `/skill:implement thoughts/shared/plans/[filename].md Phase 1` when ready.
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
7. **Iterate on feedback**: adjust Success Criteria, return to Step 2 for a wrong phase, or return to /skill:design2 Step 5 for an under-specified contract.
|
|
324
|
+
|
|
325
|
+
## Guidelines
|
|
326
|
+
|
|
327
|
+
- **No routine developer touchpoint**: synthesis runs end-to-end. Stop and surface only on real failure signals — self-verify still violating after one auto-retry, Step 3 finding still present after one auto-resynthesis, an anchor whose cited symbol is gone, or a contract proven under-specified during synthesis.
|
|
328
|
+
- **Trust the design**: Slice Contracts and Decisions are fixed. If a contract is wrong or under-specified, return to /skill:design2 Step 5 — do not silently change the approach.
|
|
329
|
+
- **No open questions in the final plan**: Step 1's two-pass STOP gate already filtered them. If new questions surface during synthesis, the contract is under-specified — STOP and return to design2.
|
|
330
|
+
|
|
331
|
+
## Success Criteria Conversion
|
|
332
|
+
|
|
333
|
+
Each phase's `### Success Criteria:` always splits into Automated and Manual.
|
|
334
|
+
|
|
335
|
+
**Format example:**
|
|
336
|
+
```markdown
|
|
337
|
+
### Success Criteria:
|
|
338
|
+
|
|
339
|
+
#### Automated Verification:
|
|
340
|
+
- [ ] All unit tests pass: `npm test`
|
|
341
|
+
- [ ] No linting errors: `npm run check`
|
|
342
|
+
- [ ] Grep pattern from Slice 1 Verification hook: `grep -r "newApiCall" packages/ | wc -l` returns >= 3
|
|
343
|
+
- [ ] API endpoint returns 200: `curl localhost:8080/api/new-endpoint`
|
|
344
|
+
|
|
345
|
+
#### Manual Verification:
|
|
346
|
+
- [ ] New feature appears correctly in the UI
|
|
347
|
+
- [ ] Performance is acceptable with 1000+ items
|
|
348
|
+
- [ ] Error messages are user-friendly
|
|
349
|
+
- [ ] Feature works correctly on mobile devices
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
**Convert design's Verification Notes AND each slice's Verification hooks to success criteria:**
|
|
353
|
+
- Slice Verification hook test names → automated `npm test` matchers
|
|
354
|
+
- Slice Verification hook grep patterns → `grep -r "..." | wc -l` automated checks
|
|
355
|
+
- Slice Verification hook observable behaviors → manual verification steps
|
|
356
|
+
- Artifact-level Verification Notes (precedents/warnings) → cross-phase manual verification
|
|
357
|
+
- Prose warnings → specific automated commands or manual steps
|
|
358
|
+
|
|
359
|
+
## Important Notes
|
|
360
|
+
|
|
361
|
+
- NEVER edit source files — this skill produces a plan document, not implementation.
|
|
362
|
+
- **Never write the artifact whole**: after Step 1's skeleton, only `Edit` operations touch the artifact, and each `Edit` is scoped to a single `## Phase N` section. Batched cross-phase Edits and full-file rewrites are forbidden — they cause overlap errors and break the per-phase transaction.
|
|
363
|
+
- **One slice per phase**: each design slice maps to exactly one plan phase, in topological order from `depends_on`. No grouping at synthesis time, no packaging step.
|
|
364
|
+
- **Read prior phases' emitted code, not their contracts**: when synthesizing a phase whose slice has `depends_on`, import against the actually-emitted exports in prior `## Phase N` sections, not the abstract contract.
|
|
365
|
+
- **Agents fulfill contracts, never invent decisions** — pattern-finder (Step 2.0 templates), integration-scanner (Step 2a MODIFY), precedent-locator (Step 2a replacement), codebase-analyzer (Step 2a anchor ambiguity), web-search-researcher (Step 2a novel work), and claim-verifier (Step 3 cross-phase verification) return templates, analysis, or row-tagged findings; the orchestrator synthesizes.
|
|
366
|
+
- **Frontmatter consistency**: snake_case for multi-word field names.
|
|
367
|
+
- **Pre-restructure design refusal**: if the design lacks the `slices:` frontmatter array, STOP and instruct the developer to re-run /skill:design2.
|
package/skills/research/SKILL.md
CHANGED
|
@@ -1,33 +1,46 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: research
|
|
3
|
-
description: Answer structured research questions via targeted parallel analysis agents.
|
|
4
|
-
argument-hint: [path to discover artifact]
|
|
3
|
+
description: Answer structured research questions via targeted parallel analysis agents. Accepts either a questions artifact from discover OR a free-text prompt/task (in which case it auto-runs discover via a subagent). Produces research documents in thoughts/shared/research/.
|
|
4
|
+
argument-hint: [path to discover artifact | free-text research prompt]
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
## Questions Source
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
The user's argument is inlined below as `$ARGUMENTS` (resolved by rpiv-args). If `$ARGUMENTS` is empty, ask for input. If `$ARGUMENTS` is a path to a `.md` file under `thoughts/`, treat it as a discover artifact. Otherwise treat it as a free-text research prompt and auto-run discover via a subagent (Step 1, free-text branch).
|
|
10
10
|
|
|
11
11
|
# Research
|
|
12
12
|
|
|
13
|
-
You are tasked with answering structured research questions by spawning targeted analysis agents and synthesizing their findings into a comprehensive research document. This skill consumes questions artifacts produced by the `discover` skill.
|
|
13
|
+
You are tasked with answering structured research questions by spawning targeted analysis agents and synthesizing their findings into a comprehensive research document. This skill consumes questions artifacts produced by the `discover` skill — either provided directly by the user, or produced on-demand via a subagent when the user passes free text.
|
|
14
|
+
|
|
15
|
+
Argument (resolved by rpiv-args): `$ARGUMENTS`
|
|
14
16
|
|
|
15
17
|
## Step 1: Read Questions Artifact
|
|
16
18
|
|
|
17
|
-
1. **Determine input
|
|
19
|
+
1. **Determine input** by inspecting `$ARGUMENTS`:
|
|
18
20
|
|
|
19
|
-
**
|
|
21
|
+
**Path to a `.md` file under `thoughts/`** (questions artifact):
|
|
20
22
|
- Read the questions artifact FULLY using the Read tool WITHOUT limit/offset
|
|
21
23
|
- Extract: Discovery Summary, Questions (dense paragraphs), frontmatter metadata (topic, tags)
|
|
22
24
|
- The Discovery Summary provides the file landscape overview — no need to re-discover
|
|
23
25
|
|
|
24
|
-
**
|
|
26
|
+
**Free-text prompt / task description** (`$ARGUMENTS` is non-empty and is NOT a path to a `thoughts/**/*.md` file):
|
|
27
|
+
- Dispatch ONE subagent to run discover end-to-end in non-interactive mode:
|
|
28
|
+
```
|
|
29
|
+
subagent({
|
|
30
|
+
agent: "general-purpose",
|
|
31
|
+
task: "Read packages/rpiv-pi/skills/discover/SKILL.md and execute it in subagent (non-interactive) mode.
|
|
32
|
+
Topic: $ARGUMENTS
|
|
33
|
+
Return ONLY the absolute path to the questions artifact you wrote.",
|
|
34
|
+
context: "fresh",
|
|
35
|
+
artifacts: false
|
|
36
|
+
})
|
|
37
|
+
```
|
|
38
|
+
- Capture the returned absolute path, then fall through into the "Path to a `.md` file …" branch above.
|
|
39
|
+
- Report: `[Auto-discovered]: ran discover via subagent for "$ARGUMENTS". Questions artifact: [path].`
|
|
40
|
+
|
|
41
|
+
**`$ARGUMENTS` is empty:**
|
|
25
42
|
```
|
|
26
|
-
|
|
27
|
-
`/skill:research thoughts/shared/questions/YYYY-MM-DD_HH-MM-SS_topic.md`
|
|
28
|
-
|
|
29
|
-
This skill requires a questions artifact from discover.
|
|
30
|
-
There is no standalone path — run /skill:discover first to produce a questions artifact.
|
|
43
|
+
Please provide a discover questions artifact path or a free-text research prompt. Free text will auto-run discover via a subagent first.
|
|
31
44
|
```
|
|
32
45
|
Then wait for input.
|
|
33
46
|
|
|
@@ -289,7 +302,7 @@ When ready:
|
|
|
289
302
|
## Important Notes
|
|
290
303
|
|
|
291
304
|
- **Analysis only**: This skill answers questions. It does NOT discover what to ask — that's discover's job.
|
|
292
|
-
- **
|
|
305
|
+
- **Two entry points**: A discover questions artifact path (chained) OR free text (auto-runs discover via a subagent in non-interactive mode, then proceeds with the produced artifact). Argument substitution is handled by `rpiv-args` (`$ARGUMENTS`).
|
|
293
306
|
- **Grouped dispatch**: Related questions are batched per agent based on file overlap. Default agent: codebase-analyzer. This reduces token waste from redundant file reads and lets agents build cross-question context.
|
|
294
307
|
- **Downstream compatible**: Research documents feed directly into design and plan — the same Code References / Integration Points / Architecture Insights sections they expect.
|
|
295
308
|
- **File reading**: Always read the questions artifact FULLY (no limit/offset) before dispatching agents
|