clean-architecture-microservices
Skill0 starsChanged 3 months agoMITView on GitHub
Clean Architecture and microservices design-pattern guidance for structuring maintainable services, defining bounded contexts, designing APIs and events, choosing service boundaries, and building resilient distributed systems. Use for architecture reviews, new service design, microservice decomposition, migration planning, or workflow diagrams.
In this repository3 other files it gives its agents.
- .claude/CLAUDE.mdCLAUDE.md
- senior-engineerSkill
- system-design-foundationSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 11 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Read references/pattern_catalog.md for pattern definitions, selection guidance, benefits, and failure modes.
- Very specific: line 13
Read references/design_workflows.md for the end-to-end architecture workflow and pattern combinations.
- Very specific: line 14
Read the .mmd and .png files in references/ when a workflow image or editable diagram source is needed.
- Very specific: line 15
Read references/visual_validation.md only when checking the generated diagram assets or updating them.
- Distinctive: line 21
Choose service boundaries: Prefer high cohesion and loose coupling.
- Distinctive: line 23
Structure each service: Keep domain entities and rules independent of frameworks.
- Distinctive: line 25
Choose interaction patterns: Use synchronous calls for immediate decisions within the latency budget.
- Distinctive: line 26
Design failure behavior: Add bounded timeouts, retry budgets with jitter, circuit breakers, bulkheads, idempotency, dead-letter handling, …
- Distinctive: line 28
Validate before expanding: Test architecture boundaries, contract compatibility, duplicate and out-of-order delivery, failure injection, …
- Distinctive: line 32
Keep dependencies pointing toward higher-level policy and domain rules.
- Distinctive: line 33
Keep a service cohesive around a business capability and its bounded context.
- Distinctive: line 34
Prefer one service owning a piece of data.
- Distinctive: line 35
Treat events as public contracts.
- Distinctive: line 36
Use a strangler migration or anti-corruption layer when replacing a legacy system.
- Distinctive: line 38
Do not introduce microservices when a modular monolith can meet the requirements with less operational complexity.
≈ “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
Clean Architecture & Microservices Design Patterns
Use this skill to design software boundaries deliberately at two levels: inside a service, keep business policy independent from infrastructure; between services, keep business capabilities cohesive, data ownership explicit, and communication contracts stable. Do not treat either Clean Architecture or microservices as mandatory. Select the smallest structure that satisfies changeability, team ownership, scale, reliability, and delivery constraints.
Load the right reference
- Read
references/pattern_catalog.mdfor pattern definitions, selection guidance, benefits, and failure modes. - Read
references/design_workflows.mdfor the end-to-end architecture workflow and pattern combinations. - Read the
.mmdand.pngfiles inreferences/when a workflow image or editable diagram source is needed. - Read
references/visual_validation.mdonly when checking the generated diagram assets or updating them.
Apply the design workflow
- Clarify the problem. Separate functional behavior from quality attributes such as latency, availability, deployability, security, operability, cost, and team autonomy. Record scope and exclusions.
- Analyze the domain. Identify business capabilities, actors, events, policies, subdomains, vocabulary, and the boundaries where a model or rule changes meaning.
- Choose service boundaries. Prefer high cohesion and loose coupling. Align services with business capabilities and ownership; do not split by technical layers such as “database service” or “messaging service.”
- Define data ownership. Give each service an authoritative data store or clearly named ownership boundary. Share contracts and events rather than tables. State transaction, consistency, retention, and migration rules.
- Structure each service. Keep domain entities and rules independent of frameworks; put use cases and application policies in the application layer; define ports for external capabilities; implement adapters for HTTP, persistence, messaging, and providers.
- Design contracts. Define REST/RPC APIs or events, schemas, versioning, compatibility, authentication, authorization, idempotency, pagination, timeouts, and error semantics. Prefer consumer needs over internal object shapes.
- Choose interaction patterns. Use synchronous calls for immediate decisions within the latency budget. Use events or queues for decoupling, burst absorption, replay, and eventual projections. Use orchestration or choreography deliberately for long-running workflows.
- Design failure behavior. Add bounded timeouts, retry budgets with jitter, circuit breakers, bulkheads, idempotency, dead-letter handling, health signals, and graceful degradation. Specify what happens when a dependency, broker, region, or data store fails.
- Make operations observable. Define logs, metrics, traces, correlation/context propagation, SLOs, alerts, audit events, deployment health checks, and ownership escalation paths.
- Validate before expanding. Test architecture boundaries, contract compatibility, duplicate and out-of-order delivery, failure injection, rollback, migration recovery, load, tail latency, and restore procedures.
Use these non-negotiable rules
- Keep dependencies pointing toward higher-level policy and domain rules; infrastructure and frameworks depend inward through ports or adapters.
- Keep a service cohesive around a business capability and its bounded context; avoid distributed monoliths that require synchronized releases or shared databases.
- Prefer one service owning a piece of data. If a cross-service transaction is unavoidable, state the consistency model and use a Saga, transactional outbox, or compensating action rather than pretending a local transaction spans the network.
- Treat events as public contracts. Define schema evolution, ordering, deduplication, replay, retention, and poison-message behavior.
- Use a strangler migration or anti-corruption layer when replacing a legacy system; do not leak legacy models into the new domain.
- Make resilience and observability part of the initial design, not a post-incident add-on.
- Do not introduce microservices when a modular monolith can meet the requirements with less operational complexity.
Produce architecture answers in this structure
- Context and assumptions. State the business goal, actors, constraints, workload, and unknowns.
- Domain model and boundaries. Show capabilities, bounded contexts, service ownership, and important aggregates or policies.
- Service structure. Explain the Clean Architecture layers, ports, adapters, dependency direction, and test seams.
- Contracts and data. Define APIs/events, versioning, ownership, transactions, consistency, idempotency, and migration rules.
- Interaction and workflow. Draw synchronous and asynchronous paths, including retries, timeouts, circuit breakers, and compensations.
- Operations and delivery. Cover deployment independence, configuration, secrets, observability, SLOs, rollback, and ownership.
- Trade-offs and alternatives. Explain why the chosen pattern is appropriate, what it costs, and when to simplify or split further.
- Validation plan. List contract, integration, load, failure-injection, migration, and disaster-recovery tests.
Diagram requirements
Use the bundled Mermaid sources for exact architecture relationships and render their PNG counterparts when an image is requested. Keep diagrams readable: show business boundaries, dependency direction, data ownership, communication mode, and resilience controls. Do not use decorative AI-generated diagrams for formal node-edge relationships. The included images are:
clean_architecture_dependency_flow.png: inward dependency flow from adapters and infrastructure toward application and domain policy.service_decomposition_workflow.png: domain analysis through bounded contexts, aggregates, service boundaries, contracts, and iterative evolution.resilient_microservice_flow.png: gateway, Clean Architecture services, owned databases, synchronous dependency protection, events, consumers, and observability.
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.

