book-clean-architecture
Skill0 starsChanged 4 months agoApache-2.0View on GitHub
Clean Architecture principles (dependency rule, boundaries, keeping business rules independent of frameworks and databases) to consult when designing or structuring code. Reference material, not a review. Use when the user asks about dependency direction, layering, or ports and adapters.
In this repository11 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- commit-conventionSkill
- pr-conventionSkill
- repo-setupSkill
- architecture-reviewSkill
- code-styleSkill
- comment-reviewSkill
- review-gateSkill
- book-legacy-codeSkill
- book-philosophy-of-software-designSkill
- book-refactoringSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
17 rules. About 0 are common, 16 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈16
Distinctive · estimate
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
- could be automatic: a setting could enforce it
- Distinctive: line 14
Use when adding, changing, reviewing, or refactoring code whose business rules should survive changes in frameworks, databases, delivery …
- Distinctive: line 18
Do not let details become the architecture.
- Distinctive: line 24
Put enterprise rules and invariants in entities or equivalent domain objects.
- Distinctive: line 26
Treat frameworks, databases, web delivery, messaging, filesystems, clocks, service clients, networks, devices, and vendors as outer-layer …
- Distinctive: line 28
Keep adapters humble. Controllers, endpoints, presenters, gateway adapters, service listeners, and hardware adapters translate external …
- Distinctive: line 31
Do not merge unrelated use cases or eliminate duplication when sharing would couple actors, change reasons, team ownership, deployment …
- Distinctive: line 32
Use structured code, dependency inversion, role-sized interfaces, substitutable implementations, controlled mutation, acyclic components, …
- Distinctive: line 34
Test entities, use cases, and boundary contracts first, without the real framework, database, network, external service, or target hardware.
- Distinctive: line 39
When urgent delivery would skip architecture, state the future change, test, replacement, or operational cost before accepting the shortcut.
- Distinctive: line 40
When framework annotations, request/response objects, serializers, ORM rows, schemas, vendor SDKs, config, environment reads, device …
- Distinctive: line 41
When controllers, jobs, handlers, views, presenters, gateways, repositories, SQL, service listeners, scripts, or hardware adapters contain …
- Distinctive: line 42
When a use case instantiates infrastructure, calls a volatile dependency directly, or depends on a concrete implementation, introduce a …
- Very specific: line 43
When a *Service, utility folder, shared module, base package, or generic core package becomes an escape hatch, split by use case, role, or …
- Distinctive: line 44
When an adapter bypasses a use case, a presenter reads persistence directly, or infrastructure is both imported by and importing inward …
- Distinctive: line 45
When service boundaries, process boundaries, remote calls, deployment boundaries, or embedded hardware appear, still verify source …
- Distinctive: line 46
When tests need the framework, database, network, service, or hardware to verify business rules, move tests to use cases/entities with …
- Distinctive: line 47
When a compromise is unavoidable, keep it at the outermost layer possible, document the violation, avoid normalizing it, and preserve a …
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- Vendored verbatim from ciembor/agent-rules-books (MIT License).
Source: https://github.com/ciembor/agent-rules-books/blob/main/clean-architecture/clean-architecture.mini.md
Third-party reference. Exempt from repo diction and prettier. -->OBEY Clean Architecture by Robert C. Martin
When to use
Use when adding, changing, reviewing, or refactoring code whose business rules should survive changes in frameworks, databases, delivery mechanisms, services, devices, vendors, deployment shape, or schedule pressure.
Primary bias to correct
Do not let details become the architecture. Business policy stays independent, dependencies point inward, and volatile mechanisms remain replaceable.
Decision rules
- Preserve independent business rules, inward dependencies, testability, and replaceable details even when the immediate feature would be shorter without them.
- Source dependencies must point inward toward higher-level policy. Domain and use cases must not import frameworks, databases, web handlers, queues, external service clients, UI types, or other details.
- Put enterprise rules and invariants in entities or equivalent domain objects; put application-specific orchestration in focused use cases.
- Pass plain request and response models across use-case boundaries. Do not pass web requests, framework contexts, ORM rows, database-bound structures, or framework response objects into or out of core policy.
- Treat frameworks, databases, web delivery, messaging, filesystems, clocks, service clients, networks, devices, and vendors as outer-layer details behind ports, gateways, presenters, mappers, or adapters.
- Inner layers own the interfaces they need; outer layers implement them. Object construction and concrete wiring belong in the composition root or other outer-layer main component.
- Keep adapters humble. Controllers, endpoints, presenters, gateway adapters, service listeners, and hardware adapters translate external formats to use-case calls and back; they do not own business decisions.
- Organize by use case, feature, or business capability before generic technical buckets. The structure should reveal domain intent and application actions.
- Choose boundaries by volatility, policy importance, substitution value, testability, and cost. Use the lightest enforceable boundary, including partial boundaries, when full deployment or runtime separation is too expensive.
- Do not merge unrelated use cases or eliminate duplication when sharing would couple actors, change reasons, team ownership, deployment needs, or release pressure.
- Use structured code, dependency inversion, role-sized interfaces, substitutable implementations, controlled mutation, acyclic components, and stability-directed dependencies to protect policy from volatile details.
- Enforce boundaries with package structure, dependency rules, build constraints, tests, visibility, or narrow APIs. A diagram, service split, package name, or shared
commonfolder is not enough. - Test entities, use cases, and boundary contracts first, without the real framework, database, network, external service, or target hardware. Test adapters separately at the seams.
- Preserve behavior while improving dependency direction. Prefer incremental boundary extraction over rewrites, and call out architectural debt when it cannot be fixed safely now.
Trigger rules
- When urgent delivery would skip architecture, state the future change, test, replacement, or operational cost before accepting the shortcut.
- When framework annotations, request/response objects, serializers, ORM rows, schemas, vendor SDKs, config, environment reads, device registers, or transport formats enter core policy, move translation outward.
- When controllers, jobs, handlers, views, presenters, gateways, repositories, SQL, service listeners, scripts, or hardware adapters contain business branching or validation, move the rule inward.
- When a use case instantiates infrastructure, calls a volatile dependency directly, or depends on a concrete implementation, introduce a policy-owned port and wire the concrete detail at the edge.
- When a
*Service, utility folder, shared module, base package, or genericcorepackage becomes an escape hatch, split by use case, role, or ownership and restore dependency direction. - When an adapter bypasses a use case, a presenter reads persistence directly, or infrastructure is both imported by and importing inward code, restore the intended boundary.
- When service boundaries, process boundaries, remote calls, deployment boundaries, or embedded hardware appear, still verify source dependencies, data ownership, I/O cost, and policy independence.
- When tests need the framework, database, network, service, or hardware to verify business rules, move tests to use cases/entities with fakes or add a stable boundary contract.
- When a compromise is unavoidable, keep it at the outermost layer possible, document the violation, avoid normalizing it, and preserve a path to separation.
Final checklist
- Business rules independent from frameworks, databases, UI, services, devices, and vendors?
- Dependencies point inward, with ports owned by inner policy and concrete details outside?
- Entities guard invariants and focused use cases orchestrate one application action?
- Boundaries explicit and enforced in code, tests, packages, or build rules?
- Controllers, presenters, gateways, service listeners, and adapters humble?
- Structure reveals use cases and business capabilities instead of generic technical buckets?
- Core tests run fast without real delivery, persistence, network, external service, or hardware?
- Details remain replaceable without rewriting business rules?
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.

