Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Guides design and implementation of evolutionary modular-monolith platforms with DDD (strategic + tactical), flat-by-aggregate organization, an Anti-Corruption Layer for vendor independence, a transactional outbox for events, smart resilience (backoff with jitter, circuit breakers, idempotency), and a polished architecture HTML document with elegant SVG diagrams. Use when designing a platform or backend, defining bounded contexts, organizing modules and folders, choosing monolith vs microservice
.claude/skills/tech-leads-club-evolutionary-modular-architecture/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 74% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 91% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 118% | 0% |
| case-18 | ✗→✓ | ▲ Improved | 60% | 0% |
| case-08 | ✓→✓ | = Same ✓ | 156% | 0% |
Design and build platforms as an evolutionary modular monolith: strong logical boundaries from day one (DDD bounded contexts, flat-by-aggregate modules, an Anti-Corruption Layer around every external system, event-driven communication, resilience by default) while keeping physical boundaries (separate deploys, separate databases) as a later, optional step. Start simple, evolve granularity only when the product and the team justify it — never reverse-engineer microservices from hype.
nestjs-modular-monolith.tactical-ddd.Separate the logical boundary (always strong) from the physical boundary (evolutionary). Modules, contracts, state ownership, and the Anti-Corruption Layer are non-negotiable from day one. Whether a module is its own deploy or its own database is an operational decision made later — never a structural prerequisite. This is what lets the system start as one deploy and grow without a rewrite.
A useful mental image: the house has well-divided rooms (modules). Inside each room things sit out in the open, grouped by what they are for (flat-by-aggregate) — not buried in nested drawers (technical-layer folders). The floor plan (boundaries) is what matters most.
| Topic | What it covers | Reference | | --- | --- | --- | | Principles | 10 modular (P1–P10) + 9 structural (P11–P19) + conflict hierarchy | references/principles.md | | DDD | Strategic (subdomains, context map, integration patterns) + tactical (rich aggregates, intensity by subdomain) | references/ddd.md | | Module internals | Flat-by-aggregate, suffixes, depth, flat vs subdomain test, scaffolding | references/flat-by-aggregate.md | | Communication | Ports & Adapters / ACL, events + transactional outbox, SSE real-time | references/acl-and-communication.md | | Resilience | Backoff + full jitter, circuit breaker, retry budget, idempotency, bulkhead, timeouts | references/resilience.md | | Stack 2026 | Frontend, backend, data, observability, durable workflow, decisions | references/stack-2026.md | | Architecture doc | Building the elegant, self-contained HTML architecture document with SVG diagrams | references/architecture-doc.md + assets/architecture-template.html | | Validation | Deterministic checks for structure and module boundaries | scripts/validate-structure.mjs, scripts/validate-boundaries.mjs |
Do not load all references at once. Read a reference only when the current phase needs it (the workflow below states when).
Use this whether you are designing a new system or reviewing an existing one. Move through phases in order; each has an exit criterion. State assumptions explicitly; if the domain is unclear, ask before guessing.
Confirm: is this a new platform, a new module in an existing one, or a review? Confirm the runtime/stack constraints (default target is the 2026 TypeScript stack — see references/stack-2026.md). Default to one deploy (modular monolith) unless a hard constraint says otherwise.
Exit: scope and constraints written down.
Read references/ddd.md. Identify subdomains from the business language, classify each as Core, Supporting, or Generic, and find the ubiquitous language of each. Do not group by technical layer. If multiple bounded-context interpretations exist, present them — do not pick silently.
Exit: a list of candidate bounded contexts, each classified, with one-line responsibility and key aggregates.
Draw the context map: which contexts exist, how they relate (Customer/Supplier, Conformist, Open Host Service, Published Language, Shared Kernel, Anti-Corruption Layer), and which are Core. Decide state ownership: one database is fine, but each module is the sole writer of its own tables — no foreign keys across module boundaries; reference other contexts by id. Keep aggregates cohesive (do not over-split a transactional Core).
Exit: context map + table-ownership map (one module = its tables).
Read references/flat-by-aggregate.md. Inside each module, organize by aggregate, not by technical layer: 1 business concept = 1 folder; technical layers become file suffixes (.entity.ts, .service.ts, .controller.ts). Keep depth ≤ 2 (flat) or ≤ 3 (subdomain-based). The Clean Architecture dependency rule still holds (presentation → application → domain ← infrastructure) — it is just expressed by suffixes and co-location, not by layer folders. Use the 6-criteria test to decide flat vs subdomain-based; default to flat.
Exit: a folder layout per module and a flat-vs-subdomain decision with rationale.
Read references/acl-and-communication.md. Every external system goes behind a Port + Adapter (ACL) — including internal services owned by other teams. The domain defines ports in its own language; adapters translate the external model in and out. Between internal modules: synchronous only inside an aggregate (one ACID transaction); events via the transactional outbox across modules, with idempotent consumers. Add SSE for server-to-client real-time when the UX needs push.
Exit: list of ports + adapters; list of domain events with the module.aggregate.action naming; sync-vs-async decisions.
Read references/resilience.md. Wrap every external/inter-service call: timeout → circuit breaker → retry (capped exponential backoff + full jitter). Only retry idempotent operations (require an idempotency key for writes). Cap retries with a budget (~10% of traffic), trip the breaker on a sliding-window error rate, and give every breaker a named fallback. Add durable execution only when a long-running, multi-step process must survive restarts.
Exit: a resilience policy applied to each adapter, plus idempotency keys for writes.
Read references/stack-2026.md. Choose the concrete stack and call out the trade-offs (runtime, API style, cache, real-time transport). Then state the evolution path: stage 1 (modular monolith + clear boundaries, with events/outbox already in place) is the current state; promote a module to its own app/database only when its own metrics justify it.
Exit: stack table + evolution note.
Produce a polished, self-contained HTML architecture document with elegant hand-drawn-style SVG diagrams. Read references/architecture-doc.md and start from assets/architecture-template.html: copy the template, keep its CSS and visual system intact, and replace the placeholder content. Build the standard sections (overview, domains, principles, monolith map, bounded contexts, ACL, communication, front-to-back, modules, resilience, real-time, evolution, stack) and number diagrams sequentially ("Diagram N — ..."). Preserve the visual identity: palette, Lato + JetBrains Mono fonts, rounded rectangles, arrow markers, soft gradients, and italic captions. The output is one HTML file that opens directly in a browser — no build step.
Exit: a single self-contained HTML file with consistent diagrams and working in-page navigation.
references/ddd.md.references/flat-by-aggregate.md.enforce-module-boundaries).Make the principles executable instead of relying on review. Run these in CI and before merge (both are zero-dependency Node ESM scripts; pass the libs/packages root, or let them autodetect):
node scripts/validate-structure.mjs [root] — enforces flat-by-aggregate (P11–P17): no technical-layer folders, no single-file folders (except __test__/), depth ≤ 3, no README inside aggregates.node scripts/validate-boundaries.mjs [root] — enforces modular boundaries (P1, P3, P8): no deep cross-module imports (only via barrel/facade), no duplicate or unprefixed entity names, no cross-context relations.Both exit non-zero on violation and print the offending paths. Treat structural failures as blocking; treat boundary findings as blocking once the team adopts the convention.
User says: "Desenhe a arquitetura de uma plataforma de contas a pagar que lança no ERP do cliente." Actions:
Result: a context map, module layouts, a port/adapter list, a resilience policy, and a stack + evolution plan — each grounded in the matching reference.
User says: "Como organizo o módulo de billing?" Actions: read references/flat-by-aggregate.md; propose billing/subscription/, billing/invoice/, billing/payment/ with co-located files and __test__/; run the 6-criteria test (billing = flat). Result: a flat folder tree with rationale and the dependency rule preserved via suffixes.
User says: "Não quero ficar preso ao OMIE." Actions: read references/acl-and-communication.md; define ErpLedgerPort in domain language; implement OmieAdapter; translate the OMIE model at the boundary; show that swapping ERPs means swapping the adapter. Result: a port interface + adapter plan; the domain never imports vendor types.
core/service/, http/controller/, persistence/entity/) inside a module — that is the legacy pattern flat-by-aggregate replaces.| Load this file | When | | --- | --- | | references/principles.md | You need the exact principle text, or to resolve a structural-vs-modular conflict. | | references/ddd.md | Phase 1–2: classifying subdomains, drawing the context map, deciding tactical intensity. | | references/flat-by-aggregate.md | Phase 3: laying out a module; flat vs subdomain; scaffolding; facades; tests. | | references/acl-and-communication.md | Phase 4: ports/adapters/ACL, events + outbox, SSE. | | references/resilience.md | Phase 5: backoff/jitter, circuit breaker, idempotency, bulkhead, durable execution. | | references/stack-2026.md | Phase 0/6: concrete stack choices and trade-offs. | | references/architecture-doc.md + assets/architecture-template.html | Phase 7: producing the HTML architecture document and its diagrams. | | scripts/validate-structure.mjs, scripts/validate-boundaries.mjs | Validation: enforcing structure and module boundaries in CI or before merge. |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-08 | pass→pass | 17,991 | 24,043 | +34% | 1 | 1 | 0% | 2,907 | 7,435 | +156% | 0 | 0 | — |
case-01 | fail→fail | 32,715 | 33,293 | +2% | 1 | 1 | 0% | 6,247 | 9,542 | +53% | 0 | 0 | — |
case-02 | fail→pass | 23,714 | 23,566 | -1% | 1 | 1 | 0% | 4,681 | 8,125 | +74% | 0 | 0 | — |
case-03 | fail→fail | 20,221 | 24,981 | +24% | 1 | 1 | 0% | 3,806 | 8,315 | +118% | 0 | 0 | — |
case-04 | pass→pass | 15,465 | 9,808 | -37% | 1 | 1 | 0% | 2,839 | 5,162 | +82% | 0 | 0 | — |
case-05 | fail→pass | 14,952 | 8,345 | -44% | 1 | 1 | 0% | 2,487 | 4,747 | +91% | 0 | 0 | — |
case-06 | pass→pass | 14,799 | 13,888 | -6% | 1 | 1 | 0% | 2,602 | 5,824 | +124% | 0 | 0 | — |
case-07 | fail→pass | 16,582 | 52,621 | +217% | 1 | 1 | 0% | 2,816 | 6,150 | +118% | 0 | 0 | — |
case-09 | pass→pass | 32,634 | 8,743 | -73% | 1 | 1 | 0% | 1,979 | 4,763 | +141% | 0 | 0 | — |
case-10 | pass→pass | 9,310 | 9,624 | +3% | 1 | 1 | 0% | 1,669 | 5,056 | +203% | 0 | 0 | — |
case-11 | pass→pass | 12,941 | 7,632 | -41% | 1 | 1 | 0% | 2,071 | 4,533 | +119% | 0 | 0 | — |
case-12 | fail→fail | 12,116 | 15,328 | +27% | 1 | 1 | 0% | 2,045 | 5,259 | +157% | 0 | 0 | — |
case-13 | pass→pass | 16,581 | 40,187 | +142% | 1 | 1 | 0% | 3,070 | 5,714 | +86% | 0 | 0 | — |
case-14 | pass→pass | 15,656 | 11,712 | -25% | 1 | 1 | 0% | 2,461 | 5,421 | +120% | 0 | 0 | — |
case-15 | pass→pass | 11,892 | 11,079 | -7% | 1 | 1 | 0% | 2,028 | 5,012 | +147% | 0 | 0 | — |
case-16 | pass→pass | 14,401 | 9,164 | -36% | 1 | 1 | 0% | 2,273 | 4,673 | +106% | 0 | 0 | — |
case-17 | fail→fail | 18,826 | 11,316 | -40% | 1 | 1 | 0% | 3,123 | 5,269 | +69% | 0 | 0 | — |
case-18 | fail→pass | 17,122 | 7,511 | -56% | 1 | 1 | 0% | 2,952 | 4,724 | +60% | 0 | 0 | — |
case-19 | pass→pass | 10,601 | 5,088 | -52% | 1 | 1 | 0% | 1,581 | 4,154 | +163% | 0 | 0 | — |
case-20 | pass→pass | 53,602 | 5,939 | -89% | 1 | 1 | 0% | 1,556 | 4,268 | +174% | 0 | 0 | — |
case-21 | pass→pass | 11,108 | 12,385 | +11% | 1 | 1 | 0% | 2,280 | 5,752 | +152% | 0 | 0 | — |
case-22 | pass→pass | 14,460 | 14,870 | +3% | 1 | 1 | 0% | 2,784 | 6,210 | +123% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +18 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.