[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M755ZSW57BAGMHFCVDVQE04S":3,"skill-same:01M755ZSW57BAGMHFCVDVQE04S":72},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":13,"repositoryHtmlUrl":29,"repositoryHomepageUrl":6,"ownerHtmlUrl":30,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":31,"install":32,"resources":45},"01M755ZSW57BAGMHFCVDVQE04S","clean-architecture",null,"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 architecture\", \"use case boundary\", \"onion architecture\", \"screaming architecture\", or \"framework independence\". Also trigger when decoupling business logic from databases or frameworks, defining module boundaries, or debating where to put business rules. Covers component principles, boundaries, and SOLID. For code quality, see clean-code. For domain modeling, see domain-driven-design.","ASoudy\u002FAGS","ASoudy","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F40639702?v=4","01M74G5NTCW8MWDNRTAF303PA1","01M74G5NTZXSE6T0GZR5BCB6V0",0,"MIT","https:\u002F\u002Fgithub.com\u002FASoudy\u002FAGS\u002Fblob\u002Fmain\u002Fclaude_skills_libraries\u002Fwondelai-product-strategy\u002Fclean-architecture\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: clean-architecture\ndescription: '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 architecture\", \"use case boundary\", \"onion architecture\", \"screaming architecture\", or \"framework independence\". Also trigger when decoupling business logic from databases or frameworks, defining module boundaries, or debating where to put business rules. Covers component principles, boundaries, and SOLID. For code quality, see clean-code. For domain modeling, see domain-driven-design.'\nlicense: MIT\nmetadata:\n  author: wondelai\n  version: \"1.1.0\"\n---\n\n# Clean Architecture Framework\n\nA 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.\n\n## Core Principle\n\n**Source code dependencies must point inward -- toward higher-level policies.** Nothing in an inner circle can know anything about something in an outer circle. This single rule, applied consistently, produces systems that are testable, independent of frameworks, independent of the UI, independent of the database, and independent of any external agency.\n\n**The foundation:** Software architecture is about drawing lines -- boundaries -- that separate things that matter from things that are details. Business rules are what matter. Databases, web frameworks, and delivery mechanisms are details. When details depend on policies (not the other way around), you can defer decisions, swap implementations, and test business logic in isolation.\n\n## Scoring\n\n**Goal: 10\u002F10.** When reviewing or creating software architecture, rate it 0-10 based on adherence to the principles below. A 10\u002F10 means full alignment with all guidelines; lower scores indicate gaps to address. Always provide the current score and specific improvements needed to reach 10\u002F10.\n\n## The Clean Architecture Framework\n\nSix principles for building systems that survive the passage of time:\n\n### 1. Dependency Rule and Concentric Circles\n\n**Core concept:** The architecture is organized as concentric circles. The innermost circle contains Entities (enterprise business rules). The next circle contains Use Cases (application business rules). Then Interface Adapters. The outermost circle contains Frameworks and Drivers. Source code dependencies always point inward.\n\n**Why it works:** When high-level policies don't depend on low-level details, you can change the database from MySQL to MongoDB, swap a web framework, or replace a REST API with GraphQL -- all without touching business logic. The system becomes resilient to the most volatile parts of the technology stack.\n\n**Key insights:**\n- The Dependency Rule is the overriding rule: inner circles cannot mention outer circle names (classes, functions, variables, data formats)\n- Data that crosses boundaries must be in a form convenient for the inner circle, never in a form dictated by the outer circle\n- Dependency Inversion (interfaces defined inward, implemented outward) is the mechanism that enforces the rule\n- The number of circles is not fixed -- four is typical, but you may have more; the rule stays the same\n- Frameworks are details, not architecture -- they belong in the outermost circle\n\n**Code applications:**\n\n| Context | Pattern | Example |\n|---------|---------|---------|\n| **Layer direction** | Inner circles define interfaces; outer circles implement them | `UserRepository` interface in Use Cases; `PostgresUserRepository` in Adapters |\n| **Data crossing** | DTOs or simple structs cross boundaries, not ORM entities | Use Case returns `UserResponse` DTO, not an ActiveRecord model |\n| **Framework isolation** | Wrap framework calls behind interfaces | `EmailSender` interface hides whether you use SendGrid or SES |\n| **Database independence** | Repository pattern abstracts persistence | Business logic calls `repo.save(user)`, never raw SQL |\n| **Dependency direction** | Import arrows on a diagram always point inward | Controller imports Use Case; Use Case never imports Controller |\n\nSee: [references\u002Fdependency-rule.md](references\u002Fdependency-rule.md)\n\n### 2. Entities and Use Cases\n\n**Core concept:** Entities encapsulate enterprise-wide business rules -- the most general, highest-level rules that would exist even if no software system existed. Use Cases contain application-specific business rules that orchestrate the flow of data to and from Entities.\n\n**Why it works:** By separating what the business does (Entities) from how the application orchestrates it (Use Cases), you can reuse Entities across multiple applications and change application behavior without altering core business rules.\n\n**Key insights:**\n- Entities are not database rows -- they are objects (or pure functions) that encapsulate critical business rules and data\n- Use Cases describe application-specific automation rules; they orchestrate Entities but do not contain enterprise logic\n- Use Cases accept Request Models and return Response Models -- never framework objects\n- Each Use Case represents a single application operation (e.g., `CreateOrder`, `ApproveExpense`)\n- The Interactor pattern: a Use Case class implements an input boundary interface and calls an output boundary interface\n- Changes to a Use Case should never affect an Entity; changes to an Entity may require Use Case updates\n\n**Code applications:**\n\n| Context | Pattern | Example |\n|---------|---------|---------|\n| **Entity design** | Encapsulate critical business rules with no framework dependencies | `Order.calculateTotal()` applies tax rules; knows nothing about HTTP |\n| **Use Case boundary** | Define Input Port and Output Port interfaces | `CreateOrderInput` interface; `CreateOrderOutput` interface |\n| **Request\u002FResponse** | Simple data structures cross the boundary | `CreateOrderRequest { items, customerId }` -- no ORM models |\n| **Single responsibility** | One Use Case per application operation | `PlaceOrder`, `CancelOrder`, `RefundOrder` as separate classes |\n| **Interactor** | Use Case class implements Input Port, calls Output Port | `PlaceOrderInteractor implements PlaceOrderInput` |\n\nSee: [references\u002Fentities-use-cases.md](references\u002Fentities-use-cases.md)\n\n### 3. Interface Adapters and Frameworks\n\n**Core concept:** Interface Adapters convert data between the format most convenient for Use Cases and Entities and the format required by external agencies (database, web, devices). Frameworks and Drivers are the outermost layer -- glue code that connects to the outside world.\n\n**Why it works:** When the web framework, ORM, or message queue is confined to the outermost circles, replacing any of them becomes a localized change. The database is a detail. The web is a detail. The framework is a detail. Details should be plugins to your business rules, not the skeleton of your application.\n\n**Key insights:**\n- Controllers translate HTTP requests into Use Case input; Presenters translate Use Case output into view models\n- Gateways implement repository interfaces defined by Use Cases -- the Use Case defines the contract, the gateway fulfills it\n- The database is a detail: business rules don't need to know whether data is stored in SQL, NoSQL, or flat files\n- The web is a detail: business rules don't know they're being delivered over HTTP\n- Treat frameworks with suspicion -- they want you to couple to them; keep them at arm's length\n- Plugin architecture: the system should be structured so that frameworks plug into business rules, not the reverse\n\n**Code applications:**\n\n| Context | Pattern | Example |\n|---------|---------|---------|\n| **Controller** | Translates delivery mechanism to Use Case input | `OrderController.create(req)` builds `CreateOrderRequest` and calls Interactor |\n| **Presenter** | Translates Use Case output to view model | `OrderPresenter.present(response)` formats data for JSON\u002FHTML |\n| **Gateway** | Implements repository interface using a specific DB | `SqlOrderRepository implements OrderRepository` |\n| **Framework boundary** | Framework code calls inward, never called by inner circles | Express route handler calls Controller; Controller never imports Express |\n| **Plugin architecture** | Main component wires dependencies at startup | `main()` instantiates concrete classes and injects them |\n\nSee: [references\u002Fadapters-frameworks.md](references\u002Fadapters-frameworks.md)\n\n### 4. Component Principles\n\n**Core concept:** Components are the units of deployment. Three cohesion principles govern what goes inside a component; three coupling principles govern relationships between components. Together they determine a system's releasability, maintainability, and stability.\n\n**Why it works:** Poorly composed components create ripple effects: one change forces redeployment of unrelated code. The cohesion and coupling principles provide a systematic way to group classes and manage inter-component dependencies so that changes remain localized.\n\n**Key insights:**\n- REP (Reuse\u002FRelease Equivalence): classes in a component should be releasable together -- if you can't version and release them as a unit, they don't belong together\n- CCP (Common Closure): classes that change for the same reason at the same time belong in the same component (SRP for components)\n- CRP (Common Reuse): don't force users to depend on things they don't use -- if you must import a component, you should need most of its classes\n- ADP (Acyclic Dependencies): the dependency graph of components must have no cycles; break cycles with DIP or by extracting a new component\n- SDP (Stable Dependencies): depend in the direction of stability -- a component with many dependents should be hard to change\n- SAP (Stable Abstractions): stable components should be abstract; unstable components should be concrete\n\n**Code applications:**\n\n| Context | Pattern | Example |\n|---------|---------|---------|\n| **Component grouping** | Group classes that change together (CCP) | All order-related Use Cases in one component |\n| **Breaking cycles** | Apply DIP to invert a dependency edge | Extract an interface into a new component to break a circular dependency |\n| **Stability metrics** | Measure instability: I = Ce \u002F (Ca + Ce) | A component with many incoming and no outgoing deps has I near 0 (stable) |\n| **Abstractness balance** | Stable components should contain mostly interfaces | Core domain component is abstract; adapter component is concrete |\n| **Release granularity** | Version and release components independently | `order-domain v2.1.0` released without touching `payment-adapter` |\n\nSee: [references\u002Fcomponent-principles.md](references\u002Fcomponent-principles.md)\n\n### 5. SOLID Principles\n\n**Core concept:** Five principles for managing dependencies at the class and module level: Single Responsibility (SRP), Open-Closed (OCP), Liskov Substitution (LSP), Interface Segregation (ISP), and Dependency Inversion (DIP). They are the mid-level building blocks that make the Dependency Rule possible.\n\n**Why it works:** SOLID principles keep source code flexible, understandable, and amenable to change. They prevent the rigidity, fragility, and immobility that turn codebases into legacy nightmares. Each principle addresses a specific way that dependencies can go wrong.\n\n**Key insights:**\n- SRP: a module should have one, and only one, reason to change -- it serves one actor (not \"does one thing\")\n- OCP: extend behavior by adding new code, not by modifying existing code; strategy and plugin patterns are the mechanism\n- LSP: subtypes must be usable through the base type interface without the client knowing the difference; violated when subclass throws unexpected exceptions or ignores methods\n- ISP: clients should not be forced to depend on methods they do not use; fat interfaces create unnecessary coupling\n- DIP: high-level modules should not depend on low-level modules; both should depend on abstractions defined by the high-level module\n\n**Code applications:**\n\n| Context | Pattern | Example |\n|---------|---------|---------|\n| **SRP violation** | Class serves multiple actors | `Employee` handles pay calculation (CFO), reporting (COO), and persistence (CTO) |\n| **OCP via strategy** | New behavior through new classes, not edits | Add `ExpressShipping` class implementing `ShippingStrategy`, no changes to `Order` |\n| **LSP violation** | Subtype changes expected behavior | `Square extends Rectangle` breaks `setWidth()`\u002F`setHeight()` contract |\n| **ISP application** | Split fat interfaces into role interfaces | `Printer`, `Scanner`, `Fax` instead of one `MultiFunctionDevice` |\n| **DIP wiring** | High-level defines interface; low-level implements | `OrderService` depends on `PaymentGateway` interface, not `StripeClient` |\n\nSee: [references\u002Fsolid-principles.md](references\u002Fsolid-principles.md)\n\n### 6. Boundaries and Boundary Anatomy\n\n**Core concept:** A boundary is a line drawn between things that matter and things that are details. Boundaries are implemented through polymorphism: source code dependencies cross the boundary pointing inward, while the flow of control may cross in either direction. The Humble Object pattern makes code at boundaries testable.\n\n**Why it works:** Every boundary you draw gives you the option to defer a decision or swap an implementation. Boundaries separate the volatile from the stable, the concrete from the abstract. Early and strategic boundary placement determines whether a system is a joy or a pain to maintain over years.\n\n**Key insights:**\n- Full boundaries use reciprocal interfaces on both sides; partial boundaries use a simpler strategy pattern or facade\n- The Humble Object pattern: split behavior at a boundary into two classes -- one hard to test (close to the boundary) and one easy to test (contains the logic)\n- Services are not inherently architectural boundaries -- a microservice with a fat shared data model is just a monolith with network calls\n- The Main component is a plugin: it creates all factories, strategies, and dependencies, then hands control to the high-level policy\n- Test boundaries: tests are the most isolated component; they always depend inward and nothing depends on them\n- Premature boundaries are expensive, but so are missing boundaries -- draw them when the cost of crossing is less than the cost of not having them\n\n**Code applications:**\n\n| Context | Pattern | Example |\n|---------|---------|---------|\n| **Full boundary** | Input\u002FOutput port interfaces on both sides | Use Case defines both `PlaceOrderInput` and `PlaceOrderOutput` |\n| **Partial boundary** | Strategy or Facade without full reciprocal interfaces | `ShippingCalculator` accepts a `ShippingStrategy` -- simpler than full ports |\n| **Humble Object** | Separate testable logic from hard-to-test infrastructure | `PresenterLogic` (testable) produces `ViewModel`; `View` (humble) renders it |\n| **Main as plugin** | Composition root assembles the system | `main()` wires all concrete implementations and starts the app |\n| **Test boundary** | Tests depend on source; source never depends on tests | Test imports `PlaceOrderInteractor`; production code never imports test code |\n\nSee: [references\u002Fboundaries.md](references\u002Fboundaries.md)\n\n## Common Mistakes\n\n| Mistake | Why It Fails | Fix |\n|---------|-------------|-----|\n| **Letting the ORM leak into business logic** | Entities become coupled to the database schema; changing the DB means rewriting business rules | Separate domain entities from persistence models; map between them at the adapter layer |\n| **Putting business rules in controllers** | Logic becomes untestable without spinning up HTTP; duplication across endpoints | Move all business logic into Use Case Interactors; controllers only translate and delegate |\n| **Framework-first architecture** | The framework dictates folder structure and dependency flow; swapping frameworks means a rewrite | Treat the framework as a plugin in the outermost circle; structure code by business capability |\n| **Circular dependencies between components** | Changes ripple unpredictably; impossible to release independently | Apply DIP to break cycles or extract a shared abstraction component |\n| **One giant Use Case per feature** | Use Cases become bloated orchestrators with thousands of lines | Split into focused Use Cases with single application operations |\n| **Skipping boundaries \"because it's simple\"** | Coupling accumulates silently; by the time you need a boundary, the cost is enormous | Draw boundaries proactively at points of likely volatility |\n| **Treating microservices as automatic good architecture** | A distributed monolith with shared databases and tight coupling is worse than a well-structured monolith | Apply the Dependency Rule within and across services; services are deployment boundaries, not architectural ones |\n\n## Quick Diagnostic\n\n| Question | If No | Action |\n|----------|-------|--------|\n| Can you test business rules without a database, web server, or framework? | Business rules are coupled to infrastructure | Extract entities and use cases behind interfaces; mock the outer layers |\n| Do source code dependencies point inward on every import? | The Dependency Rule is violated | Introduce interfaces at the boundary; invert the offending dependency |\n| Can you swap the database without changing business logic? | Persistence is leaking inward | Implement the Repository pattern; isolate persistence in adapters |\n| Are Use Cases independent of the delivery mechanism? | Use Cases know about HTTP, CLI, or message queues | Remove delivery-specific types from Use Case signatures; use plain DTOs |\n| Is the framework confined to the outermost circle? | The framework is your architecture instead of a detail | Wrap framework calls behind interfaces; push framework code to the edges |\n| Can you identify the component dependency graph and confirm it has no cycles? | Circular dependencies exist | Apply ADP: use DIP or extract new components to break every cycle |\n| Does Main (or the composition root) wire all dependencies? | Concrete classes are instantiated in inner circles | Move all construction logic to Main; use dependency injection or factories |\n\n## Reference Files\n\n- [dependency-rule.md](references\u002Fdependency-rule.md): The Dependency Rule explained, concentric circles, data crossing boundaries, keeping the inner circle pure\n- [entities-use-cases.md](references\u002Fentities-use-cases.md): Enterprise Business Rules, Application Business Rules, the Interactor pattern, request\u002Fresponse models\n- [adapters-frameworks.md](references\u002Fadapters-frameworks.md): Interface adapters, frameworks as details, database as a detail, plugin architecture\n- [component-principles.md](references\u002Fcomponent-principles.md): REP, CCP, CRP, ADP, SDP, SAP -- component cohesion and coupling\n- [solid-principles.md](references\u002Fsolid-principles.md): SRP, OCP, LSP, ISP, DIP with code examples and common violations\n- [boundaries.md](references\u002Fboundaries.md): Boundary anatomy, Humble Object pattern, partial boundaries, Main as a plugin, test boundaries\n\n## Further Reading\n\nThis skill is based on Robert C. Martin's definitive guide to software architecture. For the complete methodology with detailed examples and case studies:\n\n- [*\"Clean Architecture: A Craftsman's Guide to Software Structure and Design\"*](https:\u002F\u002Fwww.amazon.com\u002FClean-Architecture-Craftsmans-Software-Structure\u002Fdp\u002F0134494164?tag=wondelai00-20) by Robert C. Martin\n\n## About the Author\n\n**Robert C. Martin (\"Uncle Bob\")** is a software engineer, author, and one of the founding signatories of the Agile Manifesto. He has been programming since 1970 and has consulted for and trained development teams worldwide. Martin is the author of *Clean Code*, *The Clean Coder*, *Clean Architecture*, and *Clean Agile*, among other books. He is the founder of Uncle Bob Consulting LLC and cleancoder.com. His SOLID principles have become foundational vocabulary in object-oriented design, and his advocacy for craftsmanship and discipline in software development has influenced generations of programmers. Martin's work consistently argues that software architecture is about managing dependencies, drawing boundaries, and keeping business rules independent of delivery mechanisms and infrastructure details.\n","# Clean Architecture Framework\n\nA 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.\n\n## Core Principle\n\n**Source code dependencies must point inward -- toward higher-level policies.** Nothing in an inner circle can know anything about something in an outer circle. This single rule, applied consistently, produces systems that are testable, independent of frameworks, independent of the UI, independent of the database, and independent of any external agency.\n\n**The foundation:** Software architecture is about drawing lines -- boundaries -- that separate things that matter from things that are details. Business rules are what matter. Databases, web frameworks, and delivery mechanisms are details. When details depend on policies (not the other way around), you can defer decisions, swap implementations, and test business logic in isolation.\n\n## Scoring\n\n**Goal: 10\u002F10.** When reviewing or creating software architecture, rate it 0-10 based on adherence to the principles below. A 10\u002F10 means full alignment with all guidelines; lower scores indicate gaps to address. Always provide the current score and specific improvements needed to reach 10\u002F10.\n\n## The Clean Architecture Framework\n\nSix principles for building systems that survive the passage of time:\n\n### 1. Dependency Rule and Concentric Circles\n\n**Core concept:** The architecture is organized as concentric circles. The innermost circle contains Entities (enterprise business rules). The next circle contains Use Cases (application business rules). Then Interface Adapters. The outermost circle contains Frameworks and Drivers. Source code dependencies always point inward.\n\n**Why it works:** When high-level policies don't depend on low-level details, you can change the database from MySQL to MongoDB, swap a web framework, or replace a REST API with GraphQL -- all without touching business logic. The system becomes resilient to the most volatile parts of the technology stack.\n\n**Key insights:**\n- The Dependency Rule is the overriding rule: inner circles cannot mention outer circle names (classes, functions, variables, data formats)\n- Data that crosses boundaries must be in a form convenient for the inner circle, never in a form dictated by the outer circle\n- Dependency Inversion (interfaces defined inward, implemented outward) is the mechanism that enforces the rule\n- The number of circles is not fixed -- four is typical, but you may have more; the rule stays the same\n- Frameworks are details, not architecture -- they belong in the outermost circle\n\n**Code applications:**\n\n| Context | Pattern | Example |\n|---------|---------|---------|\n| **Layer direction** | Inner circles define interfaces; outer circles implement them | `UserRepository` interface in Use Cases; `PostgresUserRepository` in Adapters |\n| **Data crossing** | DTOs or simple structs cross boundaries, not ORM entities | Use Case returns `UserResponse` DTO, not an ActiveRecord model |\n| **Framework isolation** | Wrap framework calls behind interfaces | `EmailSender` interface hides whether you use SendGrid or SES |\n| **Database independence** | Repository pattern abstracts persistence | Business logic calls `repo.save(user)`, never raw SQL |\n| **Dependency direction** | Import arrows on a diagram always point inward | Controller imports Use Case; Use Case never imports Controller |\n\nSee: [references\u002Fdependency-rule.md](references\u002Fdependency-rule.md)\n\n### 2. Entities and Use Cases\n\n**Core concept:** Entities encapsulate enterprise-wide business rules -- the most general, highest-level rules that would exist even if no software system existed. Use Cases contain application-specific business rules that orchestrate the flow of data to and from Entities.\n\n**Why it works:** By separating what the business does (Entities) from how the application orchestrates it (Use Cases), you can reuse Entities across multiple applications and change application behavior without altering core business rules.\n\n**Key insights:**\n- Entities are not database rows -- they are objects (or pure functions) that encapsulate critical business rules and data\n- Use Cases describe application-specific automation rules; they orchestrate Entities but do not contain enterprise logic\n- Use Cases accept Request Models and return Response Models -- never framework objects\n- Each Use Case represents a single application operation (e.g., `CreateOrder`, `ApproveExpense`)\n- The Interactor pattern: a Use Case class implements an input boundary interface and calls an output boundary interface\n- Changes to a Use Case should never affect an Entity; changes to an Entity may require Use Case updates\n\n**Code applications:**\n\n| Context | Pattern | Example |\n|---------|---------|---------|\n| **Entity design** | Encapsulate critical business rules with no framework dependencies | `Order.calculateTotal()` applies tax rules; knows nothing about HTTP |\n| **Use Case boundary** | Define Input Port and Output Port interfaces | `CreateOrderInput` interface; `CreateOrderOutput` interface |\n| **Request\u002FResponse** | Simple data structures cross the boundary | `CreateOrderRequest { items, customerId }` -- no ORM models |\n| **Single responsibility** | One Use Case per application operation | `PlaceOrder`, `CancelOrder`, `RefundOrder` as separate classes |\n| **Interactor** | Use Case class implements Input Port, calls Output Port | `PlaceOrderInteractor implements PlaceOrderInput` |\n\nSee: [references\u002Fentities-use-cases.md](references\u002Fentities-use-cases.md)\n\n### 3. Interface Adapters and Frameworks\n\n**Core concept:** Interface Adapters convert data between the format most convenient for Use Cases and Entities and the format required by external agencies (database, web, devices). Frameworks and Drivers are the outermost layer -- glue code that connects to the outside world.\n\n**Why it works:** When the web framework, ORM, or message queue is confined to the outermost circles, replacing any of them becomes a localized change. The database is a detail. The web is a detail. The framework is a detail. Details should be plugins to your business rules, not the skeleton of your application.\n\n**Key insights:**\n- Controllers translate HTTP requests into Use Case input; Presenters translate Use Case output into view models\n- Gateways implement repository interfaces defined by Use Cases -- the Use Case defines the contract, the gateway fulfills it\n- The database is a detail: business rules don't need to know whether data is stored in SQL, NoSQL, or flat files\n- The web is a detail: business rules don't know they're being delivered over HTTP\n- Treat frameworks with suspicion -- they want you to couple to them; keep them at arm's length\n- Plugin architecture: the system should be structured so that frameworks plug into business rules, not the reverse\n\n**Code applications:**\n\n| Context | Pattern | Example |\n|---------|---------|---------|\n| **Controller** | Translates delivery mechanism to Use Case input | `OrderController.create(req)` builds `CreateOrderRequest` and calls Interactor |\n| **Presenter** | Translates Use Case output to view model | `OrderPresenter.present(response)` formats data for JSON\u002FHTML |\n| **Gateway** | Implements repository interface using a specific DB | `SqlOrderRepository implements OrderRepository` |\n| **Framework boundary** | Framework code calls inward, never called by inner circles | Express route handler calls Controller; Controller never imports Express |\n| **Plugin architecture** | Main component wires dependencies at startup | `main()` instantiates concrete classes and injects them |\n\nSee: [references\u002Fadapters-frameworks.md](references\u002Fadapters-frameworks.md)\n\n### 4. Component Principles\n\n**Core concept:** Components are the units of deployment. Three cohesion principles govern what goes inside a component; three coupling principles govern relationships between components. Together they determine a system's releasability, maintainability, and stability.\n\n**Why it works:** Poorly composed components create ripple effects: one change forces redeployment of unrelated code. The cohesion and coupling principles provide a systematic way to group classes and manage inter-component dependencies so that changes remain localized.\n\n**Key insights:**\n- REP (Reuse\u002FRelease Equivalence): classes in a component should be releasable together -- if you can't version and release them as a unit, they don't belong together\n- CCP (Common Closure): classes that change for the same reason at the same time belong in the same component (SRP for components)\n- CRP (Common Reuse): don't force users to depend on things they don't use -- if you must import a component, you should need most of its classes\n- ADP (Acyclic Dependencies): the dependency graph of components must have no cycles; break cycles with DIP or by extracting a new component\n- SDP (Stable Dependencies): depend in the direction of stability -- a component with many dependents should be hard to change\n- SAP (Stable Abstractions): stable components should be abstract; unstable components should be concrete\n\n**Code applications:**\n\n| Context | Pattern | Example |\n|---------|---------|---------|\n| **Component grouping** | Group classes that change together (CCP) | All order-related Use Cases in one component |\n| **Breaking cycles** | Apply DIP to invert a dependency edge | Extract an interface into a new component to break a circular dependency |\n| **Stability metrics** | Measure instability: I = Ce \u002F (Ca + Ce) | A component with many incoming and no outgoing deps has I near 0 (stable) |\n| **Abstractness balance** | Stable components should contain mostly interfaces | Core domain component is abstract; adapter component is concrete |\n| **Release granularity** | Version and release components independently | `order-domain v2.1.0` released without touching `payment-adapter` |\n\nSee: [references\u002Fcomponent-principles.md](references\u002Fcomponent-principles.md)\n\n### 5. SOLID Principles\n\n**Core concept:** Five principles for managing dependencies at the class and module level: Single Responsibility (SRP), Open-Closed (OCP), Liskov Substitution (LSP), Interface Segregation (ISP), and Dependency Inversion (DIP). They are the mid-level building blocks that make the Dependency Rule possible.\n\n**Why it works:** SOLID principles keep source code flexible, understandable, and amenable to change. They prevent the rigidity, fragility, and immobility that turn codebases into legacy nightmares. Each principle addresses a specific way that dependencies can go wrong.\n\n**Key insights:**\n- SRP: a module should have one, and only one, reason to change -- it serves one actor (not \"does one thing\")\n- OCP: extend behavior by adding new code, not by modifying existing code; strategy and plugin patterns are the mechanism\n- LSP: subtypes must be usable through the base type interface without the client knowing the difference; violated when subclass throws unexpected exceptions or ignores methods\n- ISP: clients should not be forced to depend on methods they do not use; fat interfaces create unnecessary coupling\n- DIP: high-level modules should not depend on low-level modules; both should depend on abstractions defined by the high-level module\n\n**Code applications:**\n\n| Context | Pattern | Example |\n|---------|---------|---------|\n| **SRP violation** | Class serves multiple actors | `Employee` handles pay calculation (CFO), reporting (COO), and persistence (CTO) |\n| **OCP via strategy** | New behavior through new classes, not edits | Add `ExpressShipping` class implementing `ShippingStrategy`, no changes to `Order` |\n| **LSP violation** | Subtype changes expected behavior | `Square extends Rectangle` breaks `setWidth()`\u002F`setHeight()` contract |\n| **ISP application** | Split fat interfaces into role interfaces | `Printer`, `Scanner`, `Fax` instead of one `MultiFunctionDevice` |\n| **DIP wiring** | High-level defines interface; low-level implements | `OrderService` depends on `PaymentGateway` interface, not `StripeClient` |\n\nSee: [references\u002Fsolid-principles.md](references\u002Fsolid-principles.md)\n\n### 6. Boundaries and Boundary Anatomy\n\n**Core concept:** A boundary is a line drawn between things that matter and things that are details. Boundaries are implemented through polymorphism: source code dependencies cross the boundary pointing inward, while the flow of control may cross in either direction. The Humble Object pattern makes code at boundaries testable.\n\n**Why it works:** Every boundary you draw gives you the option to defer a decision or swap an implementation. Boundaries separate the volatile from the stable, the concrete from the abstract. Early and strategic boundary placement determines whether a system is a joy or a pain to maintain over years.\n\n**Key insights:**\n- Full boundaries use reciprocal interfaces on both sides; partial boundaries use a simpler strategy pattern or facade\n- The Humble Object pattern: split behavior at a boundary into two classes -- one hard to test (close to the boundary) and one easy to test (contains the logic)\n- Services are not inherently architectural boundaries -- a microservice with a fat shared data model is just a monolith with network calls\n- The Main component is a plugin: it creates all factories, strategies, and dependencies, then hands control to the high-level policy\n- Test boundaries: tests are the most isolated component; they always depend inward and nothing depends on them\n- Premature boundaries are expensive, but so are missing boundaries -- draw them when the cost of crossing is less than the cost of not having them\n\n**Code applications:**\n\n| Context | Pattern | Example |\n|---------|---------|---------|\n| **Full boundary** | Input\u002FOutput port interfaces on both sides | Use Case defines both `PlaceOrderInput` and `PlaceOrderOutput` |\n| **Partial boundary** | Strategy or Facade without full reciprocal interfaces | `ShippingCalculator` accepts a `ShippingStrategy` -- simpler than full ports |\n| **Humble Object** | Separate testable logic from hard-to-test infrastructure | `PresenterLogic` (testable) produces `ViewModel`; `View` (humble) renders it |\n| **Main as plugin** | Composition root assembles the system | `main()` wires all concrete implementations and starts the app |\n| **Test boundary** | Tests depend on source; source never depends on tests | Test imports `PlaceOrderInteractor`; production code never imports test code |\n\nSee: [references\u002Fboundaries.md](references\u002Fboundaries.md)\n\n## Common Mistakes\n\n| Mistake | Why It Fails | Fix |\n|---------|-------------|-----|\n| **Letting the ORM leak into business logic** | Entities become coupled to the database schema; changing the DB means rewriting business rules | Separate domain entities from persistence models; map between them at the adapter layer |\n| **Putting business rules in controllers** | Logic becomes untestable without spinning up HTTP; duplication across endpoints | Move all business logic into Use Case Interactors; controllers only translate and delegate |\n| **Framework-first architecture** | The framework dictates folder structure and dependency flow; swapping frameworks means a rewrite | Treat the framework as a plugin in the outermost circle; structure code by business capability |\n| **Circular dependencies between components** | Changes ripple unpredictably; impossible to release independently | Apply DIP to break cycles or extract a shared abstraction component |\n| **One giant Use Case per feature** | Use Cases become bloated orchestrators with thousands of lines | Split into focused Use Cases with single application operations |\n| **Skipping boundaries \"because it's simple\"** | Coupling accumulates silently; by the time you need a boundary, the cost is enormous | Draw boundaries proactively at points of likely volatility |\n| **Treating microservices as automatic good architecture** | A distributed monolith with shared databases and tight coupling is worse than a well-structured monolith | Apply the Dependency Rule within and across services; services are deployment boundaries, not architectural ones |\n\n## Quick Diagnostic\n\n| Question | If No | Action |\n|----------|-------|--------|\n| Can you test business rules without a database, web server, or framework? | Business rules are coupled to infrastructure | Extract entities and use cases behind interfaces; mock the outer layers |\n| Do source code dependencies point inward on every import? | The Dependency Rule is violated | Introduce interfaces at the boundary; invert the offending dependency |\n| Can you swap the database without changing business logic? | Persistence is leaking inward | Implement the Repository pattern; isolate persistence in adapters |\n| Are Use Cases independent of the delivery mechanism? | Use Cases know about HTTP, CLI, or message queues | Remove delivery-specific types from Use Case signatures; use plain DTOs |\n| Is the framework confined to the outermost circle? | The framework is your architecture instead of a detail | Wrap framework calls behind interfaces; push framework code to the edges |\n| Can you identify the component dependency graph and confirm it has no cycles? | Circular dependencies exist | Apply ADP: use DIP or extract new components to break every cycle |\n| Does Main (or the composition root) wire all dependencies? | Concrete classes are instantiated in inner circles | Move all construction logic to Main; use dependency injection or factories |\n\n## Reference Files\n\n- [dependency-rule.md](references\u002Fdependency-rule.md): The Dependency Rule explained, concentric circles, data crossing boundaries, keeping the inner circle pure\n- [entities-use-cases.md](references\u002Fentities-use-cases.md): Enterprise Business Rules, Application Business Rules, the Interactor pattern, request\u002Fresponse models\n- [adapters-frameworks.md](references\u002Fadapters-frameworks.md): Interface adapters, frameworks as details, database as a detail, plugin architecture\n- [component-principles.md](references\u002Fcomponent-principles.md): REP, CCP, CRP, ADP, SDP, SAP -- component cohesion and coupling\n- [solid-principles.md](references\u002Fsolid-principles.md): SRP, OCP, LSP, ISP, DIP with code examples and common violations\n- [boundaries.md](references\u002Fboundaries.md): Boundary anatomy, Humble Object pattern, partial boundaries, Main as a plugin, test boundaries\n\n## Further Reading\n\nThis skill is based on Robert C. Martin's definitive guide to software architecture. For the complete methodology with detailed examples and case studies:\n\n- [*\"Clean Architecture: A Craftsman's Guide to Software Structure and Design\"*](https:\u002F\u002Fwww.amazon.com\u002FClean-Architecture-Craftsmans-Software-Structure\u002Fdp\u002F0134494164?tag=wondelai00-20) by Robert C. Martin\n\n## About the Author\n\n**Robert C. Martin (\"Uncle Bob\")** is a software engineer, author, and one of the founding signatories of the Agile Manifesto. He has been programming since 1970 and has consulted for and trained development teams worldwide. Martin is the author of *Clean Code*, *The Clean Coder*, *Clean Architecture*, and *Clean Agile*, among other books. He is the founder of Uncle Bob Consulting LLC and cleancoder.com. His SOLID principles have become foundational vocabulary in object-oriented design, and his advocacy for craftsmanship and discipline in software development has influenced generations of programmers. Martin's work consistently argues that software architecture is about managing dependencies, drawing boundaries, and keeping business rules independent of delivery mechanisms and infrastructure details.\n",{"name":5,"license":14,"metadata":23,"description":7},{"author":24,"version":25},"wondelai","1.1.0","main","cd1d94757d590093507ef8ac26299eab8bc20478","claude_skills_libraries\u002Fwondelai-product-strategy\u002Fclean-architecture","https:\u002F\u002Fgithub.com\u002FASoudy\u002FAGS","https:\u002F\u002Fgithub.com\u002FASoudy","2026-05-23 09:43:12",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add ASoudy\u002FAGS --skill clean-architecture",{"tool":38,"command":39},"bunx","bunx skills add ASoudy\u002FAGS --skill clean-architecture",{"tool":41,"command":42},"pnpm","pnpm dlx skills add ASoudy\u002FAGS --skill clean-architecture","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FASoudy\u002FAGS\u002Fblob\u002Fmain\u002Fclaude_skills_libraries\u002Fwondelai-product-strategy\u002Fclean-architecture\u002FSKILL.md",true,[46,52,56,60,64,68],{"path":47,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":50,"sourceHtmlUrl":51},"references\u002Fadapters-frameworks.md","REFERENCE","参考文档",15892,"https:\u002F\u002Fgithub.com\u002FASoudy\u002FAGS\u002Fblob\u002Fmain\u002Fclaude_skills_libraries\u002Fwondelai-product-strategy\u002Fclean-architecture\u002Freferences\u002Fadapters-frameworks.md",{"path":53,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":54,"sourceHtmlUrl":55},"references\u002Fboundaries.md",18349,"https:\u002F\u002Fgithub.com\u002FASoudy\u002FAGS\u002Fblob\u002Fmain\u002Fclaude_skills_libraries\u002Fwondelai-product-strategy\u002Fclean-architecture\u002Freferences\u002Fboundaries.md",{"path":57,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":58,"sourceHtmlUrl":59},"references\u002Fcomponent-principles.md",12777,"https:\u002F\u002Fgithub.com\u002FASoudy\u002FAGS\u002Fblob\u002Fmain\u002Fclaude_skills_libraries\u002Fwondelai-product-strategy\u002Fclean-architecture\u002Freferences\u002Fcomponent-principles.md",{"path":61,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":62,"sourceHtmlUrl":63},"references\u002Fdependency-rule.md",13578,"https:\u002F\u002Fgithub.com\u002FASoudy\u002FAGS\u002Fblob\u002Fmain\u002Fclaude_skills_libraries\u002Fwondelai-product-strategy\u002Fclean-architecture\u002Freferences\u002Fdependency-rule.md",{"path":65,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":66,"sourceHtmlUrl":67},"references\u002Fentities-use-cases.md",14750,"https:\u002F\u002Fgithub.com\u002FASoudy\u002FAGS\u002Fblob\u002Fmain\u002Fclaude_skills_libraries\u002Fwondelai-product-strategy\u002Fclean-architecture\u002Freferences\u002Fentities-use-cases.md",{"path":69,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":70,"sourceHtmlUrl":71},"references\u002Fsolid-principles.md",16938,"https:\u002F\u002Fgithub.com\u002FASoudy\u002FAGS\u002Fblob\u002Fmain\u002Fclaude_skills_libraries\u002Fwondelai-product-strategy\u002Fclean-architecture\u002Freferences\u002Fsolid-principles.md",[73,80,87,94,101,108],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":18},"01M756BTEVC407T0QR8S420JWD","web-typography","Select, pair, and implement typefaces for web projects. Use when the user mentions \"font pairing\", \"which typeface\", \"line height\", \"responsive typography\", \"web font loading\", \"type hierarchy\", \"variable fonts\", \"FOUT\u002FFOIT\", or \"typographic scale\". Also trigger when choosing between system fonts and web fonts, optimizing font loading performance, or designing readable long-form content layouts. Covers readability evaluation, CSS implementation, and performance optimization. For overall UI design systems, see refactoring-ui. For dramatic typographic experiences, see top-design.","https:\u002F\u002Fgithub.com\u002FASoudy\u002FAGS\u002Fblob\u002Fmain\u002Fclaude_skills_libraries\u002Fwondelai-product-strategy\u002Fweb-typography\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":18},"01M756B4RYF2CB17C33X6ZJQT5","ux-heuristics","Evaluate and improve interface usability using heuristic analysis. Use when the user mentions \"usability audit\", \"UX review\", \"users are confused\", \"heuristic evaluation\", \"form usability\", \"navigation problems\", \"Nielsen heuristics\", \"cognitive walkthrough\", or \"usability testing\". Also trigger when reviewing a design for usability issues, improving form completion rates, or evaluating information architecture and navigation. Covers Nielsens 10 heuristics, severity ratings, and information architecture. For visual design fixes, see refactoring-ui. For conversion-focused audits, see cro-methodology.","https:\u002F\u002Fgithub.com\u002FASoudy\u002FAGS\u002Fblob\u002Fmain\u002Fclaude_skills_libraries\u002Fwondelai-product-strategy\u002Fux-heuristics\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":18},"01M756ANVFT0T6BAPV6Y93EPR6","traction-eos","Implement the Entrepreneurial Operating System (EOS) to align vision and execution across a company. Use when the user mentions \"EOS\", \"V\u002FTO\", \"quarterly rocks\", \"Level 10 meetings\", \"accountability chart\", \"IDS process\", \"Entrepreneurial Operating System\", or \"business operating system\". Also trigger when a growing company needs meeting structure, goal-setting frameworks, or a systematic approach to solving recurring organizational issues. Covers the six EOS components: Vision, People, Data, Issues, Process, Traction. For team motivation design, see drive-motivation. For lean experimentation, see lean-startup.","https:\u002F\u002Fgithub.com\u002FASoudy\u002FAGS\u002Fblob\u002Fmain\u002Fclaude_skills_libraries\u002Fwondelai-product-strategy\u002Ftraction-eos\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":18},"01M756A7NZZMNJN9KZ33QGFHV6","top-design","Create award-winning, immersive web experiences at the level of Awwwards-featured agencies. Use when the user mentions \"premium website\", \"portfolio site\", \"scroll animations\", \"Awwwards quality\", \"brand experience\", \"cinematic web design\", \"parallax storytelling\", or \"agency-quality site\". Also trigger when building landing pages that need to impress, designing creative portfolios, or elevating a standard website to a memorable digital experience. Covers dramatic typography, purposeful motion, scroll-based composition, and performance-optimized animation. For foundational UI, see refactoring-ui. For type selection, see web-typography.","https:\u002F\u002Fgithub.com\u002FASoudy\u002FAGS\u002Fblob\u002Fmain\u002Fclaude_skills_libraries\u002Fwondelai-product-strategy\u002Ftop-design\u002FSKILL.md",[],[],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":18},"01M7569J5G1NXM3RR194D52SGB","system-design","Design scalable distributed systems using structured approaches for load balancing, caching, database scaling, and message queues. Use when the user mentions \"system design\", \"scale this\", \"high availability\", \"rate limiter\", \"design a URL shortener\", \"system design interview\", \"capacity planning\", or \"distributed architecture\". Also trigger when estimating infrastructure requirements, choosing between microservices and monoliths, or designing for millions of concurrent users. Covers common system designs and back-of-the-envelope estimation. For data fundamentals, see ddia-systems. For resilience, see release-it.","https:\u002F\u002Fgithub.com\u002FASoudy\u002FAGS\u002Fblob\u002Fmain\u002Fclaude_skills_libraries\u002Fwondelai-product-strategy\u002Fsystem-design\u002FSKILL.md",[],[],{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":18},"01M75691MJKE6PBA1EC398EKQT","storybrand-messaging","Clarify brand messaging using narrative structure that positions the customer as hero. Use when the user mentions \"brand message\", \"website copy\", \"elevator pitch\", \"one-liner\", \"messaging isnt resonating\", \"brand script\", \"StoryBrand framework\", or \"customer as hero\". Also trigger when rewriting homepage copy, crafting email nurture sequences, or creating consistent messaging across sales collateral and marketing materials. Covers landing page copy, marketing collateral, and consistent communication. For memorable messaging, see made-to-stick. For product positioning, see obviously-awesome.","https:\u002F\u002Fgithub.com\u002FASoudy\u002FAGS\u002Fblob\u002Fmain\u002Fclaude_skills_libraries\u002Fwondelai-product-strategy\u002Fstorybrand-messaging\u002FSKILL.md",[],[]]