Clean architecture — concentric layers (entities, use cases, interface adapters, frameworks), the dependency rule, boundaries and DTOs, module structure, enforcing dependencies with tooling, pragmatic adaptation. Use to structure or review layering and dependency direction (clean architecture, layers, dependency rule, boundaries).
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Clean Architecture?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/vectora-os-clean-architecture)
---
name: clean-architecture
description: Clean architecture — concentric layers (entities, use cases, interface adapters, frameworks), the dependency rule, boundaries and DTOs, module structure, enforcing dependencies with tooling, pragmatic adaptation. Use to structure or review layering and dependency direction (clean architecture, layers, dependency rule, boundaries).
metadata:
category: design-patterns
---
# Clean architecture
## Purpose
Make code depend inward on policy, not outward on details, so it stays changeable.
**Use when:** structuring new services or reviewing layering violations.
**Not for:** tiny scripts.
## Inputs
- Codebase or design.
## Outputs
- Layer map, dependency rules, violations list.
## Read first
- [Project Brain](../../../project-brain/README.md) — `npm run brain -- query "clean architecture"` for prior decisions, patterns and anti-patterns.
- [Architecture standard](../../../standards/architecture.md)
## Steps
1. **Layers.** Define layers and what belongs in each.
Done when each module maps to one layer.
2. **Rule.** Dependencies point inward only; enforce with a tool (e.g., dependency-cruiser, ArchUnit).
Done when the rule runs in CI.
3. **Boundaries.** Cross boundaries with simple data structures.
Done when no framework types cross inward.
4. **Review.** List violations with fixes.
Done when violations have owners.
## Best practices
- Automate the dependency rule.
- Be pragmatic: fewer layers for simple domains.
## Common mistakes
- Layering for its own sake.
- Use cases calling controllers.
## Example
Dependency-cruiser rule forbidding `domain/**` → `infrastructure/**`; 7 violations found and fixed.
## Reusable prompt
```text
Apply the Clean architecture skill (.agents/skills/clean-architecture/SKILL.md).
Context: {{task card or question; links to PRD, ADRs, code paths}}
Constraints: {{approved thresholds, deadlines, allowed files}}
Map the code to layers, define and automate the dependency rule, and list violations with fixes.
Return: Layer map, dependency rules, violations list..
Cite evidence (file:line, command output, source) for every claim; list open questions separately.
```