Component Review (Detail Level)
Audit class- and method-level design of a scoped target. Report findings — never modify code.
Scope
In scope: SOLID (per class), cohesion inside a class, pattern correctness, interface segregation, method signatures, aggregate invariants, error model, testability seams, naming that leaks abstractions.
Out of scope: module boundaries, dependency cycles, layer violations (→ architecture-review), code formatting, style, line-level null checks.
Examples
# Review a PR's component design
/component-review pr 42
# Review a branch
/component-review branch feat/order-service
# Review a specific namespace/module
/component-review namespace src/Order
# Review current uncommitted changes
/component-review
Workflow
flowchart TD
A["Parse target mode"] --> B["Load project context"]
B --> C["Detect stack + idioms"]
C --> D["Research current patterns"]
D --> E["Run checks"]
E --> F["Report findings"]
Phase 1: Parse Target
From $ARGUMENTS:
pr <N> → gh pr diff <N>, gh pr view <N> --json headRefName,files, read files via git show <branch>:<file>
branch <name> → git diff main...<name>, read files from branch
namespace <path> → recursive read under <path>
- empty →
git diff HEAD for uncommitted changes
Phase 2: Load Project Context
Check in order, stop at first hit:
.agent-context/layer1-bootstrap.md, layer2-project-core.md
.agent-context/decisions.json → ADRs that constrain class design
docs/architecture/**/*.md
CLAUDE.md, AGENTS.md, CONTRIBUTING.md
- Manifest files for stack detection
Never block on missing context — infer from surrounding code.
Phase 3: Detect Stack & Idioms
- Language, framework, version from manifests
- Existing patterns in surrounding files — the review baseline is the codebase's own conventions, not abstract ideals
- Read nearby tests to understand the real contract
Phase 4: Research Current Best Practices
Use WebFetch or Context7 for version-sensitive rules:
- Framework DI and lifecycle (Symfony, Spring, NestJS)
- Language-specific idioms (Go error wrapping, Rust ownership, Vue Composition API, Java sealed types)
Don't apply generic OO dogma if the ecosystem has moved on.
Phase 5: Checks
Run each relevant check and record findings with file:line:
1. Single Responsibility (per class)
- Can you describe the class in one sentence without "and"?
- Are private methods clearly serving one public contract?
2. Open/Closed & Extensibility
- Are new variants added via new types, or by editing the same class?
- Flag
switch on type tags or string enums that will keep growing.
3. Liskov & Interface Segregation
- Do subclasses honor the parent contract (no surprise throws, no empty overrides)?
- Are interfaces narrow enough that callers only depend on what they use?
4. Dependency Inversion
- Are collaborators injected, or instantiated with
new?
- Are infrastructure concerns leaking into domain classes?
5. Pattern Correctness
- If a named pattern is used, is it used correctly? (Strategy without behavior variation = not a Strategy)
- Is there a simpler pattern or plain function that would do?
6. Cohesion Inside a Class
- Fields only used by some methods → hint of hidden class
- Temporal coupling (must call A before B) → signal for missing abstraction
7. Method Signatures
- Boolean flags that toggle behavior → two methods instead
- Primitive obsession → candidate for a value object
- Output parameters, tuple returns that should be a type
8. Aggregate / Invariant Integrity
- Can domain invariants be violated by calling methods in a legal order?
- Are mutations funneled through the aggregate root?
9. Error Model
- Exceptions vs. result types — consistent with the codebase?
- Are errors silently swallowed or generically re-thrown?
10. Testability Seams
- Can the class be tested without patching globals or network?
- Are seams (ports, factories) at sensible places?
11. Naming That Leaks
- Names that reveal the wrong abstraction (
OrderManager, UserUtil, DataHelper) → symptom of unclear responsibility
Phase 6: Report
Host-rendered findings (optional, in addition to the report below)
Some hosts render findings as a typed, clickable list (Claude Code: ReportFindings). Feature-detect it; if absent, skip silently and note host rendering: not available under Files reviewed.
Component findings qualify only when they name a file and line and a concrete failure scenario — an LSP violation that throws on a legal subtype, a mutable default that leaks state between calls. Pure design judgements (naming, cohesion, pattern fit) stay in the Markdown report. Never invent a failure scenario to make a design finding eligible. Emit once, most-severe first, after the checks are complete; do not repeat those entries as chat text.
Report
Output in the user's language:
## Component Review — <scope>
**Risk Level:** LOW | MEDIUM | HIGH | CRITICAL
**Detected stack:** <stack>
**Files reviewed:** <N>
## Critical (must fix)
- **<Title>** — `path/to/file.ext:line`
- Problem: <what is wrong>
- Principle: <SRP / LSP / DIP / …>
- Suggested direction: <high-level fix, not code>
## Warnings (should fix)
- ...
## Suggestions (nice to have)
- ...
## Patterns Observed
- <Pattern> — used correctly / misused / missing
## Suggested Next Steps
1. ...
2. ...
Rules
- Read-only. Never modify source files.
- Detail level only. If the findings are really about module boundaries, recommend
architecture-review.
- Evidence-based. Every finding needs a concrete
file:line reference.
- Respect local idioms. Match the codebase's existing style — don't import dogma from another ecosystem.
- Severity over volume. Fewer high-signal findings beat many nitpicks.
- Ignore style. Linters and formatters own formatting.
- Fallback, don't block. Missing context layers → infer from code.
1---2name: component-review3description: Review low-level component and class design — SOLID, cohesion, pattern correctness, interface design, method contracts, aggregate integrity, and domain-model health inside a PR, branch, namespace, or module. Make sure to use this skill whenever the user asks to review class design, check SOLID, audit a component, check if a pattern is used correctly, or says things like "component review", "class review", "prüfe das klassen design", "are these classes clean", "review the service", "solid check". Use this skill for DETAIL REVIEW only — module boundaries and dependency structure belong in `architecture-review`.4license: MIT5---67# Component Review (Detail Level)89Audit class- and method-level design of a scoped target. Report findings — never modify code.1011## Scope1213**In scope:** SOLID (per class), cohesion inside a class, pattern correctness, interface segregation, method signatures, aggregate invariants, error model, testability seams, naming that leaks abstractions.1415**Out of scope:** module boundaries, dependency cycles, layer violations (→ `architecture-review`), code formatting, style, line-level null checks.1617## Examples1819```bash20# Review a PR's component design21/component-review pr 422223# Review a branch24/component-review branch feat/order-service2526# Review a specific namespace/module27/component-review namespace src/Order2829# Review current uncommitted changes30/component-review31```3233## Workflow3435```mermaid36flowchart TD37 A["Parse target mode"] --> B["Load project context"]38 B --> C["Detect stack + idioms"]39 C --> D["Research current patterns"]40 D --> E["Run checks"]41 E --> F["Report findings"]42```4344## Phase 1: Parse Target4546From `$ARGUMENTS`:4748- `pr <N>` → `gh pr diff <N>`, `gh pr view <N> --json headRefName,files`, read files via `git show <branch>:<file>`49- `branch <name>` → `git diff main...<name>`, read files from branch50- `namespace <path>` → recursive read under `<path>`51- empty → `git diff HEAD` for uncommitted changes5253## Phase 2: Load Project Context5455Check in order, stop at first hit:56571. `.agent-context/layer1-bootstrap.md`, `layer2-project-core.md`582. `.agent-context/decisions.json` → ADRs that constrain class design593. `docs/architecture/**/*.md`604. `CLAUDE.md`, `AGENTS.md`, `CONTRIBUTING.md`615. Manifest files for stack detection6263Never block on missing context — infer from surrounding code.6465## Phase 3: Detect Stack & Idioms6667- Language, framework, version from manifests68- Existing patterns in surrounding files — the review baseline is the codebase's own conventions, not abstract ideals69- Read nearby tests to understand the real contract7071## Phase 4: Research Current Best Practices7273Use `WebFetch` or Context7 for version-sensitive rules:7475- Framework DI and lifecycle (Symfony, Spring, NestJS)76- Language-specific idioms (Go error wrapping, Rust ownership, Vue Composition API, Java sealed types)7778Don't apply generic OO dogma if the ecosystem has moved on.7980## Phase 5: Checks8182Run each relevant check and record findings with `file:line`:8384### 1. Single Responsibility (per class)8586- Can you describe the class in one sentence without "and"?87- Are private methods clearly serving one public contract?8889### 2. Open/Closed & Extensibility9091- Are new variants added via new types, or by editing the same class?92- Flag `switch` on type tags or string enums that will keep growing.9394### 3. Liskov & Interface Segregation9596- Do subclasses honor the parent contract (no surprise throws, no empty overrides)?97- Are interfaces narrow enough that callers only depend on what they use?9899### 4. Dependency Inversion100101- Are collaborators injected, or instantiated with `new`?102- Are infrastructure concerns leaking into domain classes?103104### 5. Pattern Correctness105106- If a named pattern is used, is it used correctly? (Strategy without behavior variation = not a Strategy)107- Is there a simpler pattern or plain function that would do?108109### 6. Cohesion Inside a Class110111- Fields only used by some methods → hint of hidden class112- Temporal coupling (must call A before B) → signal for missing abstraction113114### 7. Method Signatures115116- Boolean flags that toggle behavior → two methods instead117- Primitive obsession → candidate for a value object118- Output parameters, tuple returns that should be a type119120### 8. Aggregate / Invariant Integrity121122- Can domain invariants be violated by calling methods in a legal order?123- Are mutations funneled through the aggregate root?124125### 9. Error Model126127- Exceptions vs. result types — consistent with the codebase?128- Are errors silently swallowed or generically re-thrown?129130### 10. Testability Seams131132- Can the class be tested without patching globals or network?133- Are seams (ports, factories) at sensible places?134135### 11. Naming That Leaks136137- Names that reveal the wrong abstraction (`OrderManager`, `UserUtil`, `DataHelper`) → symptom of unclear responsibility138139## Phase 6: Report140141### Host-rendered findings (optional, in addition to the report below)142143Some hosts render findings as a typed, clickable list (Claude Code: `ReportFindings`). Feature-detect it; if absent, skip silently and note `host rendering: not available` under Files reviewed.144145Component findings qualify **only** when they name a file and line and a concrete failure scenario — an LSP violation that throws on a legal subtype, a mutable default that leaks state between calls. Pure design judgements (naming, cohesion, pattern fit) stay in the Markdown report. **Never invent a failure scenario to make a design finding eligible.** Emit once, most-severe first, after the checks are complete; do not repeat those entries as chat text.146147### Report148149Output in the user's language:150151```markdown152## Component Review — <scope>153154**Risk Level:** LOW | MEDIUM | HIGH | CRITICAL155156**Detected stack:** <stack>157158**Files reviewed:** <N>159160## Critical (must fix)161162- **<Title>** — `path/to/file.ext:line`163 - Problem: <what is wrong>164 - Principle: <SRP / LSP / DIP / …>165 - Suggested direction: <high-level fix, not code>166167## Warnings (should fix)168169- ...170171## Suggestions (nice to have)172173- ...174175## Patterns Observed176177- <Pattern> — used correctly / misused / missing178179## Suggested Next Steps1801811. ...1822. ...183```184185## Rules186187- **Read-only.** Never modify source files.188- **Detail level only.** If the findings are really about module boundaries, recommend `architecture-review`.189- **Evidence-based.** Every finding needs a concrete `file:line` reference.190- **Respect local idioms.** Match the codebase's existing style — don't import dogma from another ecosystem.191- **Severity over volume.** Fewer high-signal findings beat many nitpicks.192- **Ignore style.** Linters and formatters own formatting.193- **Fallback, don't block.** Missing context layers → infer from code.