Design

From juicesharp/rpiv-pi · View interactive version

Design is an AI agent skill from the GitHub repository juicesharp/rpiv-pi. 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 f

How to use this skill

Skill file

Design

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.

How it works:

The final artifact is plan-compatible.

Step 1: Input Handling

When this command is invoked:

  1. Read research artifact:

Research artifact provided (argument contains a path to a .md file in thoughts/):

No arguments provided:

```

I'll design a feature iteratively from a research artifact. Please provide:

/skill:design [research artifact] [discover] [task description]

Research artifact is required. Discover and task description are optional, in any order.

```

Then wait for input.

  1. Read any additional files mentioned — tickets, related designs, existing implementations. Read them FULLY before proceeding.

Step 2: Targeted Research

This is NOT a discovery sweep. Focus on DEPTH (how things work, what patterns to follow) not BREADTH (where things are).

  1. Spawn parallel research agents using the Agent tool:

Novel work (new libraries, first-time patterns, no existing codebase precedent):

Agent prompts should focus on:

NOT: "Find all files related to X" — that's discovery's job, upstream of this skill.

  1. Read all key files identified by agents into the main context — especially the pattern templates you'll model after.
  1. Wait for ALL agents to complete before proceeding.
  1. Analyze and verify understanding:

Step 3: Identify Ambiguities — Dimension Sweep

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.

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.

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).

Step 4: Holistic Self-Critique

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.

Prompt yourself:

Areas to consider (suggestive, not a checklist):

Remediation:

Step 5: Developer Checkpoint

Use the grounded-questions-one-at-a-time pattern. Use a ❓ Question: prefix so the developer knows their input is needed. Each question must:

Question patterns by ambiguity type:

Critical rules:

Choosing question format:

> 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).

"❓ Question: Integration scanner found no background job registration for this area. Is that expected, or is there async processing I'm not seeing?"

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.

Classify each response:

Decision (e.g., "use pattern A", "yes, follow that approach"):

Correction (e.g., "no, there's a third option you missed", "check the events module"):

Scope adjustment (e.g., "skip the UI, backend only", "include tests"):

After all ambiguities are resolved, present a brief design summary (under 15 lines):

Design: [feature name]
Approach: [1-2 sentence summary of chosen architecture]

Decisions:
- [Decision 1]: [choice] — modeled after `file:line`
- [Decision 2]: [choice]
- [Decision 3]: [choice]

Scope: [what's in] | Not building: [what's out]
Files: [N] new, [M] modified

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).

Step 6: Feature Decomposition

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.

  1. Decompose holistically — define ALL slices, dependencies, and ordering before generating any code:

```

Feature Breakdown: [feature name]

Slice 1: [name] — [what this slice delivers]

Files: path/to/file.ext (NEW), path/to/file.ext (MODIFY)

Depends on: nothing (foundation)

Slice 2: [name] — [what this slice delivers]

Files: path/to/file.ext (NEW), path/to/file.ext (MODIFY)

Depends on: Slice 1

Slice 3: [name] — [what this slice delivers]

Files: path/to/file.ext (NEW)

Depends on: Slice 2

```

  1. Slice properties:
  1. 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).
  1. Create skeleton artifact — immediately after decomposition is approved:

Artifact template sections (all required in skeleton):

Architecture format in skeleton:

Step 7: Generate Slices (Iterative)

Generate code one slice at a time. Each slice sees the fixed code from all previous slices.

For each slice in the decomposition (sequential order):

7a. Generate slice code (internal)

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.

If additional context is needed, spawn a targeted codebase-analyzer agent.

No pseudocode, no TODOs, no placeholders — the code must be copy-pasteable by implement.

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.

7b. Self-verify slice

Before presenting to the developer, cross-check this slice and produce a structured summary:

Self-verify Slice N:
- Decisions: [OK / VIOLATION: decision X — fix applied]
- Cross-slice: [OK / CONFLICT: file X has inconsistent types — fix applied]
- Research: [OK / WARNING: constraint Y not satisfied — fix applied]

If violations found: fix in-place before presenting. Include the self-verify summary in the 7c checkpoint presentation.

7c. Developer micro-checkpoint

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:

  1. Summary (1-2 sentences): what changed, what pattern used, what it connects to
  2. Signatures: type/interface definitions, exported function signatures with parameter and return types
  3. Key code blocks: factory calls, wiring, non-obvious logic — the interesting parts that show the design decision in action

Omit: boilerplate, import lists, full function bodies, obvious implementations.

MODIFY files: focused diff (- old / + new) with ~3 lines context. Test files: test case names only.

If the developer asks to see full code, show it inline — exception, not default.

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).

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.

Otherwise batch 2-3 slices (max 3).

7d. Incorporate feedback

Approve: Lock this slice's code and Edit the artifact immediately:

  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
  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)
  3. After merge, verify: no duplicate function definitions, imports deduplicated, exports list complete
  4. Update the Design History section: - Slice N: [name] — approved as generated

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.

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).

Update decomposition (add/remove/reorder remaining slices) and confirm before continuing.

Step 8: Integration Verification

After all slices are complete, review cross-slice consistency:

  1. Present integration summary (under 15 lines):

```

Integration: [feature name] — [N] slices complete

Slices: [brief list of slice names and file counts]

Cross-slice: [types consistent / imports valid / wiring complete]

Research constraints: [all satisfied / N violations noted]

```

  1. Verify research constraints: Check each Precedent & Lesson and Verification Note from the research artifact against the generated code. List satisfaction status.
  1. 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).

Step 9: Finalize Design Artifact

The artifact was created as a skeleton in Step 6 and filled progressively in Step 7d. This step verifies completeness and finalizes.

  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.
  1. 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.
  1. Update frontmatter via Edit:
  1. Verify template completeness: Ensure all 17 sections from the template reference in Step 6 are present and filled. Edit to fix any gaps.
  1. Architecture format reminder:

Step 10: Review & Iterate

  1. Present the design artifact location:

```

Design artifact written to:

thoughts/shared/designs/[filename].md

[N] architectural decisions fixed, [M] new files designed, [K] existing files modified.

[S] slices generated, [R] revisions during generation.

Please review and let me know:

When ready, run /skill:plan thoughts/shared/designs/[filename].md to sequence into phases.

```

  1. Handle follow-up changes:

Guidelines

  1. Be Architectural: Design shapes code; plans sequence work. Every decision must be grounded in file:line evidence from the actual codebase.
  1. 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.
  1. 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.
  1. 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.
  1. 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.
  1. 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.

Agent Usage

| Context | Agents Spawned |

|---|---|

| Default (research artifact provided) | codebase-pattern-finder, codebase-analyzer, integration-scanner, precedent-locator |

| Novel work (new library/pattern) | + web-search-researcher |

| During code writing (if needed) | targeted codebase-analyzer for specific files |

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.

Important Notes

Common Design Patterns

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.