/clean-architecture:clean-architecturefrom clean-architecture
Reviews code and provides design guidance based on Clean Architecture principles. Checks dependency rule, layer separation, boundary crossing, and SOLID principles. Useful for architecture review, dependency checks, or designing features with clean architecture.
Ships in clean-architecture. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This skill analyzes and reviews code based on Robert C. Martin's (Uncle Bob) Clean Architecture principles.
First, understand the project's directory structure:
When designing rather than reviewing, decide these before writing code:
Core Principle: Source code dependencies must only point inward (toward higher-level policies).
┌─────────────────────────────────────────────────────────┐
│ Frameworks & Drivers │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Interface Adapters │ │
│ │ ┌─────────────────────────────────────────┐ │ │
│ │ │ Use Cases │ │ │
│ │ │ ┌─────────────────────────────────┐ │ │ │
│ │ │ │ Entities │ │ │ │
│ │ │ └─────────────────────────────────┘ │ │ │
│ │ └─────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘
← Dependencies flow inward
Checklist:
The module that chooses concrete implementations (DI container, service locator, provide* factory, app entry point) depends on everything, so nothing inside may depend on it.
main) and pass them inward through constructors, parameters, or a context/provider// Bad: the view model reaches out to the container
class InventoryViewModel {
private repository = AppContainer.inventoryRepository();
}
// Good: the composition root decides and injects
class InventoryViewModel {
constructor(private repository: InventoryRepository) {}
}
const viewModel = new InventoryViewModel(createInventoryRepository(config));
The flow of control and source code dependency can point in opposite directions.
Controller → Use Case → Presenter
↓ ↓ ↑
[dependency] [dependency] [inverted!]
Example: When Use Case needs to call Presenter
// Use Case Layer (inner)
interface OrderOutputPort {
presentOrder(order: OrderData): void;
}
class CreateOrderUseCase {
constructor(private outputPort: OrderOutputPort) {}
execute() {
// ... business logic
this.outputPort.presentOrder(orderData);
}
}
// Adapter Layer (outer) - depends on Use Case
class OrderPresenter implements OrderOutputPort {
presentOrder(order: OrderData): void {
// Transform for UI
}
}
Principle: Data crossing boundaries should be simple data structures (DTOs).
// Bad: Passing Entity directly
class GetUserUseCase {
constructor(private userRepository: UserRepository) {}
execute(id: string): Promise<User> { // Returning Entity directly
return this.userRepository.findById(id);
}
}
// Good: Transform to DTO
class GetUserUseCase {
constructor(private userRepository: UserRepository) {}
async execute(id: string): Promise<UserResponseDTO> {
const user = await this.userRepository.findById(id);
return { id: user.id, name: user.name };
}
}
Checklist:
Checklist:
When an external authority decides a rule (quotas, eligibility, pricing, reward amounts, expiry), the client must not duplicate that rule in its domain. Duplicated rules drift: the authority changes the rule and the client shows stale numbers until the next release.
remainingToday, nextGrantAmount, expiresAt) instead of the raw inputs the client would need to compute itA pure function is not automatically a domain rule. "Show a warning when an item expires within 3 days" is a display decision; changing 3 to 2 alters no business outcome. Keep such thresholds, labels, and countdown formatting in presenters or view models, and promote them to the domain only when a business process (for example a notification job) needs the same rule.
Checklist:
Checklist:
Checklist:
A fake backend, in-memory store, or mock SDK is an outer-layer implementation of the same port.
Reset, seed, and time-travel operations used only in development or staging do not belong on the production port; otherwise every real implementation must implement them (ISP). Expose them as a separate optional capability that the composition root provides only in those environments.
When several screens or components show data from the same port, one owner (a provider, store, or cache in the adapter layer) holds the repository instance and its state, and the others subscribe to it.
Symptoms of missing ownership:
Centralize refresh triggers (focus, app resume, schedule boundaries, after mutations) in the owner and coalesce concurrent loads into one request. Keep timers that exist only for display, such as a ticking countdown, inside the component that displays them so the shared state does not re-render every subscriber.
If the real backend contract (API spec, GraphQL schema, SDK callback) does not exist yet, do not write a "real" adapter against an invented contract, and do not bypass generated types or hand-edit schemas to make it compile.
Object-oriented design principles used in Clean Architecture implementation. DIP is essential for Crossing Boundaries.
| Principle | Description | Clean Architecture Relevance |
|---|---|---|
| SRP | A class should have only one reason to change | Layer responsibility separation |
| OCP | Open for extension, closed for modification | Extension through interfaces |
| LSP | Subtypes must be substitutable for base types | Implementation replaceability |
| ISP | Don't depend on interfaces you don't use | Port interface segregation |
| DIP | Depend on abstractions, not concretions | Core of Crossing Boundaries |
Do not rely on folder names. List what each layer actually imports with the project's search tools, for example:
# Inner layers must not reference implementations, frameworks, or the composition root.
# Port interfaces such as `UserRepository` are expected in the domain, so search for
# implementation names and wiring instead of the word "Repository".
rg -n "Impl\b|Container|Module\.provide" src/domain
rg -n "Impl\b|AppContainer|Module\.provide" src/presentation src/ui
# Fakes must be referenced only by adapters and the composition root
rg -n "Fake|Mock" src --glob '!src/data/**' --glob '!src/di/**'
Adjust module names to the project's conventions, then read each hit: a match is a lead, not a verdict.
Report each violation with the file and line, the inner module, the outer module it reaches, and the boundary that fixes it.
Provide review results in this format:
# Clean Architecture Review Report
## Summary
- Overall Assessment: [Good/Needs Improvement/Critical]
- Key findings summary
## Dependency Rule Analysis
- List of violations
- Improvement suggestions
## Layer Structure Review
### Entities: [Good/Needs Improvement]
### Use Cases: [Good/Needs Improvement]
### Interface Adapters: [Good/Needs Improvement]
### Infrastructure: [Good/Needs Improvement]
## Recommendations
1. High priority improvements
2. Medium priority improvements
3. Long-term suggestions
Always consider these questions during review:
Ask yourself if you're really benefiting from Clean Architecture:
// Good: Dependency Inversion
interface UserRepository {
findById(id: string): Promise<User>;
}
class GetUserUseCase {
constructor(private userRepository: UserRepository) {}
}
// Bad: Depending on concrete implementation
class GetUserUseCase {
constructor(private userRepository: PostgresUserRepository) {}
}
A port does not need classes. A record of functions is a port, and the composition root builds it.
(* Domain: port as a record of functions *)
type inventory_repository = {
load : unit -> inventory Lwt.t;
reserve : request_id:string -> (reservation, failure) result Lwt.t;
}
(* Data: one adapter per backend, each returning the same record *)
let fake_inventory ~store = { load = ...; reserve = ... }
let http_inventory ~client = { load = ...; reserve = ... }
(* Composition root: the only place that chooses *)
let inventory = if config.use_fake then fake_inventory ~store else http_inventory ~client
# Good: Interface definition using Protocol
from typing import Protocol
class UserRepository(Protocol):
def find_by_id(self, id: str) -> User: ...
# Bad: Direct implementation import
from infrastructure.postgres import PostgresUserRepository
// Good: Interface segregation
interface UserRepository {
fun findById(id: String): User?
}
class GetUserUseCase(
private val userRepository: UserRepository
)
// Bad: Using concrete implementation
class GetUserUseCase(
private val userRepository: JpaUserRepository
)
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub nathankim0/clean-architecture-skills --plugin clean-architectureOther plugins' skills for the same job