<< All versions

Skill v1.0.0

currentAutomated scan100/100
danielpohlmann/ia-marktplace/dev-craftsmanship-clean-architecture
──Details
PublishedOctober 25, 2026 at 04:19 AM
Content Hashsha256:09c8be3de946106a...
Git SHA9f1dda3738fd
──Files
Files (1 file, 4.5 KB)
SKILL.md4.5 KBactive
SKILL.md · 97 lines · 4.5 KB

version: "1.0.0" name: dev-craftsmanship-clean-architecture description: Use when designing or checking layer boundaries and dependency direction (Robert C. Martin's Clean Architecture). USE FOR: the Dependency Rule, entities/use cases/adapters/frameworks layers, humble objects, screaming architecture, keeping domain free of infrastructure. DO NOT USE FOR: readability (use dev-craftsmanship-clean-code), ports/adapters (use dev-architecture-hexagonal), SOLID (use dev-craftsmanship-solid).


Clean Architecture

Overview

Clean Architecture: A Craftsman's Guide to Software Structure and Design by Robert C. Martin presents a set of principles for organizing software so that it is testable, independent of frameworks, independent of the UI, independent of the database, and independent of any external agency.

The central idea: The Dependency Rule — source code dependencies must point only inward, toward higher-level policies.

Screaming Architecture

"A good architecture screams the intent of the system."

When you look at the top-level directory structure, it should tell you what the system does, not what framework it uses.

# Bad — screams "Rails" or "Express"
src/
controllers/
models/
views/
routes/
middleware/
# Good — screams "Health Clinic"
src/
patients/
appointments/
prescriptions/
billing/
shared/

Each top-level folder represents a use case area or a bounded context, not a technical layer.

Clean Architecture vs. Related Patterns

PatternRelationship
Hexagonal Architecture (Ports & Adapters)Clean Architecture is a generalization. Ports are the interfaces in the Use Case layer; Adapters are the implementations in the outer layer.
Onion ArchitectureNearly identical in structure. Clean Architecture adds the concept of Screaming Architecture and the Humble Object.
Domain-Driven Design (DDD)Clean Architecture's Entities map to DDD's Domain Model. Bounded Contexts often align with top-level Clean Architecture modules.
SOLID PrinciplesClean Architecture is the architectural expression of SOLID, especially the Dependency Inversion Principle.

Typical Project Structure

src/
domain/ # Entities — enterprise business rules
entities/
value-objects/
domain-events/
application/ # Use Cases — application business rules
use-cases/
ports/ # Interfaces for outbound dependencies
dto/ # Request/Response data structures
adapters/ # Interface Adapters
controllers/ # Inbound (driving) adapters
gateways/ # Outbound (driven) adapters
presenters/
mappers/
infrastructure/ # Frameworks & Drivers
database/
web/
messaging/
config/

Best Practices

  • Enforce the Dependency Rule with linter rules or architectural tests (e.g., ArchUnit, dependency-cruiser).
  • Defer framework decisions as long as possible. The architecture should work without Express, React, or PostgreSQL.
  • Keep Use Cases as pure orchestrators — they call Entities and Ports but contain minimal logic themselves.
  • Use the Humble Object pattern at every boundary to maximize testable code.
  • Name modules after business capabilities, not technical layers — let the architecture scream.
  • Test inner layers with unit tests (fast, no I/O). Test boundaries with integration tests. Test the outermost layer with end-to-end tests sparingly.
  • When in doubt about which layer something belongs to, ask: "If I change the database / framework / UI, does this need to change?" If yes, it belongs in an outer layer.

Detailed reference

Load only the file that matches the task — each is self-contained.

FileContents
references/the-four-layers.mdThe Four Layers — 1. Entities (Enterprise Business Rules), 2. Use Cases (Application Business Rules), 3. Interface Adapters (Controllers, Gateways, Presenters), 4. Frameworks & Drivers
references/details.mdThe Concentric Circles; The Dependency Rule; Crossing Boundaries; The Humble Object Pattern; Boundaries

References

See references/rules.md for the full rule catalog.

All versions