clean-architecture
Skill11 starsChanged 11 days agoMITView on GitHub
Clean Architecture guidance centered on the dependency rule, entities, use cases/interactors, and interface adapters that keep business policy independent from frameworks, databases, and UI. Use when the main design question is how policy flows through use cases and adapter boundaries. Use hexagonal-architecture when named inbound/outbound ports around external actors are the main concern, onion-architecture when explicit concentric domain/application rings are the requested model, and architecture-review for a read-only audit. Do not use for simple CRUD, prototypes, or framework-convention-first apps where added layers reduce clarity.
28 other projects use a version of this.
Adopted by
Most recently taken up by
- kinhluan/skillstheir own version, first seen Nov 8, 2026
- codewithmukesh/dotnet-claude-kittheir own version, first seen Nov 8, 2026
- yht-4403/jc-agent-skillstheir own version, first seen Nov 8, 2026
- zdanovichnick/dotnet-pilottheir own version, first seen Nov 6, 2026
- soysantana/skillstheir own version, first seen Nov 1, 2026
- GabrielMartinMoran/mindtheir own version, first seen Nov 1, 2026
Used with
Projects with it also use convention-learner, opentelemetry and 8 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
codewithmukeshSkillconvention-learner
Detects and enforces project-specific coding conventions by analyzing existing codebase patterns. Learns naming conventions, folder structure, test organization, and coding style from the existing code. Load when: "conventions", "coding standards", "project patterns", "enforce style", "detect patterns", "learn conventions", "code consistency".
Also in 3 projects that use this
codewithmukeshSkillopentelemetry
OpenTelemetry observability for .NET 10 applications. Covers traces, metrics, and logs using the OpenTelemetry SDK with OTLP export. Includes custom ActivitySource, IMeterFactory metrics, resource configuration, and Aspire Dashboard integration. Load this skill when setting up distributed tracing, custom metrics, OTLP export, or when the user mentions "OpenTelemetry", "OTLP", "traces", "spans", "Activity", "ActivitySource", "metrics", "IMeterFactory", "Meter", "Counter", "Histogram", "Gauge", "telemetry", "observability", "distributed tracing", "OTEL", or "Aspire Dashboard".
Also in 3 projects that use this
MovGP0Skillmodern-csharp
Modern C# style guidance for Bendex and MicroSea code changes, including primary constructors, expression-bodied members, var usage, target-typed new, lambdas, and pattern matching.
Also in 3 projects that use this
MicrosoftSkillresilience
Apply resilience patterns (retry, backoff, circuit breaking) when writing or reviewing code that makes outbound HTTP/REST calls, database operations, or any I/O that can experience transient failures. Use this skill when: (1) writing new code that calls external services or APIs, (2) reviewing code that uses fetch, HTTP clients, or service-to-service calls, (3) adding queue consumers or workers that interact with remote systems, (4) debugging intermittent failures in production.
Also in 3 projects that use this
hongyuancSkillvertical-slice
Build and evaluate a production-quality vertical slice before advancing from Pre-Production to Production.
Also in 3 projects that use this
wpankSkillcaching
Caching strategies, invalidation, eviction policies, HTTP caching, distributed caching, and anti-patterns. Use when designing cache layers, choosing eviction policies, debugging stale data, or optimizing read-heavy workloads.
Also in 3 projects that use this
Other versions28 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 28
- ciembor/agent-rules-books★ 2.8ksame name
- wondelai/skills★ 2.6ksame name
- codewithmukesh/dotnet-claude-kit★ 808same name
- Mindrally/skills★ 275same name
- Resgrid/Core★ 238same name
- GabrielMartinMoran/mind★ 193same name
- tokenaissance/clean-architecture★ 17same name
- G1Joshi/Agent-Skills★ 15same name
- korallis/skills-collection★ 14same name
- kinhluan/skills★ 6same name
18 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository70 other files it gives its agents.
- AGENTS.mdAGENTS.md
- adversarial-reviewSkill
- api-designSkill
- architecture-reviewSkill
- behavior-driven-developmentSkill
- brainstormingSkill
- ci-release-engineeringSkill
- code-reviewSkill
- container-engineeringSkill
- create-agent-skillSkill
- csharp-dotnet-engineeringSkill
- css-scss-stylingSkill
- data-platform-engineeringSkill
- dependency-supply-chain-reviewSkill
- digital-asset-managementSkill
- documentation-engineeringSkill
- domain-driven-designSkill
- domain-modelingSkill
- donsetch-web-researchSkill
- gherkinSkill
- git-commitSkill
- git-workflowsSkill
- hexagonal-architectureSkill
- impeccableSkill
- internationalization-localizationSkill
- javascript-typescript-engineeringSkill
- justfilesSkill
- mcp-server-engineeringSkill
- mysql-mariadb-sql-engineeringSkill
- observability-engineeringSkill
- onion-architectureSkill
- parallelism-engineeringSkill
- performance-reviewSkill
- playwright-e2eSkill
- postgresql-sql-engineeringSkill
- prompt-engineering-reviewSkill
- python-antipatternsSkill
- python-design-patternsSkill
- python-engineeringSkill
- random-data-identifiersSkill
- release-readinessSkill
- review-verification-protocolSkill
- root-cause-analysisSkill
- ruby-engineeringSkill
- rust-antipatternsSkill
- rust-async-webSkill
- rust-code-reviewSkill
- rust-design-patternsSkill
- rust-desktop-guiSkill
- rust-engineeringSkill
- rust-persistence-sqlSkill
- rust-testing-qualitySkill
- script-engineeringSkill
- security-review-evidenceSkill
- security-reviewSkill
- semantic-versioningSkill
- sql-engineeringSkill
- sqlite-sql-engineeringSkill
- suggest-lucide-iconsSkill
- svelte-sveltekit-engineeringSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
16 rules. 0 are common, 15 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 26 edited versions we read keep these.
15
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use Clean Architecture to keep business policy independent from delivery mechanisms, frameworks, databases, UI, queues, and vendor SDKs.
- Distinctive: line 33
Do not force it for:
- Distinctive: line 88
Name the inner policy: Put enterprise/application business rules in domain objects and use cases.
- Distinctive: line 91
Define boundaries from core needs: Create input/output boundaries, repository interfaces, gateways, presenters, or ports only where the use …
- Distinctive: line 97
Wire dependencies at the outside: Use dependency injection, composition roots, factories, or module wiring outside the core.
- Distinctive: line 104
When implementation begins, load the matching language engineering skill and any data skill needed for persistence, schema, query, or …
- Distinctive: line 109
Before reporting completion, check the changed behavior and dependency direction at the affected policy and adapter boundaries, then run …
- Distinctive: line 121
Use case inputs should express what the use case needs, not the raw HTTP body, CLI args, queue payload, or UI form state.
- Distinctive: line 123
Use case outputs can be simple result DTOs, domain results, events, or an output port/presenter interface.
- Distinctive: line 135
Test entities and domain services directly for invariants, calculations, policies, and state transitions.
- Distinctive: line 137
Test use cases with fake or in-memory gateways, repositories, presenters, clocks, ID generators, and external-service ports.
- Distinctive: line 139
Test interface adapters against their real contracts: HTTP routing and serialization, database mappings and constraints, SQL, queue …
- Distinctive: line 142
Add architecture/dependency tests when the language or tooling can enforce inward dependencies cheaply.
- Distinctive: line 144
Use end-to-end tests for critical wiring and behavior that narrower tests cannot prove.
- Very specific: line 159
Prefer names from the domain and use cases over generic buckets like helpers, managers, or services when the code represents business …
- Distinctive: line 193
Before recommending Clean Architecture, ask or infer: expected lifetime, business-rule complexity, delivery mechanisms, infrastructure …
“Common” is measured: kept by at least 6 in 10 of the 26 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Clean Architecture
Use Clean Architecture to keep business policy independent from delivery mechanisms, frameworks, databases, UI, queues, and vendor SDKs. The core idea is separation of concerns enforced by the dependency rule: source-code dependencies point inward toward higher-level policy, while outer details adapt to the core.
Clean Architecture is a dependency strategy, not a mandatory folder layout. Apply it only where business rules, lifetime, testability, or change pressure justify the ceremony.
Use When
Recommend or apply Clean Architecture when the work involves:
- Long-lived services or applications where maintainability matters more than fastest initial delivery.
- Complex business rules, invariants, workflows, policies, or application use cases that should survive framework, UI, database, or vendor changes.
- Multiple delivery mechanisms invoking the same behavior: HTTP, CLI, jobs, schedulers, message consumers, server functions, UI actions, or APIs.
- Infrastructure that should be replaceable or testable behind seams: databases, ORMs, queues, caches, clocks, ID generators, file systems, cloud SDKs, payment providers, email senders, or external services.
- Teams that can tolerate explicit boundaries, mapping, tests per boundary, and the learning curve of dependency inversion.
Do not force it for:
- Simple CRUD with little business behavior.
- Prototypes, one-off scripts, throwaway tools, migrations, or small automation.
- Apps where framework conventions are intentionally the architecture.
- Teams or deadlines where extra indirection will slow learning and reduce clarity more than it protects future change.
- Features that might grow later but do not yet have real policy, external mechanisms, or testability pressure. Leave seams; do not build unused layers.
Dependency Rule
- Inner policy must not mention outer details: frameworks, controllers, request objects, response objects, ORM rows, database clients, SDK models, queues, serializer types, or UI components.
- Outer layers depend on inner layers. If control must flow outward, use dependency inversion: define the needed boundary in or near the inner policy and implement it outward.
- Data crossing inward should be simple and shaped for the inner use case, not a framework, persistence, transport, or vendor format.
- The dependency rule matters more than the number or names of layers. Four circles are a teaching diagram, not a required package count.
Typical Responsibilities
- Entities/domain model: general business rules, invariants, calculations, state transitions, policies, value objects, aggregates, and domain events. They should be independent of application workflow and infrastructure details.
- Use cases/interactors/application services: application-specific business rules. They orchestrate workflows, authorization handoff, transactions, entity/domain operations, outbound gateway calls, and result production.
- Interface adapters: controllers, presenters, view models, serializers, repository/gateway implementations, persistence mappers, API clients, queue consumers/producers, and adapters that translate between inner models and outer mechanisms.
- Frameworks, drivers, and infrastructure: web frameworks, databases, ORMs, UI frameworks, message brokers, file systems, cloud services, external SDKs, app startup, dependency injection wiring, and glue code.
Names vary by ecosystem. use case, interactor, application service,
handler, or command handler can all be valid if dependency direction and
responsibility boundaries are clear.
Workflow
- Confirm the cost is justified. Identify the business policy, expected lifetime, change pressure, delivery mechanisms, infrastructure dependencies, and tests that need isolation. If these are weak, recommend a simpler design.
- Evaluate the existing architecture first. Inspect modules, dependencies, tests, framework conventions, and where business rules currently live. Do not recommend a rewrite or terminology change when healthy inward dependencies already exist.
- Choose the smallest scope. Apply Clean Architecture at a service, module, package, feature area, or bounded context. Do not reorganize the whole repository when one core workflow needs protection.
- Name the inner policy. Put enterprise/application business rules in domain objects and use cases. Keep controllers, ORM models, serializers, queue handlers, and UI components thin translators.
- Define boundaries from core needs. Create input/output boundaries, repository interfaces, gateways, presenters, or ports only where the use case needs a seam. Do not mirror a framework or SDK API inward.
- Map at the edges. Convert request DTOs, API payloads, database rows, persistence models, SDK objects, framework errors, and transport responses at adapter boundaries. Keep business decisions out of mapping code.
- Wire dependencies at the outside. Use dependency injection, composition roots, factories, or module wiring outside the core. The core should receive abstractions or simple functions, not construct infrastructure.
- Adopt incrementally. Move one use case or boundary at a time, protect it with tests, and leave stable code alone. Prefer strangling infrastructure leaks over broad directory reshuffles.
When implementation begins, load the matching language engineering skill and any data skill needed for persistence, schema, query, or transaction work.
Verification And Reporting
Before reporting completion, check the changed behavior and dependency direction at the affected policy and adapter boundaries, then run broader repository checks when the change warrants them. Report failures, skipped checks, and residual risk from unverified wiring, mappings, or dependency leaks.
Boundary and Data Guidance
- DTOs are boundary messages. They are not domain entities, ORM rows, API models, or view models unless the project has deliberately collapsed a boundary.
- Entities should not depend on persistence annotations, framework base classes, request/session objects, or database row shapes when those details can change independently of policy.
- Use case inputs should express what the use case needs, not the raw HTTP body, CLI args, queue payload, or UI form state.
- Use case outputs can be simple result DTOs, domain results, events, or an output port/presenter interface. Prefer the simplest shape that preserves inward dependencies and keeps presentation policy outside the use case.
- Repository and gateway abstractions should describe domain/application needs:
load_order_for_checkout,save_invoice, orreserve_credit, not generic table-shaped CRUD unless generic CRUD is truly the policy. - CQRS is optional. Split commands and queries when read and write concerns, models, scaling, authorization, or performance differ enough to justify it; do not add buses or handlers just to look architectural.
Testing Guidance
- Test entities and domain services directly for invariants, calculations, policies, and state transitions.
- Test use cases with fake or in-memory gateways, repositories, presenters, clocks, ID generators, and external-service ports.
- Test interface adapters against their real contracts: HTTP routing and serialization, database mappings and constraints, SQL, queue payloads, SDK error mapping, dependency-injection wiring, and framework integration.
- Add architecture/dependency tests when the language or tooling can enforce inward dependencies cheaply.
- Use end-to-end tests for critical wiring and behavior that narrower tests cannot prove; do not make E2E the only protection for business rules.
Organization Guidance
There is no universal folder structure. Choose a structure that makes dependency direction and domain intent visible in the target language:
- For small scoped adoption, organize by feature or bounded context first, then by inner policy versus adapters inside that scope.
- For ecosystems that favor projects/packages/modules, make compile-time dependencies enforce the dependency rule where practical.
- For framework-heavy apps, keep framework entry points at the edge and move only policy-heavy behavior behind use cases; do not fight every framework convention when the framework is intentionally the product shell.
- Prefer names from the domain and use cases over generic buckets like
helpers,managers, orserviceswhen the code represents business behavior.
Relationship To Other Architecture Skills
- Layered architecture: layered systems often separate UI, business, and data access by horizontal layers, but dependencies may point downward into data access. Clean Architecture inverts dependencies so business policy does not depend on data or framework details.
- Hexagonal Architecture: both protect the core with inward dependencies. Load
hexagonal-architecturewhen the main decision is ports/adapters around external actors, multiple drivers, swappable infrastructure, or running the core headless. Prefer Clean Architecture wording when the main decision is concentric policy/detail layers, use-case boundaries, interactors, presenters, and interface-adapter responsibilities. Either is fine when the current code already has healthy boundaries; do not rename architecture for terminology alone. - Onion Architecture: closely related; both place domain/application policy at
the center and infrastructure outside. Load
onion-architecturewhen the user asks for Onion by name or when domain/application rings are the clearest framing. Prefer Clean Architecture wording when use cases, interactors, presenters, and interface adapters are the clearer responsibilities. - DDD: DDD defines ubiquitous language, bounded contexts, aggregates, value
objects, repositories, domain services, and invariants. Load
domain-driven-designwhen the model and language need work; use Clean Architecture to protect that model and route use cases around it. - CQRS: CQRS can fit inside Clean Architecture when separate command and query models solve real complexity. It is not required, and it does not replace the dependency rule.
Agent Guidance
- Before recommending Clean Architecture, ask or infer: expected lifetime, business-rule complexity, delivery mechanisms, infrastructure volatility, testing pain, team familiarity, and whether the user wants architecture change or a local fix.
- Caution against Clean Architecture when the request is simple CRUD, a prototype, a framework tutorial, a one-off script, or a small change in an intentionally framework-centric app.
- Propose incremental refactors: extract one use case, introduce one boundary, isolate one external dependency, or move one business rule out of a controller. Avoid big-bang rewrites.
- Explain tradeoffs explicitly: more files, mapping, abstractions, and onboarding cost in exchange for clearer policy boundaries, testability, and replaceable details.
- Preserve repository conventions. Adapt vocabulary to the codebase instead of imposing Clean Architecture names everywhere.
Common Mistakes
- Treating Clean Architecture as folders named
domain,application,infrastructure, andpresentationwhile dependencies still point outward. - Adding interfaces for every class without a real boundary, alternate implementation, testing seam, or external mechanism to isolate.
- Putting business rules in controllers, ORM models, serializers, UI components, queue handlers, database triggers, or framework services by default.
- Letting use cases depend on HTTP, ORM, SQL, queue, session, UI, or SDK types.
- Passing database rows, active records, framework request objects, or external API payloads inward as if they were domain types.
- Confusing DTOs, entities, persistence models, API models, and view models.
- Creating an anemic domain model when rich domain behavior would protect invariants better.
- Applying the pattern uniformly across every feature regardless of complexity.
Successful Use
The final design names the protected business policy, use cases, entities/domain objects, boundary interfaces, adapters, mapping points, dependency direction, tests per boundary, and any deliberate decision to keep a simpler structure.
Source Anchors
- Robert C. Martin, The Clean Architecture.
- Alistair Cockburn, Hexagonal architecture.
- Jeffrey Palermo, The Onion Architecture.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

