install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/pproenca/dot-skills/clean-architecture" ~/.claude/skills/comeonoliver-skillshub-clean-architecture && rm -rf "$T"
manifest:
skills/pproenca/dot-skills/clean-architecture/SKILL.mdsource content
Clean Architecture Best Practices
Comprehensive guide to Clean Architecture principles for designing maintainable, testable software systems. Based on Robert C. Martin's "Clean Architecture: A Craftsman's Guide to Software Structure and Design." Contains 42 rules across 8 categories, prioritized by architectural impact.
When to Apply
Reference these guidelines when:
- Designing new software systems or modules
- Structuring dependencies between layers
- Defining boundaries between business logic and infrastructure
- Reviewing code for architectural violations
- Refactoring coupled systems toward cleaner structure
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Dependency Direction | CRITICAL | |
| 2 | Entity Design | CRITICAL | |
| 3 | Use Case Isolation | HIGH | |
| 4 | Component Cohesion | HIGH | |
| 5 | Boundary Definition | MEDIUM-HIGH | |
| 6 | Interface Adapters | MEDIUM | |
| 7 | Framework Isolation | MEDIUM | |
| 8 | Testing Architecture | LOW-MEDIUM | |
Quick Reference
1. Dependency Direction (CRITICAL)
- Source dependencies point inward onlydep-inward-only
- Interfaces belong to clients not implementersdep-interface-ownership
- Avoid framework imports in inner layersdep-no-framework-imports
- Use simple data structures across boundariesdep-data-crossing-boundaries
- Eliminate cyclic dependencies between componentsdep-acyclic-dependencies
- Depend on stable abstractions not volatile concretionsdep-stable-abstractions
2. Entity Design (CRITICAL)
- Entities contain only enterprise business rulesentity-pure-business-rules
- Entities must not know how they are persistedentity-no-persistence-awareness
- Encapsulate business invariants within entitiesentity-encapsulate-invariants
- Use value objects for domain conceptsentity-value-objects
- Build rich domain models not anemic data structuresentity-rich-not-anemic
3. Use Case Isolation (HIGH)
- Each use case has one reason to changeusecase-single-responsibility
- Define input and output ports for use casesusecase-input-output-ports
- Use cases orchestrate entities not implement business rulesusecase-orchestrates-not-implements
- Use cases must not contain presentation logicusecase-no-presentation-logic
- Declare all dependencies explicitly in constructorusecase-explicit-dependencies
- Use case defines the transaction boundaryusecase-transaction-boundary
4. Component Cohesion (HIGH)
- Structure should scream the domain not the frameworkcomp-screaming-architecture
- Group classes that change togethercomp-common-closure
- Avoid forcing clients to depend on unused codecomp-common-reuse
- Release components as cohesive unitscomp-reuse-release-equivalence
- Depend in the direction of stabilitycomp-stable-dependencies
5. Boundary Definition (MEDIUM-HIGH)
- Use humble objects at architectural boundariesbound-humble-object
- Use partial boundaries when full separation is prematurebound-partial-boundaries
- Weigh boundary cost against ignorance costbound-boundary-cost-awareness
- Treat main as a plugin to the applicationbound-main-component
- Defer framework and database decisionsbound-defer-decisions
- Services must have internal clean architecturebound-service-internal-architecture
6. Interface Adapters (MEDIUM)
- Keep controllers thinadapt-controller-thin
- Presenters format data for the viewadapt-presenter-formats
- Gateways hide external system detailsadapt-gateway-abstraction
- Use mappers to translate between layersadapt-mapper-translation
- Build anti-corruption layers for external systemsadapt-anti-corruption-layer
7. Framework Isolation (MEDIUM)
- Domain layer has zero framework dependenciesframe-domain-purity
- Keep ORM usage in infrastructure layerframe-orm-in-infrastructure
- Web framework concerns stay in interface layerframe-web-in-infrastructure
- Dependency injection containers live at the edgeframe-di-container-edge
- Abstract logging behind domain interfacesframe-logging-abstraction
8. Testing Architecture (LOW-MEDIUM)
- Tests are part of the system architecturetest-tests-are-architecture
- Design for testability from the starttest-testable-design
- Test each layer in isolationtest-layer-isolation
- Verify architectural boundaries with teststest-boundary-verification
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
Reference Files
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |