Component Design (Detail Level)
Design the internals of one module: classes, interfaces, patterns, method contracts. Output a design doc plus optional diagrams when they earn their place.
Scope
In scope: class responsibilities, interfaces/abstract types, design patterns (Strategy, Factory, Adapter, …), aggregate roots and invariants, method signatures, collaboration, data-shape contracts, testability seams.
Out of scope: module/context boundaries (→ architecture-design), feature requirements, infrastructure choices outside the module.
Examples
# Design a specific component
/component-design OrderService
# Design a new component from scratch
/component-design payment-retry handler
Workflow
flowchart TD
A["Locate target module"] --> B["Read existing code"]
B --> C["Detect stack + idioms"]
C --> D["Research framework patterns"]
D --> E["Clarify contract with user"]
E --> F["Propose 2-3 designs"]
F --> G["User picks design"]
G --> H["Write design doc"]
H --> I["Summarize"]
Phase 1: Locate the Target
From $ARGUMENTS, find the module via Glob / Grep. If nothing matches, ask the user to confirm path/name.
Always read at minimum:
- The target module's current files (or parent directory if new)
- Nearby sibling modules for convention parity
- Existing tests — they reveal the real contract
Phase 2: Detect Stack & Idioms
- Language, framework, version
- Framework-native building blocks (Symfony services, Nuxt composables, Go packages, Spring beans, NestJS providers)
- DI container style, preferred error handling, validation approach
- Existing patterns in the codebase — match them unless there is a reason not to
Phase 3: Research Current Best Practices
Use WebFetch or Context7 for version-specific guidance. Examples of what NOT to guess:
- Symfony autowiring and attribute-based config
- Vue 3 Composition API +
<script setup> patterns
- Go generics and error wrapping idioms
- Java records, sealed interfaces, pattern matching
Phase 4: Clarify Contract
Ask one focused question at a time when genuinely ambiguous:
- What are the inputs and outputs?
- What are the invariants (things that must always hold)?
- What errors can occur, and how should callers learn about them?
- What side effects exist (DB writes, events, external calls)?
- What needs to be mockable for tests?
Skip questions you can answer from code.
Phase 5: Propose 2-3 Designs
Each proposal contains:
- Shape: classes/interfaces/functions + their responsibilities (one sentence each)
- Collaboration: who calls whom (Mermaid sequence or class diagram, only if it clarifies)
- Pattern: named pattern if applicable (Strategy, Template Method, Adapter, Ports & Adapters, …)
- Trade-offs: testability, extensibility, complexity cost
- Effort: rough gut feel, not estimates
End with Recommendation and reason.
Typical axes to vary:
- Rich domain model vs. anemic + service
- Inheritance vs. composition / Strategy
- Single aggregate vs. split aggregates
- Sync vs. async (events) for side effects
- One large service vs. small focused services
Phase 6: Produce the Design Doc
Write to docs/architecture/components/<module>-design.md only when the design is non-trivial (≥3 classes, or a pattern worth recording). Skip the file for tiny designs and answer inline.
Template:
# Component Design: <Name>
**Module:** `<namespace/path>`
**Date:** YYYY-MM-DD
**Related ADR:** <id or none>
## Purpose
<1-2 sentences: what this component is responsible for>
## Public API
```<lang>
// signatures of what callers use
```
## Internal Structure
- **<Class>** — <responsibility>
- **<Interface>** — <purpose, implementations>
## Collaboration
<mermaid diagram OR short prose — only if it clarifies>
## Invariants
- <Rule that must always hold>
## Error Model
- <Error type> → <how callers handle>
## Testability Seams
- <What is mocked/faked and why>
## Alternatives Considered
- <Alt> — rejected because …
Phase 7: Summary
Report in the user's language:
- Chosen shape in one sentence
- Where the doc lives (if written)
- Suggested next step (usually: implement + TDD, or run
component-review after implementation)
Rules
- Detail level only. If the request is really about module boundaries, redirect to
architecture-design.
- Match existing idioms. Don't introduce a new pattern if the codebase already has one that fits.
- Never modify source code. Write only to
docs/architecture/components/.
- Research, don't guess. Fetch current framework docs when the version matters.
- YAGNI. Don't design for hypothetical future extensions. One concrete use case is enough.
- Diagrams optional. Only include one if a sentence wouldn't be clearer.
1---2name: component-design3description: Design low-level component and class structure — classes, interfaces, design patterns, method signatures, aggregates, service contracts, and collaboration within a single module or bounded context. Make sure to use this skill whenever the user asks to design classes, pick a design pattern, define interfaces, model an aggregate, shape a service, or says things like "wie strukturiere ich die klassen", "welches pattern passt", "component design", "class design", "design the service", "model the aggregate". Use this skill for DETAIL DESIGN inside a known module — system-level structure belongs in `architecture-design`.4license: MIT5---67# Component Design (Detail Level)89Design the internals of one module: classes, interfaces, patterns, method contracts. Output a design doc plus optional diagrams when they earn their place.1011## Scope1213**In scope:** class responsibilities, interfaces/abstract types, design patterns (Strategy, Factory, Adapter, …), aggregate roots and invariants, method signatures, collaboration, data-shape contracts, testability seams.1415**Out of scope:** module/context boundaries (→ `architecture-design`), feature requirements, infrastructure choices outside the module.1617## Examples1819```bash20# Design a specific component21/component-design OrderService2223# Design a new component from scratch24/component-design payment-retry handler25```2627## Workflow2829```mermaid30flowchart TD31 A["Locate target module"] --> B["Read existing code"]32 B --> C["Detect stack + idioms"]33 C --> D["Research framework patterns"]34 D --> E["Clarify contract with user"]35 E --> F["Propose 2-3 designs"]36 F --> G["User picks design"]37 G --> H["Write design doc"]38 H --> I["Summarize"]39```4041## Phase 1: Locate the Target4243From `$ARGUMENTS`, find the module via `Glob` / `Grep`. If nothing matches, ask the user to confirm path/name.4445Always read **at minimum**:4647- The target module's current files (or parent directory if new)48- Nearby sibling modules for convention parity49- Existing tests — they reveal the real contract5051## Phase 2: Detect Stack & Idioms5253- Language, framework, version54- Framework-native building blocks (Symfony services, Nuxt composables, Go packages, Spring beans, NestJS providers)55- DI container style, preferred error handling, validation approach56- Existing patterns in the codebase — match them unless there is a reason not to5758## Phase 3: Research Current Best Practices5960Use `WebFetch` or Context7 for version-specific guidance. Examples of what NOT to guess:6162- Symfony autowiring and attribute-based config63- Vue 3 Composition API + `<script setup>` patterns64- Go generics and error wrapping idioms65- Java records, sealed interfaces, pattern matching6667## Phase 4: Clarify Contract6869Ask one focused question at a time when genuinely ambiguous:7071- What are the **inputs and outputs**?72- What are the **invariants** (things that must always hold)?73- What **errors** can occur, and how should callers learn about them?74- What **side effects** exist (DB writes, events, external calls)?75- What **needs to be mockable** for tests?7677Skip questions you can answer from code.7879## Phase 5: Propose 2-3 Designs8081Each proposal contains:8283- **Shape:** classes/interfaces/functions + their responsibilities (one sentence each)84- **Collaboration:** who calls whom (Mermaid sequence or class diagram, only if it clarifies)85- **Pattern:** named pattern if applicable (Strategy, Template Method, Adapter, Ports & Adapters, …)86- **Trade-offs:** testability, extensibility, complexity cost87- **Effort:** rough gut feel, not estimates8889End with **Recommendation** and reason.9091Typical axes to vary:9293- Rich domain model vs. anemic + service94- Inheritance vs. composition / Strategy95- Single aggregate vs. split aggregates96- Sync vs. async (events) for side effects97- One large service vs. small focused services9899## Phase 6: Produce the Design Doc100101Write to `docs/architecture/components/<module>-design.md` **only when** the design is non-trivial (≥3 classes, or a pattern worth recording). Skip the file for tiny designs and answer inline.102103Template:104105````markdown106# Component Design: <Name>107108**Module:** `<namespace/path>`109110**Date:** YYYY-MM-DD111112**Related ADR:** <id or none>113114## Purpose115116<1-2 sentences: what this component is responsible for>117118## Public API119120```<lang>121// signatures of what callers use122```123124## Internal Structure125126- **<Class>** — <responsibility>127- **<Interface>** — <purpose, implementations>128129## Collaboration130131<mermaid diagram OR short prose — only if it clarifies>132133## Invariants134135- <Rule that must always hold>136137## Error Model138139- <Error type> → <how callers handle>140141## Testability Seams142143- <What is mocked/faked and why>144145## Alternatives Considered146147- <Alt> — rejected because …148````149150## Phase 7: Summary151152Report in the user's language:153154- Chosen shape in one sentence155- Where the doc lives (if written)156- Suggested next step (usually: implement + TDD, or run `component-review` after implementation)157158## Rules159160- **Detail level only.** If the request is really about module boundaries, redirect to `architecture-design`.161- **Match existing idioms.** Don't introduce a new pattern if the codebase already has one that fits.162- **Never modify source code.** Write only to `docs/architecture/components/`.163- **Research, don't guess.** Fetch current framework docs when the version matters.164- **YAGNI.** Don't design for hypothetical future extensions. One concrete use case is enough.165- **Diagrams optional.** Only include one if a sentence wouldn't be clearer.