Clean Architecture
A good architecture maximizes the number of decisions NOT made.
Clean Architecture is Robert C. Martin's prescriptive software design methodology built on one ironclad rule: all source-code dependencies must point inward, toward abstract business logic, never outward toward frameworks, databases, or UI. Martin organizes every system into four canonical concentric layers — Entities, Use Cases, Interface Adapters, and Frameworks & Drivers — and reinforces this structure with SOLID principles at the class level and cohesion/coupling principles at the component level. The result is a codebase where business logic can be fully tested without a running database, web server, or framework — and where technical choices become swappable implementation details.
“It's a Node.js order management service for e-commerce. Express route handlers call service files, and the service files import Sequelize ORM models…”
Make your business rules the center — frameworks, databases, and UI are just plugins
Clean Architecture structures every software system into four named concentric rings, each with explicit rules about what it may and may not depend on. Entities (innermost) hold enterprise-wide business rules and data structures — they are framework-agnostic and maximally stable. Use Cases hold application-specific orchestration logic that coordinates Entities to fulfill system behaviors. Interface Adapters (controllers, presenters, gateways) translate data between the formats used by Use Cases and the formats required by external tools. Frameworks & Drivers (outermost) contain databases, web frameworks, UI, and all volatile technical details. The Dependency Rule is the single governing constraint: source-code dependencies may only point inward; outer rings know about inner rings, never the reverse. This rule is mechanically enforced by the Dependency Inversion Principle (DIP) — one of the five SOLID principles that govern class-level design (SRP, OCP, LSP, ISP, DIP). At the component level, three cohesion principles (REP, CCP, CRP) define what belongs in a package; three coupling principles (ADP, SDP, SAP) govern stability and abstraction relationships between packages. Supporting heuristics include Screaming Architecture (folder structure should reveal the domain, not the framework), the Humble Object pattern (isolate testable logic from hard-to-test boundary code), and BIE decomposition (Boundary, Interactor, Entity).
Most codebases accumulate structural debt when business logic becomes entangled with frameworks, ORMs, and HTTP handlers — making core rules impossible to test in isolation, painful to migrate between technology stacks, and fragile when business requirements change. Developers lack a binary decision criterion for architecture choices: 'Is this dependency allowed here?' Clean Architecture gives them exactly that criterion — the Dependency Rule — plus named layers and named principles that make the answer unambiguous.
Apply the Dependency Rule and Clean Architecture's four-layer model to your system and you will know precisely where every class belongs, which dependencies are violations, and how to restructure your codebase so that business logic is fully tested without infrastructure and frameworks become swappable implementation details.
- A description of your system, service, or module — prose, pseudocode, or class names all work
- Import graphs, directory structures, or dependency lists you want analyzed for violations
- The feature or business capability you are designing or refactoring
- Specific pain points: tight coupling to frameworks, untestable business logic, unclear package boundaries
- A Dependency Rule Violation Report: every bad dependency named, layer boundary identified, and fix pattern recommended
- A Layer Assignment Map classifying each component into its correct Clean Architecture ring with justification
- A Use Case Interactor Interface: typed input-port (request model), output-port (response model), and entity dependencies ready to implement
- A sequenced Refactoring Roadmap with each step independently shippable and ordered by lowest risk, highest leverage
Watch the methodology work.
Three specimens from a single real session: the same situation, unaided and calibrated, the full transcript, and the skill answering live in the channel where the work happens.
“Your `orderService.js` imports Sequelize models at the top, runs SQL queries mid-function, and calculates discounts in the same method that writes to the database. Every unit test requires an active database connection or 200 lines of Sequelize mocks. A new engineer reads `src/routes/`, `src/services/`, `src/models/` and learns nothing about the business — only that you use Express and Sequelize. Switching to Prisma means touching every service file.”
“Your `DiscountPolicy.js` has no imports except pure domain types — it tests in under 100ms with no mocks and zero database setup. `SequelizeOrderRepository` is the only file that knows Sequelize exists; swapping it for Prisma means writing one new adapter class. Your `src/domain/` folder reads like a business requirements document: Order, InventoryItem, PlaceOrder, CalculateDiscount. The Dependency Rule Violation Report shows zero violations.”
The same skill, where the work happens.
No new app to learn. The methodology runs over the WhatsApp Business API, so the answer lands as a reply in the thread you’re already in — same rigour, zero context-switch.
What it does, specifically.
Each capability is a distinct move drawn straight from the source methodology — not a generic assistant guessing.
Dependency Rule Auditor
Analyzes import graphs, module relationships, or described dependency chains and flags every dependency that crosses a layer boundary in the wrong direction. Each violation is explained — which layer is importing which, why it violates the rule — and paired with a recommended fix pattern: Port interface, Adapter class, or Dependency Inversion.
Layer Assignment Classifier
Given any class, module, or service description, identifies which of the four concentric rings it belongs to — Entities, Use Cases, Interface Adapters, or Frameworks & Drivers — and explains the reasoning with reference to the component's responsibilities, volatility, and permissible dependencies.
Use Case Interactor Designer
Defines the complete interface for a Use Case Interactor: the input port (request model), output port (response model or presenter interface), and the Entity and Gateway dependencies the interactor requires. Produces typed interface definitions in the user's language of choice, ready to implement.
SOLID Principle Reviewer
Evaluates a class design, method signature, or module structure against each of the five SOLID principles, flagging violations with specific code-level evidence and recommending targeted refactors. Particular attention is paid to the Dependency Inversion Principle as the mechanical enforcement of the Dependency Rule.
Screaming Architecture Auditor
Assesses a project's directory structure or module naming to determine whether it reveals the domain — Orders, Inventory, Payments — or instead reveals the framework — Controllers, Models, Routes. Produces a restructuring recommendation that surfaces domain intent at the top level.
Refactoring Roadmap Builder
Given a legacy or tightly coupled codebase description, produces a sequenced, incremental plan to migrate toward Clean Architecture boundaries — starting with the lowest-risk, highest-leverage extractions and progressing to full layer separation without requiring a rewrite.
Graded before it shipped.
Every skill is scored against independent scenarios for methodology fidelity before it goes live — not vibes, a rubric.
Dependency Rule Violation Report
A structured list of every detected boundary violation, organized by layer pair (e.g., Use Case → Framework, Entity → Interface Adapter). Each entry names the violating class, identifies the bad dependency, explains which rule it breaks, and recommends a concrete fix: Port interface, Adapter extraction, or constructor injection.
Clean Architecture Layer Map
A classified inventory of your system's components organized into the four concentric rings, making visible which classes are stable Entities, which are Use Case orchestrators, which are translating Interface Adapters, and which are volatile infrastructure details. Serves as the canonical reference for architecture reviews and team onboarding.
Use Case Interactor Interface
A fully specified interface definition for a Use Case — input port (request model), output port (response model or presenter interface), Entity dependencies, gateway interfaces, and exception types — ready to be implemented in your language of choice with zero framework imports.
Refactoring Roadmap
A prioritized, step-by-step migration plan for moving a coupled codebase toward Clean Architecture, with each step scoped to be independently releasable. Includes the Dependency Rule justification for each move, which tests to write before each extraction, and which violations it eliminates.
Grounded in the original work.
Every answer traces back to a real source and the practitioner who wrote it — not a secondhand summary. Here is the source of record.
Robert C. Martin
Robert C. Martin (known universally as 'Uncle Bob') co-signed the Agile Manifesto in 2001, authored Clean Code (2008) and Clean Architecture (Prentice Hall, 2017) — two of the most widely read books in professional software engineering — and founded Clean Coders LLC. With over 50 years of software development experience spanning embedded systems, enterprise platforms, and distributed architectures, he developed the SOLID principles, introduced the concept of Screaming Architecture, and produced the Clean Coders video series: 30+ hours of methodology instruction with worked examples across multiple technology stacks.
Clean Architecture: A Craftsman's Guide to Software Structure and Design
Co-signer of the Agile Manifesto (2001); author of Clean Code and Clean Architecture (Prentice Hall); originator of SOLID principles; keynote speaker at NDC, GOTO, and YOW conferences; founder of Clean Coders LLC.
Be first to run it.
Clean Architecture is being built right now. Leave your email and we’ll tell you the moment it goes live.