← ClaudeAtlas

clean-architecturelisted

ALWAYS-ON architecture standard. Every time code is PLANNED or WRITTEN (any language, you or a subagent) you MUST apply Clean Architecture: dependencies point inward only, business rules never import frameworks/IO, and every external concern sits behind a port (interface) implemented by an adapter at the edge. Use whenever planning a feature, designing modules/services/layers, starting a new app, adding a use case, deciding where a file goes, wiring a database/HTTP/queue, or whenever the user says "architecture", "layers", "use case", "port", "adapter", "domain", "where should this live", or "how should this be structured".
dustin-olenslager/claude-phalanx · ★ 1 · AI & Automation · score 77
Install: claude install-skill dustin-olenslager/claude-phalanx
# Clean Architecture — the structural standard Always-on at **plan time** (decide boundaries) and **write time** (place code, point deps inward). Enforced at edit-time by `effect-ca-gate.js` and **mechanically at verify** by `arch-enforce` (dependency-cruiser / import-linter / ArchUnit). Off: "stop clean-arch" → `touch <CLAUDE_DIR>/.ts-arch-off`. ## The one rule (ELI5) Circles inside circles. Inside = business rules; outside = db, web, UI, clock — replaceable details. **Source dependencies point INWARD only.** Inside knows nothing about outside → swap Postgres for SQLite, REST for gRPC, without touching a rule. ## Four layers (inner → outer) 1. **Entities/Domain** — pure types, invariants, value objects, domain errors. Zero framework/IO/other-layer imports. 2. **Use Cases/Application** — orchestrate entities for one user intent; depend on **ports** they declare, never concrete IO. (TS: an `Effect` over port tags.) 3. **Interface Adapters** — controllers, presenters, gateways, repositories; implement the ports; translate to/from the outside. 4. **Frameworks & Drivers** — db, web server, ORM, SDKs, fs, env, main(). The replaceable edge; the composition root lives here. **Dependency Rule:** layer N references inward only. Inner naming outer = the #1 violation — invert it. ## Dependency Inversion Use case *owns* the interface; adapter *implements* it. Data crosses boundaries as a domain type/DTO the inner layer defines — never a framework object (no ORM entity, n