@juicesharp/rpiv-pi 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +178 -0
  3. package/agents/codebase-analyzer.md +121 -0
  4. package/agents/codebase-locator.md +107 -0
  5. package/agents/codebase-pattern-finder.md +207 -0
  6. package/agents/integration-scanner.md +97 -0
  7. package/agents/precedent-locator.md +130 -0
  8. package/agents/test-case-locator.md +121 -0
  9. package/agents/thoughts-analyzer.md +147 -0
  10. package/agents/thoughts-locator.md +138 -0
  11. package/agents/web-search-researcher.md +107 -0
  12. package/extensions/rpiv-core/agents.ts +312 -0
  13. package/extensions/rpiv-core/git-context.ts +81 -0
  14. package/extensions/rpiv-core/guidance.ts +213 -0
  15. package/extensions/rpiv-core/index.ts +275 -0
  16. package/extensions/rpiv-core/package-checks.ts +51 -0
  17. package/package.json +36 -0
  18. package/scripts/migrate.js +242 -0
  19. package/scripts/types.js +1 -0
  20. package/skills/annotate-guidance/SKILL.md +303 -0
  21. package/skills/annotate-guidance/examples/root-dotnet-clean-arch.md +38 -0
  22. package/skills/annotate-guidance/examples/root-nodejs-monorepo.md +42 -0
  23. package/skills/annotate-guidance/examples/subfolder-database-layer.md +81 -0
  24. package/skills/annotate-guidance/examples/subfolder-dotnet-application.md +64 -0
  25. package/skills/annotate-guidance/examples/subfolder-schemas-layer.md +50 -0
  26. package/skills/annotate-guidance/templates/root-architecture.md +46 -0
  27. package/skills/annotate-guidance/templates/subfolder-architecture.md +57 -0
  28. package/skills/annotate-inline/SKILL.md +299 -0
  29. package/skills/annotate-inline/examples/root-dotnet-clean-arch.md +38 -0
  30. package/skills/annotate-inline/examples/root-nodejs-monorepo.md +42 -0
  31. package/skills/annotate-inline/examples/subfolder-database-layer.md +81 -0
  32. package/skills/annotate-inline/examples/subfolder-dotnet-application.md +64 -0
  33. package/skills/annotate-inline/examples/subfolder-schemas-layer.md +50 -0
  34. package/skills/annotate-inline/templates/root-claude-md.md +46 -0
  35. package/skills/annotate-inline/templates/subfolder-claude-md.md +57 -0
  36. package/skills/code-review/SKILL.md +184 -0
  37. package/skills/commit/SKILL.md +65 -0
  38. package/skills/create-handoff/SKILL.md +91 -0
  39. package/skills/design/SKILL.md +416 -0
  40. package/skills/discover/SKILL.md +242 -0
  41. package/skills/explore/SKILL.md +261 -0
  42. package/skills/implement/SKILL.md +74 -0
  43. package/skills/migrate-to-guidance/SKILL.md +88 -0
  44. package/skills/outline-test-cases/SKILL.md +348 -0
  45. package/skills/outline-test-cases/templates/feature-meta.md +43 -0
  46. package/skills/outline-test-cases/templates/outline-readme.md +36 -0
  47. package/skills/plan/SKILL.md +281 -0
  48. package/skills/research/SKILL.md +304 -0
  49. package/skills/resume-handoff/SKILL.md +207 -0
  50. package/skills/revise/SKILL.md +242 -0
  51. package/skills/validate/SKILL.md +175 -0
  52. package/skills/write-test-cases/SKILL.md +322 -0
  53. package/skills/write-test-cases/examples/customer-auth-flow.md +50 -0
  54. package/skills/write-test-cases/examples/order-management-suite.md +57 -0
  55. package/skills/write-test-cases/examples/order-placement-flow.md +54 -0
  56. package/skills/write-test-cases/examples/team-management-flow.md +56 -0
  57. package/skills/write-test-cases/examples/team-management-suite.md +54 -0
  58. package/skills/write-test-cases/templates/coverage-map.md +64 -0
  59. package/skills/write-test-cases/templates/regression-suite.md +63 -0
  60. package/skills/write-test-cases/templates/test-case.md +65 -0
