clean-architecture
Structure software around the Dependency Rule: source code dependencies point inward from frameworks to use cases to entities.
Skill by wondelai
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/sung1-labs-clean-architecture
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: design, frontend, backend, devops
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions: not checked yet.
What's inside
- Skill name
clean-architecture- Description
- Structure software around the Dependency Rule: source code dependencies point inward from frameworks to use cases to entities. Use when the user mentions "architecture layers", "dependency rule", "ports and adapters (hexagonal)", "onion architecture", "screaming architecture", "where should business logic go", "decouple from the database", "swap the framework without a rewrite", or "keep business rules independent". Also trigger when deciding which layer code belongs in, isolating core logic from infrastructure, defining module boundaries, or debating whether the framework should call your code or the reverse. Covers component principles, boundaries, and SOLID. For code-level quality, see clean-code. For domain modeling, see domain-driven-design.
- License
- MIT
- Metadata
- author: wondelai · version: 1.4.0
- Instructions
- 189 lines in SKILL.md · view on GitHub
Agent Skills spec issues
- name: "clean-architecture" does not match folder "sddx-ai-clean-architecture"
Files (7)
- SKILL.md
- adapters-frameworks.md · references/
- boundaries.md · references/
- component-principles.md · references/
- dependency-rule.md · references/
- entities-use-cases.md · references/
- solid-principles.md · references/
SKILL.md (first lines)
# Clean Architecture Framework
A disciplined approach to structuring software so that business rules remain independent of frameworks, databases, and delivery mechanisms. Apply these principles when designing system architecture, reviewing module boundaries, or advising on dependency management.
## Core Principle
**Source code dependencies must point inward — toward higher-level policies.** Nothing in an inner circle can know anything about an outer circle. This single rule produces systems that are testable and independent of frameworks, UI, database, and any external agency. Business rules are what matter; databases, web frameworks, and delivery mechanisms are details — when details depend on policies, you can defer decisions, swap implementations, and test business logic in isolation.
## Scoring
**Goal: 10/10.** Score one point for each of the seven Quick Diagnostic rows the architecture satisfies (0-7), then map to a 0-10 band: 6-7 satisfied = **9-10** (Dependency Rule holds, business logic is framework- and DB-independent); 4-5 = **6-8** (core is testable but some details leak inward); 2-3 = **3-5** (framework or persistence dictates structure); 0-1 = **0-2** (no boundaries — business rules live in controllers and ORM models). Report the score, the failed diagnostic rows, and the specific inversion needed to fix each.
### 1. Dependency Rule and Concentric Circles
**Core concept:** Organize the architecture as concentric circles — Entities (enterprise business rules) innermost, then Use Cases (application business rules), then Interface Adapters, with Frameworks and Drivers outermost. Source code dependencies always point inward.
**Why it works:** When high-level policies don't depend on low-level details, you can swap the database, web framework, or API style without touching business logic — the system becomes resilient to the most volatile parts of the stack.
**Key insights:**
- Inner circles cannot mention outer circle names — no classes, functions, variables, or data formats from outside
- Data crossing a boundary must be in the form most convenient for the inner circle, never dictated by the outer
- Dependency Inversion (interfaces defined inward, implemented outward) is the mechanism that enforces the rule
- The number of circles is not fixed — four is typical; the rule stays the same
- Frameworks are details, not architecture — they belong in the outermost circle
**Code applications:**
| Context | Pattern | Example |
|---------|---------|---------|
| **Layer direction** | Inner circles define interfaces; outer implement | `UserRepository` interface in Use Cases; `PostgresUserRepository` in Adapters |
| **Data crossing** | DTOs cross boundaries, not ORM entities | Use Case returns `UserResponse` DTO, not an ActiveRecord model |
| **Dependency direction** | Import arrows always point inward | Controller imports Use Case; Use Case never imports Controller |
See [references/dependency-rule.md](references/dependency-rule.md) when an inner-circle import points outward and you need the four-circle code walkthrough, the data-crossing rules, and the four-step dependency-inversion procedure to fix it.
### 2. Entities and Use Cases
**Core concept:** Entities encapsulate enterprise-wide business rules — rules that would exist even without software. Use Cases contain application-specific rules that orchestrate the flow of data to and from Entities.
**Why it works:** Separating what the business does (Entities) from how the application orchestrates it (Use Cases) lets you reuse Entities across applications and change application behavior without altering core business rules.
**Key insights:**
- Entities are not database rows — they are objects or pure functions encapsulating critical business rules
- Use Cases accept Request Models and return Response Models — never framework objects
- Each Use Case is a single application operation (`CreateOrder`, `ApproveExpense`)
- The Interactor pattern: a Use Case class implements an input boundary interface and calls an output boundary interface
- Changes to a Use Case should never affect an Entity; Entity changes may ripple to Use Cases
**Code applications:**
| Context | Pattern | Example |
|---------|---------|---------|
| **Entity design** | Critical business rules, zero framework dependencies | `Order.calculateTotal()` applies tax rules; knows nothing about HTTP |
| **Request/Response** | Simple data structures cross the boundary | `CreateOrderRequest { items, customerId }` — no ORM models |
| **Single responsibility** | One Use Case per operation | `PlaceOrder`, `CancelOrder`, `RefundOrder` as separate classes |
| **Interactor** | Implements Input Port, calls Output Port | `PlaceOrderInteractor implements PlaceOrderInput` |
See [references/entities-use-cases.md](references/entities-use-cases.md) when designing an Interactor or deciding what belongs in an Entity versus a Use Case — full Enterprise vs. Application Business Rules treatment with request/response model examples.
### 3. Interface Adapters and Frameworks
**Core concept:** Interface Adapters convert data between the form convenient for Use Cases/Entities and the form required by external agencies. Frameworks and Drivers are the outermost layer — glue code to the outside world.
**Why it works:** When the web framework, ORM, or message queue is confined to the outer circles, replacing any of them is a localized change. The database is a detail; the web is a detail; details should be plugins to your business rules, not the skeleton of the application.
**Key insights:**
- Controllers translate HTTP into Use Case input; Presenters translate Use Case output into view models
- Gateways implement repository interfaces defined by Use Cases — the inner circle defines the contract, the outer fulfills it
- Business rules never know whether data lives in SQL, NoSQL, or flat files, or that delivery is HTTP
- Treat frameworks with suspicion — they want you to couple to them; keep them at arm's length
**Code applications:**
| Context | Pattern | Example |
|---------|---------|---------|
| **Controller** | Delivery mechanism → Use Case input | `OrderController.create(req)` builds `CreateOrderRequest`, calls Interactor |
| **Presenter** | Use Case output → view model | `OrderPresenter.present(response)` formats for JSON/HTML |
| **Gateway** | Repository interface implemented per DB | `SqlOrderRepository implements OrderRepository` |
| **Framework boundary** | Framework calls inward, never the reverse | Express route handler calls Controller; Controller never imports Express |
See [references/adapters-frameworks.md](references/adapters-frameworks.md) when wiring controllers, presenters, or gateways, or arguing that the database/web is a detail — covers plugin architecture and how to confine a framework to the edges.
### 4. Component Principles
**Core concept:** Components are the units of deployment. Three cohesion principles govern what goes inside a component; three coupling principles govern relationships between components.
**Why it works:** Poorly composed components create ripple effects where one change forces redeployment of unrelated code; the principles keep changes localized and releases independent.
**Key insights:**
- REP (Reuse/Release Equivalence): classes in a component must be versionable and releasable as a unit
- CCP (Common Closure): classes that change for the same reason at the same time belong together — SRP for components
- CRP (Common Reuse): don't force users to depend on classes they don't use
- ADP (Acyclic Dependencies): the component graph must have no cycles — break them with DIP or a new component
- SDP (Stable Dependencies): depend in the direction of stability
- SAP (Stable Abstractions): stable components should be abstract; unstable ones concrete
**Code applications:**
| Context | Pattern | Example |
|---------|---------|---------|
| **Component grouping** | Group classes that change together (CCP) | All order-related Use Cases in one component |
| **Breaking cycles** | Apply DIP to invert a dependency edge | Extract an interface into a new component to break the cycle |
| **Stability metrics** | Instability I = Ce / (Ca + Ce) | Many incoming, no outgoing deps → I near 0 (stable) |
See [references/component-principles.md](references/component-principles.md) when grouping classes into deployable components or breaking a dependency cycle — each of REP, CCP, CRP, ADP, SDP, SAP worked through with the instability metric.
### 5. SOLID Principles
**Core concept:** Five class-and-module-level principles — Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, Dependency Inversion — the mid-level building blocks that make the Dependency Rule possible.
**Why it works:** Each principle addresses a specific way dependencies go wrong, preventing the rigidity, fragility, and immobility that turn codebases into legacy nightmares.
**Key insights:**
- SRP: a module has one reason to change — it serves one actor (not "does one thing")
- OCP: extend behavior by adding new code, not modifying existing code — strategy and plugin patterns
- LSP: subtypes must be usable through the base interface without the client knowing — violated by unexpected exceptions or ignored methods
- ISP: clients should not depend on methods they don't use — fat interfaces create needless coupling
- DIP: high-level modules and low-level modules both depend on abstractions defined by the high-level moduleFrom sung1-labs/sddx, MIT.
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Sep 6, 2026 (1 month ago)
From GitHub (fetched Oct 24, 2026).
Details
- Version
- 1.4.0
- License
- MIT
- Repository
- github.com/sung1-labs/sddx
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
- 0.618score
clean-architecture
wondelai
Structure software around the Dependency Rule: source code dependencies point inward from frameworks to use cases to entities.
SkillBFreshness: B★ 2.5KClaude Code +9 - 0.323score
clean-architecture
wondelai
Structure software around the Dependency Rule: source code dependencies point inward from frameworks to use cases to entities.
SkillBFreshness: B★ 2.5KClaude Code +9 - 0.323score
clean-architecture
wondelai
Structure software around the Dependency Rule: source code dependencies point inward from frameworks to use cases to entities.
SkillBFreshness: B★ 2.5KClaude Code +9 - 0.248score
clean-architecture
wondelai
Structure software around the Dependency Rule: source code dependencies point inward from frameworks to use cases to entities.
SkillBFreshness: BClaude Code +9
More from wondelai
- 0.618score
architecture-optimization
wondelai
Guided journey from a working codebase grown slow and tangled to one measurably fast, cleanly bounded, and readable.
SkillBFreshness: B★ 2.5KClaude Code +9 - 0.618score
conversion-optimization
wondelai
Guided journey from a leaking conversion flow - landing page, signup, checkout, or in-app onboarding - to a measured, tested funnel.
SkillBFreshness: B★ 2.5KClaude Code +9 - 0.618score
mom-test
wondelai
Talk to customers without leading them using Mom Test rules: discuss their life not your idea, ask about specifics in the past, and talk less.
SkillBFreshness: B★ 2.5KClaude Code +9 - 0.618score
37signals-way
wondelai
Build lean, opinionated products using the 37signals philosophy from "Getting Real", "Rework", and "Shape Up".
SkillBFreshness: B★ 2.5KClaude Code +9 - 0.618score
blue-ocean-strategy
wondelai
Create uncontested market space using value innovation instead of competing head-to-head.
SkillBFreshness: B★ 2.5KClaude Code +9 - 0.618score
clean-architecture
wondelai
Structure software around the Dependency Rule: source code dependencies point inward from frameworks to use cases to entities.
SkillBFreshness: B★ 2.5KClaude Code +9
Cite this page
clean-architecture skill. Agent Mart. https://agentmart.dev/skills/sung1-labs-clean-architecture (last updated 2026-10-24)