/system-design:hexagonal-architecturefrom system-design
Enforces hexagonal (ports and adapters) architecture in opted-in repositories: inside/outside zones, application-owned ports, thin adapters, composition roots, and stateful-fake testing.
Ships in system-design. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Before applying any pattern in this skill, verify that the repository or user has explicitly opted into hexagonal architecture:
README, AGENTS.md, CLAUDE.md, Architectural Decision Record (ADR), or explicit user request stating that the project uses or adopts hexagonal (ports and adapters) architecture.test-seams for breaking a hidden dependency or to architect for general module boundaries.tdd, never instead of it.Follow these mandatory safeguards on every change in an opted-in codebase.
Any client, request model, or data-transfer object (DTO) exported by a third-party package or the repository's SDK folder is outside the hexagon. Every file that imports it — including type-only imports — is outside the hexagon.
principle-hide-representations).principle-keep-the-core-pure). Adapters receive finished values and translate them to technology shapes.For<Verb>ing<Noun>, such as ForPlacingOrders or ForSendingReceipts).OrderRepository, PaymentGateway, ReceiptSender) or keep the repository's existing For... convention if it already uses one.principle-parse-at-the-boundary), invokes the driving port, and translates the result.principle-test-behavior-not-implementation). Test each adapter separately at its real technology boundary.When you touch an inside file that still imports a vendor package or the repository's SDK folder, porting all of its SDK dependencies is part of the change, not scope creep.
Preserve the repository's existing layout for inside code when physical restructuring is out of scope. Adapters and fakes are first-party code: place them beside the feature they serve or in an adapters/ or testing/ location, never inside a folder that holds third-party SDK clients.
Use-case tests must contain no mocking-framework helpers (no spy, stub, or module-mock calls) and no imports from vendor SDK folders. Build a hand-written stateful or recording fake for each driven port and assert observable outcomes and recorded state. When you touch an existing use-case test that mocks SDK clients, replace those mocks with fakes of the declared ports rather than extending them.
Hexagonal architecture defines two zones only: inside and outside. Dependencies point strictly inward.
Driving (left) Driven (right)
+-----------------------+ +-----------------------+
| HTTP / UI / CLI / | | Persistence / APIs / |
| Queue / System Intent |---+ +---| Messaging / Hardware |
+-----------------------+ | | +-----------------------+
calls into ---> +------+ <--- implements
|INSIDE|
|Domain|
|& App |
+------+
| Role | Zone | Responsibility |
|---|---|---|
| Domain policy | Inside | Pure business rules, domain types, state transitions; zero framework, clock, ID-generator, UI, or I/O dependencies |
| Application policy | Inside | Use-case orchestration implementing driving ports and calling driven ports; zero concrete I/O |
| Port contracts | Inside | Provided (driving) and required (driven) contracts owned by their innermost consumer |
| Driving adapters | Outside | Parse untrusted input, authenticate, invoke driving ports, translate results |
| Driven adapters | Outside | Implement driven ports and translate between domain types and external technology |
| Test interactors | Outside | Test drivers calling driving ports and stateful fakes implementing driven ports |
| Composition root | Executable host | Constructs concrete adapters and wires them into use cases |
Vocabulary:
PaymentGateway, not StripeClient or HttpPaymentPort). If swapping a vendor forces a port rename, infrastructure leaked into the name.I prefixes, Interface suffixes, Port suffixes, UseCase/Handler suffixes, and Impl suffixes.principle-make-operations-idempotent).| Concern | Owner | Rule |
|---|---|---|
| Authentication (who are you?) | Driving adapter | Verify credentials or session at the edge; pass a provider-free authenticated principal inward |
| Authorisation (are you allowed?) | Domain / application | Evaluate permissions as business rules on domain data and the authenticated principal |
| Untrusted input schema parsing | Driving adapter | Parse transport syntax and boundary schemas at the edge (principle-parse-at-the-boundary) |
| Business invariant validation | Domain | Validate business rules on typed domain values and return explicit domain results |
| Technical telemetry and correlation | Adapters / decorators | Log request cycles, timings, and trace IDs outside; domain never imports a logger or sees a trace ID |
| Domain-significant observations | Driven Domain Probe port or domain events | Announce business-significant facts through a severity-free, fire-and-forget driven port (or existing domain event publisher); test with recording fakes |
| Transactions | Application port + driven adapter | Application declares what must persist atomically; driven adapter owns transaction mechanics; domain stays unaware |
| Error formatting | Driving adapter | Map domain result reasons to protocol status codes or UI feedback |
I.../...Port/...UseCase/...Impl names.log(level, message) port inward or widening domain return types only to smuggle telemetry data out.Apply these local principles rather than repeating their theory here:
principle-keep-the-core-pure — keep business decisions in pure functions behind thin shells.principle-hide-representations — keep vendor, wire, storage, and framework shapes outside port boundaries.principle-parse-at-the-boundary — validate untrusted external input at driving and driven edges.principle-test-behavior-not-implementation — assert observable behaviour and state through ports, not mock call choreography.principle-make-operations-idempotent — design retried writes and external effects to converge safely.Name every applicable companion skill explicitly in your design, plan, or handover, and route neighbouring concerns to their owning skill:
codebase-layout — designing or changing the physical directory, workspace, package, or target layout and enforcing import direction automatically.test-seams — breaking hidden dependencies in non-opted-in repositories or untestable legacy code to get characterisation tests running before deciding whether to extract durable ports.tdd — running the Red-Green-Refactor cycle (load alongside hexagonal-architecture, never instead of it).swiftui-architecture — SwiftUI view state ownership, @Observable services via .environment, and zero-ViewModel rules on iOS.app-intent-driven-development — AppIntent driving adapters, AppEntity parameters, and @AppDependency wiring on iOS.swift-testing — authoring Swift Testing suites (@Test, #expect, #require, isolated fixtures).react-testing — authoring React Testing Library tests for web frontend driving adapters.Load only the reference matching your current task:
| Reference | Load when... |
|---|---|
references/greenfield-and-adoption.md | Starting a hexagonal project from scratch (4-wiring sequence, Walking Skeleton) or adopting hexagonal architecture incrementally (Strangler Fig steps and priority matrix) |
references/testing-and-probes.md | Designing the port test wall, stateful fakes vs mocks, shared adapter contract suites, swappability validation, or 4-tier Domain Probe observability |
references/cqrs-lite-and-transactions.md | Building a backend service where reads join across aggregates (CQRS-lite) or writes require atomic multi-row/outbox transactions and optimistic concurrency |
references/typescript-backend.md | Implementing or reviewing a TypeScript/Node backend feature with driving/driven ports, boundary schema parsing, driven adapters, composition root, and stateful fakes |
references/typescript-frontend.md | Implementing or reviewing a React/web frontend feature with UI/router driving adapters, API/storage driven ports, root composition, and stateful fakes |
references/swift-ios.md | Implementing or reviewing a Swift 6 / SwiftUI / App Intents iOS feature with local Swift Package targets, pure domain vs pragmatic SwiftData core, earned Sendable ports, AppGraph, and Swift Testing fakes |
references/cqrs-lite-and-transactions.md (opens in a new tab)references/greenfield-and-adoption.md (opens in a new tab)references/swift-ios.md (opens in a new tab)references/testing-and-probes.md (opens in a new tab)references/typescript-backend.md (opens in a new tab)references/typescript-frontend.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub mintuz/skills --plugin system-design5 skills in this plugin
/architecture-auditWHEN auditing an existing repository or multi-module subsystem to discover and rank bounded architectural hotspots and decide where investment pays off now; NOT for designing one already-selected module contract (architect), auditing physical directory, package or build-target layout and import enforcement (codebase-layout), breaking hidden dependencies in untestable code (test-seams), simplifying one chosen path (reducer), or editing code (refactoring); returns a read-only Markdown and Mermaid report with qualitative ranking, confidence, counterevidence and next-skill handovers.
/codebase-layoutWHEN designing, auditing, or migrating physical source trees, packages, build targets, placement rules, or import-direction enforcement; NOT for one module's logical types and caller contract (architect), repository-wide architecture hotspot triage (architecture-audit), or semantic ports-and-adapters rules (hexagonal-architecture); produces an evidence-backed layout, dependency rules, proportionate enforcement, and a staged migration plan.
/mermaid-generatorWHEN creating Mermaid diagrams from code or architecture; NOT for diagrams without a code or system-design source; analyzes the relevant structure and returns a scoped, renderable diagram with evidence and assumptions.
/twelve-factorWHEN configuring, auditing, or refactoring deployable service or app operational boundaries—deploy-time configuration and secrets, backing services, process startup and graceful shutdown, structured logging, dev/prod parity, or one-off admin tasks; NOT for pure UI styling, internal logic refactoring, or domain design with no deployment or operational boundary; applies the twelve factors through an upfront platform applicability gate so server-only rules never misapply to edge functions or client apps.Other plugins' skills for the same job