@@ -0,0 +1,91 @@
1
+ ---
2
+ name: create-handoff
3
+ description: Create context-preserving handoff documents for session transitions. Compacts essential context into concise documents. Use when context is getting large or before starting a fresh session.
4
+ argument-hint: [description]
5
+ allowed-tools: Read, Write, Bash(git *), Glob, Grep
6
+ disable-model-invocation: true
7
+ ---
8
+
9
+ # Create Handoff
10
+
11
+ You are tasked with writing a handoff document to hand off your work to another agent in a new session. You will create a handoff document that is thorough, but also **concise**. The goal is to compact and summarize your context without losing any of the key details of what you're working on.
12
+
13
+
14
+ ## Process
15
+ ### 1. Filepath & Metadata
16
+ Use the following information to understand how to create your document:
17
+ - create your file under `thoughts/shared/handoffs/YYYY-MM-DD_HH-MM-SS_description.md`, where:
18
+ - YYYY-MM-DD is today's date
19
+ - HH-MM-SS is the hours, minutes and seconds based on the current time, in 24-hour format (i.e. use `13-00-00` for `1:00 pm`)
20
+ - description is a brief kebab-case description
21
+ - Repository name: from git root basename, or current directory basename if not a git repo
22
+ - Use the git branch and commit from the git context injected at the start of the session (or run `git branch --show-current` / `git rev-parse --short HEAD` directly)
23
+ - Researcher: use the User from the git context injected at the start of the session (fallback: "unknown")
24
+ - If metadata unavailable: use "unknown" for commit/branch
25
+ - Examples:
26
+ - `thoughts/shared/handoffs/2025-01-08_13-55-22_create-context-compaction.md`
27
+
28
+ ### 2. Handoff writing.
29
+ using the above conventions, write your document. use the defined filepath, and the following YAML frontmatter pattern. Use the metadata gathered in step 1, Structure the document with YAML frontmatter followed by content:
30
+
31
+ Use the following template structure:
32
+ ```markdown
33
+ ---
34
+ date: [Current date and time with timezone in ISO format]
35
+ researcher: [Researcher name from thoughts status]
36
+ git_commit: [Current commit hash]
37
+ branch: [Current branch name]
38
+ repository: [Repository name]
39
+ topic: "[Feature/Task Name] [Work Type]" # Customize work type: Implementation Strategy, Bug Fix, Research, Feature Implementation, etc.
40
+ tags: [implementation, strategy, relevant-component-names]
41
+ status: complete
42
+ last_updated: [Current date in YYYY-MM-DD format]
43
+ last_updated_by: [Researcher name]
44
+ type: [work_type] # Options: implementation_strategy, bug_fix, research, refactoring, feature_development, etc.
45
+ ---
46
+
47
+ # Handoff: {very concise description}
48
+
49
+ ## Task(s)
50
+ {description of the task(s) that you were working on, along with the status of each (completed, work in progress, planned/discussed). If you are working on an implementation plan, make sure to call out which phase you are on. Make sure to reference the plan document and/or research document(s) you are working from that were provided to you at the beginning of the session, if applicable.}
51
+
52
+ ## Critical References
53
+ {List any critical specification documents, architectural decisions, or design docs that must be followed. Include only 2-3 most important file paths. Leave blank if none.}
54
+
55
+ ## Recent changes
56
+ {describe recent changes made to the codebase that you made in file:line syntax}
57
+
58
+ ## Learnings
59
+ {describe important things that you learned - e.g. patterns, root causes of bugs, or other important pieces of information someone that is picking up your work after you should know. consider listing explicit file paths.}
60
+
61
+ ## Artifacts
62
+ { an exhaustive list of artifacts you produced or updated as filepaths and/or file:line references - e.g. paths to feature documents, implementation plans, etc that should be read in order to resume your work.}
63
+
64
+ ## Action Items & Next Steps
65
+ { a list of action items and next steps for the next agent to accomplish based on your tasks and their statuses}
66
+
67
+ ## Other Notes
68
+ { other notes, references, or useful information - e.g. where relevant sections of the codebase are, where relevant documents are, or other important things you learned that you want to pass on but that don't fall into the above categories}
69
+ ```
70
+ ---
71
+
72
+ ### 3. Approve
73
+ Save the document.
74
+
75
+ Once this is completed, you should respond to the user with the template between <template_response></template_response> XML tags. do NOT include the tags in your response.
76
+
77
+ <template_response>
78
+ Handoff created! You can resume from this handoff in a new session with the following command:
79
+
80
+ ```bash
81
+ /skill:resume-handoff thoughts/shared/handoffs/YYYY-MM-DD_HH-MM-SS_description.md
82
+ ```
83
+
84
+ Replace the path with your actual handoff file path.
85
+ </template_response>
86
+
87
+ ---
88
+ ## Additional Notes & Instructions
89
+ - **more information, not less**. This is a guideline that defines the minimum of what a handoff should be. Always feel free to include more information if necessary.
90
+ - **be thorough and precise**. include both top-level objectives, and lower-level details as necessary.
91
+ - **avoid excessive code snippets**. While a brief snippet to describe some key change is important, avoid large code blocks or diffs; do not include one unless it's necessary (e.g. pertains to an error you're debugging). Prefer using `/path/to/file.ext:line` references that an agent can follow later when it's ready, e.g. `packages/dashboard/src/app/dashboard/page.tsx:12-24`
@@ -0,0 +1,416 @@
1
+ ---
2
+ name: design
3
+ description: Design features through iterative vertical-slice decomposition and progressive code generation with developer micro-checkpoints. For complex multi-component features touching 6+ files across multiple layers. Produces design artifacts in thoughts/shared/designs/. Always requires a research artifact from discover → research, or a solutions artifact from explore.
4
+ argument-hint: [research artifact path]
5
+ ---
6
+
7
+ # Design
8
+
9
+ You are tasked with designing how code will be shaped for a feature or change. This iterative variant decomposes features into vertical slices and generates code slice-by-slice with developer micro-checkpoints between slices. The design artifact feeds directly into plan, which sequences it into phases.
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
+ - Identify ambiguities — triage into simple decisions and genuine ambiguities (Step 3)
15
+ - Holistic self-critique — review the combined design for gaps and contradictions (Step 4)
16
+ - Developer checkpoint — resolve genuine ambiguities one at a time (Step 5)
17
+ - Decompose into vertical slices holistically before generating code (Step 6)
18
+ - Generate code slice-by-slice with developer micro-checkpoints (Step 7)
19
+ - Verify cross-slice integration consistency (Step 8)
20
+ - Finalize the design artifact (Step 9)
21
+ - Review and iterate with the developer (Step 10)
22
+
23
+ The final artifact is plan-compatible.
24
+
25
+ ## Step 1: Input Handling
26
+
27
+ When this command is invoked:
28
+
29
+ 1. **Read research artifact**:
30
+
31
+ **Research artifact provided** (argument contains a path to a `.md` file in `thoughts/`):
32
+ - Read the research artifact FULLY using the Read tool WITHOUT limit/offset
33
+ - Extract: Summary, Code References, Integration Points, Architecture Insights, Developer Context, Open Questions
34
+ - **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.
35
+ - These become starting context — no need to re-discover what exists
36
+ - Research Developer Context Q/As = inherited decisions (record in Decisions, never re-ask); Open Questions = starting ambiguity queue, filtered by dimension in Step 3
37
+ - If a discover artifact is also provided, read it for additional discovery context
38
+
39
+ **No arguments provided**:
40
+ ```
41
+ I'll design a feature iteratively from a research artifact. Please provide:
42
+
43
+ `/skill:design [research artifact] [discover] [task description]`
44
+
45
+ Research artifact is required. Discover and task description are optional, in any order.
46
+ ```
47
+ Then wait for input.
48
+
49
+ 2. **Read any additional files mentioned** — tickets, related designs, existing implementations. Read them FULLY before proceeding.
50
+
51
+ ## Step 2: Targeted Research
52
+
53
+ This is NOT a discovery sweep. Focus on DEPTH (how things work, what patterns to follow) not BREADTH (where things are).
54
+
55
+ 1. **Spawn parallel research agents** using the Agent tool:
56
+
57
+ - Use **codebase-pattern-finder** to find existing implementations to model after — the primary template for code shape
58
+ - Use **codebase-analyzer** to understand HOW integration points work in detail
59
+ - Use **integration-scanner** to map the wiring surface — inbound refs, outbound deps, config/DI/event registration
60
+ - 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
61
+
62
+ **Novel work** (new libraries, first-time patterns, no existing codebase precedent):
63
+ - Add **web-search-researcher** for external documentation, API references, and community patterns
64
+ - Instruct it to return LINKS with findings — include those links in the final design artifact
65
+
66
+ Agent prompts should focus on:
67
+ - "Find the implementation pattern I should model after for [feature type]"
68
+ - "How does [integration point] work in detail — show me the wiring"
69
+ - "What connects to [component] — inbound refs, outbound deps, config"
70
+
71
+ NOT: "Find all files related to X" — that's discovery's job, upstream of this skill.
72
+
73
+ 2. **Read all key files identified by agents** into the main context — especially the pattern templates you'll model after.
74
+
75
+ 3. **Wait for ALL agents to complete** before proceeding.
76
+
77
+ 4. **Analyze and verify understanding**:
78
+ - Cross-reference research findings with actual code read in Step 1
79
+ - Identify any discrepancies or misunderstandings
80
+ - Note assumptions that need verification
81
+ - Determine true scope based on codebase reality
82
+
83
+ ## Step 3: Identify Ambiguities — Dimension Sweep
84
+
85
+ Walk Step 2 findings, inherited research Q/As, and carried Open Questions through six architectural dimensions that map 1:1 to `plan` extract sections — the sweep guarantees downstream completeness. Add **migration** as a seventh dimension only if the feature changes persisted schema.
86
+
87
+ - **Data model** — types, schemas, entities
88
+ - **API surface** — signatures, exports, routes
89
+ - **Integration wiring** — mount points, DI, events, config
90
+ - **Scope** — in / explicitly deferred
91
+ - **Verification** — tests, assertions, risk-bearing behaviors
92
+ - **Performance** — load paths, caching, N+1 risks
93
+
94
+ For each dimension, classify findings as **simple decisions** (one valid option, obvious from codebase — record in Decisions with `file:line` evidence, do not ask) or **genuine ambiguities** (multiple valid options, conflicting patterns, scope questions, novel choices — queue for Step 5). Inherited research Q/As land as simple; Open Questions filter by dimension — architectural survives, implementation-detail defers.
95
+
96
+ **Pre-validate every option** before queuing it against research constraints and runtime code behavior. Eliminate or caveat options that contradict Steps 1-2 evidence. **Coverage check**: every Step 2 file read appears in at least one decision or ambiguity; every dimension is addressed (silently-resolved valid, skipped-unchecked not).
97
+
98
+ ## Step 4: Holistic Self-Critique
99
+
100
+ Before presenting ambiguities to the developer, review the combined design picture holistically. Step 3 triages findings individually — this step checks whether they fit together as a coherent whole.
101
+
102
+ **Prompt yourself:**
103
+ - What's inconsistent, missing, or contradictory across the research findings, resolved decisions, and identified ambiguities?
104
+ - What edge cases or failure modes aren't covered by any ambiguity or decision?
105
+ - Do any patterns from different agents conflict when combined?
106
+
107
+ **Areas to consider** (suggestive, not a checklist):
108
+ - Requirement coverage — is every requirement from Step 1 addressed by at least one decision or ambiguity?
109
+ - Cross-cutting concerns — do error handling, state management, or performance span multiple ambiguities without being owned by any?
110
+ - Pattern coherence — do the simple decisions from Step 3 still hold when viewed together, or does a combination reveal a conflict?
111
+ - Ambiguity completeness — did Step 3 miss a genuine ambiguity by treating a multi-faceted issue as simple?
112
+
113
+ **Remediation:**
114
+ - Issues you can resolve with evidence: fix in-place — reclassify simple decisions as genuine ambiguities, or resolve a genuine ambiguity as simple if holistic review provides clarity. Note what changed.
115
+ - Issues that need developer input: add as new genuine ambiguities to the Step 5 checkpoint queue.
116
+ - If no issues found: proceed to Step 5 with the existing ambiguity set.
117
+
118
+ ## Step 5: Developer Checkpoint
119
+
120
+ Use the grounded-questions-one-at-a-time pattern. Use a **❓ Question:** prefix so the developer knows their input is needed. Each question must:
121
+ - Reference real findings with `file:line` evidence
122
+ - Present concrete options (not abstract choices)
123
+ - Pull a DECISION from the developer, not confirm what you already found
124
+
125
+ **Question patterns by ambiguity type:**
126
+
127
+ - **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?"
128
+ - **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?"
129
+ - **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?"
130
+ - **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]?"
131
+ - **Novel approach**: "No existing [X] in the project. Options: (A) [library/pattern] — [evidence/rationale], (B) [library/pattern] — [evidence/rationale]. Which fits?"
132
+
133
+ **Critical rules:**
134
+ - Ask ONE question at a time. Wait for the answer before asking the next.
135
+ - Lead with the most architecturally significant ambiguity.
136
+ - Every answer becomes a FIXED decision — no revisiting unless the developer explicitly asks.
137
+
138
+ **Choosing question format:**
139
+
140
+ - **`ask_user_question` tool** — when your question has 2-4 concrete options from code analysis (pattern conflicts, integration choices, scope boundaries, priority overrides). The user can always pick "Other" for free-text. Example:
141
+
142
+ > Use the `ask_user_question` tool with the following question: "Found 2 mapping approaches — which should new code follow?". Header: "Pattern". Options: "Manual mapping (Recommended)" (Used in OrderService (src/services/OrderService.ts:45) — 8 occurrences); "AutoMapper" (Used in UserService (src/services/UserService.ts:12) — 2 occurrences).
143
+
144
+ - **Free-text with ❓ Question: prefix** — when the question is open-ended and options can't be predicted (discovery, "what am I missing?", corrections). Example:
145
+ "❓ Question: Integration scanner found no background job registration for this area. Is that expected, or is there async processing I'm not seeing?"
146
+
147
+ **Batching**: When you have 2-4 independent questions (answers don't depend on each other), you MAY batch them in a single `ask_user_question` call. Keep dependent questions sequential.
148
+
149
+ **Classify each response:**
150
+
151
+ **Decision** (e.g., "use pattern A", "yes, follow that approach"):
152
+ - Record in Developer Context. Fix in Decisions section.
153
+
154
+ **Correction** (e.g., "no, there's a third option you missed", "check the events module"):
155
+ - Spawn targeted rescan: **codebase-analyzer** on the new area (max 1-2 agents).
156
+ - Merge results. Update ambiguity assessment.
157
+
158
+ **Scope adjustment** (e.g., "skip the UI, backend only", "include tests"):
159
+ - Record in Developer Context. Adjust scope.
160
+
161
+ **After all ambiguities are resolved**, present a brief design summary (under 15 lines):
162
+
163
+ ```
164
+ Design: [feature name]
165
+ Approach: [1-2 sentence summary of chosen architecture]
166
+
167
+ Decisions:
168
+ - [Decision 1]: [choice] — modeled after `file:line`
169
+ - [Decision 2]: [choice]
170
+ - [Decision 3]: [choice]
171
+
172
+ Scope: [what's in] | Not building: [what's out]
173
+ Files: [N] new, [M] modified
174
+ ```
175
+
176
+ Use the `ask_user_question` tool to confirm before proceeding. Question: "[Summary from design brief above]. Ready to proceed to decomposition?". Header: "Design". Options: "Proceed (Recommended)" (Decompose into vertical slices, then generate code slice-by-slice); "Adjust decisions" (Revisit one or more architectural decisions above); "Change scope" (Add or remove items from the building/not-building lists).
177
+
178
+ ## Step 6: Feature Decomposition
179
+
180
+ After the design summary is confirmed, decompose the feature into vertical slices. Each slice is a self-contained unit: types + implementation + wiring for one concern.
181
+
182
+ 1. **Decompose holistically** — define ALL slices, dependencies, and ordering before generating any code:
183
+
184
+ ```
185
+ Feature Breakdown: [feature name]
186
+
187
+ Slice 1: [name] — [what this slice delivers]
188
+ Files: path/to/file.ext (NEW), path/to/file.ext (MODIFY)
189
+ Depends on: nothing (foundation)
190
+
191
+ Slice 2: [name] — [what this slice delivers]
192
+ Files: path/to/file.ext (NEW), path/to/file.ext (MODIFY)
193
+ Depends on: Slice 1
194
+
195
+ Slice 3: [name] — [what this slice delivers]
196
+ Files: path/to/file.ext (NEW)
197
+ Depends on: Slice 2
198
+ ```
199
+
200
+ 2. **Slice properties**:
201
+ - End-to-end vertical: each slice is a complete cross-section of one concern (types + impl + wiring)
202
+ - ~512-1024 tokens per slice (maps to individual file blocks)
203
+ - Sequential: each builds on the previous (never parallel)
204
+ - Foundation first: types/interfaces always Slice 1
205
+
206
+ 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 (Recommended)" (Proceed to slice-by-slice code generation); "Adjust slices" (Reorder, merge, or split slices before generating); "Change scope" (Add or remove files from the decomposition).
207
+
208
+ 4. **Create skeleton artifact** — immediately after decomposition is approved:
209
+ - 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")
210
+ - Write skeleton using the Write tool with `status: in-progress` in frontmatter
211
+ - **Include all prose sections filled** from Steps 1-5: Summary, Requirements, Current State Analysis, Scope, Decisions, Desired End State, File Map, Ordering Constraints, Verification Notes, Performance Considerations, Migration Notes, Pattern References, Developer Context, References
212
+ - **Architecture section**: one `### path/to/file.ext — NEW/MODIFY` heading per file from the decomposition, with empty code fences as placeholders
213
+ - **Design History section**: list all slices with `— pending` status
214
+ - This is the living artifact — all subsequent writes use the Edit tool
215
+
216
+ **Artifact template sections** (all required in skeleton):
217
+
218
+ - **Frontmatter**: date, designer, git_commit, branch, repository, topic, tags, `status: in-progress`, research_source, last_updated, last_updated_by
219
+ - **# Design: [Feature Name]**
220
+ - **## Summary**: 2-3 sentences — what we're building and the chosen architectural approach. Settled decision, not a discussion.
221
+ - **## Requirements**: Bullet list from ticket, research, or developer input.
222
+ - **## 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.
223
+ - **## 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).
224
+ - **## Decisions**: `###` per decision. Complex: Ambiguity → Explored (Option A/B with `file:line` + pro/con) → Decision. Simple: just state decision with evidence.
225
+ - **## Architecture**: `###` per file with NEW/MODIFY label. Empty code fences in skeleton (filled in Step 7d). NEW files get full implementation. MODIFY files get only modified/added code — no "Current" block.
226
+ - **## Desired End State**: Usage examples showing the feature in use from a consumer's perspective — concrete code, not prose.
227
+ - **## File Map**: `path/to/file.ext # NEW/MODIFY — purpose` per line.
228
+ - **## Ordering Constraints**: What must come before what. What can run in parallel.
229
+ - **## 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.
230
+ - **## Performance Considerations**: Any performance implications or optimizations.
231
+ - **## Migration Notes**: If applicable — existing data, schema changes, rollback strategy, backwards compatibility. Empty if not applicable.
232
+ - **## Pattern References**: `path/to/similar.ext:line-range` — what pattern to follow and why.
233
+ - **## Developer Context**: Record questions exactly as asked during checkpoint, including `file:line` evidence. For iterative variant: also record micro-checkpoint interactions from Step 7c.
234
+ - **## Design History**: Slice approval/revision log. `- Slice N: [name] — pending/approved as generated/revised: [what changed]`. plan ignores this section.
235
+ - **## References**: Research artifacts, tickets, similar implementations.
236
+
237
+ **Architecture format in skeleton**:
238
+ - **NEW files**: heading + empty code fence (filled with full implementation in Step 7d)
239
+ - **MODIFY files**: heading with `file:line-range` + empty code fence (filled with only the modified code in Step 7d — no "Current" block, the original is on disk)
240
+
241
+ ## Step 7: Generate Slices (Iterative)
242
+
243
+ Generate code one slice at a time. Each slice sees the fixed code from all previous slices.
244
+
245
+ **For each slice in the decomposition (sequential order):**
246
+
247
+ ### 7a. Generate slice code (internal)
248
+
249
+ Generate complete, copy-pasteable code for every file in this slice — but **hold it for the artifact, do NOT present full code to the developer**. The developer sees a condensed review in 7c; the full code goes into the artifact in 7d.
250
+
251
+ - **New files**: complete code — imports, types, implementation, exports. Follow the pattern template from Step 2.
252
+ - **Modified files**: read current file FULLY, generate only the modified/added code scoped to changed sections (no full "Current" block — the original is on disk)
253
+ - **Test files**: complete test suites following project patterns
254
+ - **Wiring**: show where new code hooks into existing code
255
+
256
+ If additional context is needed, spawn a targeted **codebase-analyzer** agent.
257
+
258
+ No pseudocode, no TODOs, no placeholders — the code must be copy-pasteable by implement.
259
+
260
+ **Context grounding** (after slice 2): Before generating, re-read the artifact's Architecture section for files this slice touches. The artifact is the source of truth — generate code that extends what's already there, not what you remember from conversation.
261
+
262
+ ### 7b. Self-verify slice
263
+
264
+ Before presenting to the developer, cross-check this slice and produce a structured summary:
265
+
266
+ ```
267
+ Self-verify Slice N:
268
+ - Decisions: [OK / VIOLATION: decision X — fix applied]
269
+ - Cross-slice: [OK / CONFLICT: file X has inconsistent types — fix applied]
270
+ - Research: [OK / WARNING: constraint Y not satisfied — fix applied]
271
+ ```
272
+
273
+ If violations found: fix in-place before presenting. Include the self-verify summary in the 7c checkpoint presentation.
274
+
275
+ ### 7c. Developer micro-checkpoint
276
+
277
+ Present a **condensed review** of the slice — NOT the full generated code. The developer reviews the design shape, not every line. For each file in the slice, show:
278
+
279
+ 1. **Summary** (1-2 sentences): what changed, what pattern used, what it connects to
280
+ 2. **Signatures**: type/interface definitions, exported function signatures with parameter and return types
281
+ 3. **Key code blocks**: factory calls, wiring, non-obvious logic — the interesting parts that show the design decision in action
282
+
283
+ **Omit**: boilerplate, import lists, full function bodies, obvious implementations.
284
+ **MODIFY files**: focused diff (`- old` / `+ new`) with ~3 lines context. **Test files**: test case names only.
285
+
286
+ **If the developer asks to see full code**, show it inline — exception, not default.
287
+
288
+ Use the `ask_user_question` tool to confirm. Question: "Slice [N/M]: [slice name] — [files affected]. [1-line summary]. Approve?". Header: "Slice [N]". Options: "Approve (Recommended)" (Lock this slice, write to artifact, proceed to slice [N+1]); "Revise this slice" (Adjust code before proceeding — describe what to change); "Rethink remaining slices" (This slice reveals a design issue — revisit decomposition).
289
+
290
+ **Checkpoint cadence**: Slices 1-2: always individual. Slices 3+: individual if (a) mid-generation agent spawn was needed, (b) MODIFY touches an undiscussed file, or (c) self-verify fixed a violation.
291
+ Otherwise batch 2-3 slices (max 3).
292
+
293
+ ### 7d. Incorporate feedback
294
+
295
+ **Approve**: Lock this slice's code and **Edit the artifact immediately**:
296
+ 1. For each file in this slice, Edit the skeleton artifact to replace the empty code fence under that file's Architecture heading with the full generated code from 7a
297
+ 2. If a later slice contributes to a file already filled by an earlier slice: **rewrite the entire code fence** with the merged result (do not append alongside existing code)
298
+ 3. After merge, verify: no duplicate function definitions, imports deduplicated, exports list complete
299
+ 4. Update the Design History section: `- Slice N: [name] — approved as generated`
300
+ - Proceed to next slice
301
+
302
+ **Revise**: Update code per developer feedback. Re-run self-verify (7b). Re-present the same slice (7c). The artifact is NOT touched — only "Approve" writes to the artifact.
303
+
304
+ **Rethink**: Developer spotted a design issue. If a previously approved slice is affected, flag the conflict and offer cascade revision — developer decides whether to reopen (if yes, Edit artifact entry).
305
+ Update decomposition (add/remove/reorder remaining slices) and confirm before continuing.
306
+
307
+ ## Step 8: Integration Verification
308
+
309
+ After all slices are complete, review cross-slice consistency:
310
+
311
+ 1. **Present integration summary** (under 15 lines):
312
+ ```
313
+ Integration: [feature name] — [N] slices complete
314
+
315
+ Slices: [brief list of slice names and file counts]
316
+ Cross-slice: [types consistent / imports valid / wiring complete]
317
+ Research constraints: [all satisfied / N violations noted]
318
+ ```
319
+
320
+ 2. **Verify research constraints**: Check each Precedent & Lesson and Verification Note from the research artifact against the generated code. List satisfaction status.
321
+
322
+ 3. **Confirm using the `ask_user_question` tool**. Question: "[N] slices complete, [M] files total. Cross-slice consistency verified. Proceed to design artifact?". Header: "Verify". Options: "Proceed (Recommended)" (Finalize the design artifact (verify completeness, update status)); "Revisit slice" (Reopen a specific slice for revision — Edit the artifact after); "Add missing" (A file or integration point is missing — add to artifact).
323
+
324
+ ## Step 9: Finalize Design Artifact
325
+
326
+ The artifact was created as a skeleton in Step 6 and filled progressively in Step 7d. This step verifies completeness and finalizes.
327
+
328
+ 1. **Verify all Architecture entries are filled**: Every file heading from the decomposition must have a non-empty code block. If any are still empty (e.g., a slice was skipped), generate and fill them now.
329
+
330
+ 2. **Verify cross-slice file merges**: For files touched by multiple slices, confirm the Architecture entry contains the final merged code, not just the last slice's contribution.
331
+
332
+ 3. **Update frontmatter** via Edit:
333
+ - Set `status: complete`
334
+ - Update `last_updated` to current date
335
+ - Update `last_updated_by` to the User from the injected git context (fallback: "unknown")
336
+
337
+ 4. **Verify template completeness**: Ensure all 17 sections from the template reference in Step 6 are present and filled. Edit to fix any gaps.
338
+
339
+ 5. **Architecture format reminder**:
340
+ - **NEW files**: `### path/to/file.ext — NEW` + one-line purpose + full implementation code block
341
+ - **MODIFY files**: `### path/to/file.ext:line-range — MODIFY` + code block with only the modified/added code (no "Current" block — the original is on disk, implement reads it)
342
+
343
+ ## Step 10: Review & Iterate
344
+
345
+ 1. **Present the design artifact location**:
346
+ ```
347
+ Design artifact written to:
348
+ `thoughts/shared/designs/[filename].md`
349
+
350
+ [N] architectural decisions fixed, [M] new files designed, [K] existing files modified.
351
+ [S] slices generated, [R] revisions during generation.
352
+
353
+ Please review and let me know:
354
+ - Are the architectural decisions correct?
355
+ - Does the code match what you envision?
356
+ - Any missing integration points or edge cases?
357
+
358
+ When ready, run `/skill:plan thoughts/shared/designs/[filename].md` to sequence into phases.
359
+ ```
360
+
361
+ 2. **Handle follow-up changes**:
362
+ - Use the Edit tool to update the design artifact in-place
363
+ - Update frontmatter: `last_updated` and `last_updated_by`
364
+ - Add `last_updated_note: "Updated [brief description]"` to frontmatter
365
+ - If the change affects decisions, update both the Decisions section AND the Architecture code
366
+ - If new ambiguities arise, return to Step 5 (developer checkpoint)
367
+
368
+ ## Guidelines
369
+
370
+ 1. **Be Architectural**: Design shapes code; plans sequence work. Every decision must be grounded in `file:line` evidence from the actual codebase.
371
+
372
+ 2. **Be Interactive**: Don't produce the full design in one shot. Resolve ambiguities through the checkpoint first, get buy-in on the approach, THEN decompose and generate slice-by-slice.
373
+
374
+ 3. **Be Complete**: Code in the Architecture section must be copy-pasteable by implement. No pseudocode, no TODOs, no "implement here" placeholders. If you can't write complete code, an ambiguity wasn't resolved.
375
+
376
+ 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.
377
+
378
+ 5. **Resolve Everything**: No unresolved questions in the final artifact. If something is ambiguous, ask during the checkpoint or micro-checkpoint. The design must be complete enough that plan can mechanically decompose it into phases.
379
+
380
+ 6. **Present Condensed, Persist Complete**: Micro-checkpoints show the developer summaries, signatures, and key code blocks. The artifact always contains full copy-pasteable code. If the developer asks to see full code, show it — but never default to walls of code in checkpoints.
381
+
382
+ ## Agent Usage
383
+
384
+ | Context | Agents Spawned |
385
+ |---|---|
386
+ | Default (research artifact provided) | codebase-pattern-finder, codebase-analyzer, integration-scanner, precedent-locator |
387
+ | Novel work (new library/pattern) | + web-search-researcher |
388
+ | During code writing (if needed) | targeted codebase-analyzer for specific files |
389
+
390
+ Spawn multiple agents in parallel when they're searching for different things. 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.
391
+
392
+ ## Important Notes
393
+
394
+ - **Always chained**: This skill requires a research artifact produced by the research skill. There is no standalone design mode.
395
+ - **File reading**: Always read research artifacts and referenced files FULLY (no limit/offset) before spawning agents
396
+ - **Critical ordering**: Follow the numbered steps exactly
397
+ - ALWAYS read input files first (Step 1) before spawning agents (Step 2)
398
+ - ALWAYS wait for all agents to complete before identifying ambiguities (Step 3)
399
+ - ALWAYS resolve all ambiguities (Step 5) before decomposing into slices (Step 6)
400
+ - ALWAYS complete holistic decomposition before generating any slice code (Step 7)
401
+ - ALWAYS create the skeleton artifact immediately after decomposition approval (Step 6)
402
+ - NEVER leave Architecture code fences empty after their slice is approved — fill via Edit in Step 7d
403
+ - NEVER skip the developer checkpoint — developer input on architectural decisions is the highest-value signal in the design process
404
+ - NEVER edit source files — all code goes into the design document, not the codebase. This skill produces a document, not implementation. Source file editing is implement's job.
405
+ - **Code is source of truth** — if the Architecture code section conflicts with the Decisions prose, the code wins. Update the prose.
406
+ - **Checkpoint recordings**: Record micro-checkpoint interactions in Developer Context with `file:line` references, same as Step 5 questions.
407
+ - **Frontmatter consistency**: Always include frontmatter, use snake_case for multi-word fields, keep tags relevant
408
+ - CC auto-loads CLAUDE.md files when agents read files in a directory — no need to scan for them explicitly
409
+
410
+ ## Common Design Patterns
411
+
412
+ - **New Features**: types first → backend logic → API surface → UI last. Research existing patterns first. Include tests alongside each implementation.
413
+ - **Modifications**: Read current file FULLY. Show only the modified/added code scoped to changed sections. Check integration points for side effects.
414
+ - **Database Changes**: schema/migration → store/repository → business logic → API → client. Include rollback strategy.
415
+ - **Refactoring**: Document current behavior first. Plan incremental backwards-compatible changes. Verify existing behavior preserved.
416
+ - **Novel Work**: Include approach comparison in Decisions. Ground in codebase evidence OR web research. Get explicit developer sign-off BEFORE writing code.