hexagonal-architecture/SKILL.md
Enforces Hexagonal Architecture (Ports and Adapters) principles including driving and driven ports, adapter separation, and technology-agnostic core design. Use when structuring application boundaries, defining port interfaces, implementing adapters for databases or external APIs, testing business logic in isolation, or comparing hexagonal with onion and clean architecture approaches.
npx skillsauth add kayaman/skills hexagonal-architectureInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Reference: Hexagonal Architecture Explained (Cockburn & Garrido de Paz), Get Your Hands Dirty on Clean Architecture (Hombergs)
Alistair Cockburn published the pattern in 2005 (roots back to 1994). The hexagon shape was chosen to break away from layered stack diagrams — it is not about the number six.
Core intent: "Allow an application to equally be driven by users, programs, automated tests, or batch scripts, and to be developed and tested in isolation from its eventual run-time devices and databases."
Fundamental rule: The application core defines ALL port interfaces. Adapters depend on ports. The core MUST NOT depend on adapters.
Ports are interfaces belonging to the application core — they are NOT a separate layer.
Interfaces the application exposes for external actors to call INTO the application.
ForPlacingOrders, ForManagingInventory, ForQueryingReportsInterfaces the application requires from external systems — what the application needs but does not implement.
ForStoringOrders, ForSendingNotifications, ForFetchingExchangeRatesForStoringOrders not DatabasePort)Adapters are concrete implementations that connect ports to the outside world.
Translate external input into calls on driving ports. They call INTO the application.
| Adapter Type | Example | Translates From |
|-------------|---------|-----------------|
| REST Controller | OrderController | HTTP request → PlaceOrderCommand |
| CLI Handler | ImportCli | Command-line args → ImportDataCommand |
| Message Consumer | OrderEventListener | Queue message → ProcessPaymentCommand |
| Test Harness | OrderAcceptanceTest | Test setup → direct port method calls |
| GraphQL Resolver | OrderResolver | GraphQL query → port method call |
Implement driven port interfaces. The application calls THROUGH them.
| Adapter Type | Example | Connects To |
|-------------|---------|-------------|
| SQL Repository | PostgresOrderRepository | Database via SQL/ORM |
| REST Client | ExchangeRateApiClient | External HTTP API |
| Message Publisher | RabbitMqNotificationSender | Message broker |
| File Storage | S3DocumentStore | Object storage |
| In-Memory Stub | InMemoryOrderRepository | HashMap (for tests) |
PostgresOrderRepository with MongoOrderRepository requires no core changesThe hexagon's interior contains all business logic, free from infrastructure concerns:
core/
domain/
model/ # Entities, Value Objects, Aggregates
service/ # Domain services (stateless business rules)
application/
port/
driving/ # Driving port interfaces (ForPlacingOrders)
driven/ # Driven port interfaces (ForStoringOrders)
service/ # Application services (use case orchestration)
The hexagonal architecture's primary advantage is testability through adapter substitution.
| Phase | Driving Adapter | Driven Adapter | Tests | |-------|----------------|----------------|-------| | 1. Unit/Domain | Test harness | In-memory stubs | Business rules in isolation | | 2. Integration | Test harness | Real infrastructure | Port contract verification | | 3. Acceptance | HTTP/CLI test client | In-memory stubs | End-to-end behavior without infrastructure | | 4. System | HTTP/CLI test client | Real infrastructure | Full stack verification |
All three share the same DNA: business logic at center, dependencies point inward, DIP at architectural level.
| Aspect | Hexagonal | Onion (Palermo, 2008) | Clean (Martin, 2012) | |--------|-----------|----------------------|---------------------| | Internal structure | Least prescriptive — core is a single hexagon | Explicit concentric layers: Domain Model → Domain Services → Application Services | Four named layers with defined responsibilities | | Terminology | Ports and Adapters | Layers and Interfaces | Entities, Use Cases, Interface Adapters, Frameworks | | Unique contribution | Symmetry between driving and driven sides; ports as first-class concept | Explicit domain service layer separation | Screaming Architecture, Humble Object, component principles | | Best for | Teams wanting flexibility in internal organization | Teams wanting explicit domain layer separation | Teams wanting comprehensive architectural rules |
| Pitfall | Remedy | |---------|--------| | Ports as a separate layer | Ports belong to the core — they ARE the core's boundary, not a layer between core and adapters | | Adapter with business logic | Move logic to domain or application service; adapter does translation only | | Core importing adapter | Invert the dependency — core defines the interface, adapter implements it | | Technology in port signatures | Express ports in domain language; convert technology types in the adapter | | One giant port per side | Split into focused ports by actor/concern; one port per interaction boundary | | Over-engineering simple apps | Hexagonal adds value when multiple adapters or testability are genuinely needed |
When designing or reviewing a hexagonal architecture, verify:
| Book | Author(s) | Publisher | Year | |------|-----------|-----------|------| | Hexagonal Architecture Explained | Alistair Cockburn, Juan Manuel Garrido de Paz | Addison-Wesley | 2024 | | Get Your Hands Dirty on Clean Architecture (2nd ed.) | Tom Hombergs | Packt | 2023 | | Fundamentals of Software Architecture | Mark Richards, Neal Ford | O'Reilly | 2020 | | Software Architecture: The Hard Parts | Ford, Richards, Sadalage, Dehghani | O'Reilly | 2021 |
tools
Guidance for designing charts, graphs, plots, dashboards, and data visualizations that communicate clearly and persuade. Use when creating or reviewing a visualization, choosing a chart type, picking a color palette, decluttering a busy graphic, fixing misleading axes or proportions, building a dashboard, annotating a figure, or turning data into a presentation, report, or data-driven story. Grounded in the standard data-visualization literature (Knaflic, Tufte, Cleveland & McGill, Cairo, Wilke, Munzner, Few, Berinato). Covers chart selection, graphical perception and encoding, color and accessibility, decluttering, graphical integrity, dashboards, and narrative. Does NOT cover building data pipelines or ETL, statistical modeling or analysis methods, BI tool/vendor selection, or general UI/UX layout (see ux-design-principles). Tool-agnostic, with optional Python recipes.
development
Architect and implement production-grade microservices systems in TypeScript (NestJS) and Python (FastAPI), including resilience, observability, testing, deployment, and migration guidance.
development
--- name: databricks-genie-spaces-best-practices description: Design, configure, curate, govern, monitor, and integrate Databricks AI/BI Genie Spaces — the natural-language-to-SQL surface over Unity Catalog. Covers space scoping, general instructions, parameterized example SQL, SQL functions, trusted assets, JOIN configuration, knowledge store, certified queries, benchmarks, monitoring tab, feedback loops, the Genie Conversation API, governance via Unity Catalog (row filters, column masks, embed
tools
Implement OTP and passwordless authentication on AWS for TypeScript projects using Cognito CUSTOM_AUTH triggers (default) or a custom DynamoDB-backed flow, with SES (email) and SNS (SMS) delivery. Use when the user mentions OTP, one-time password, passwordless login, magic link, Cognito custom auth, DefineAuthChallenge, CreateAuthChallenge, VerifyAuthChallengeResponse, SES verification email, SNS SMS code, or MFA over email/SMS. Covers architecture decision (Cognito vs custom), Lambda trigger handlers, SES/SNS notifiers, DynamoDB schema with TTL, rate limiting, constant-time comparison, threat model (enumeration, replay, brute force), and aws-sdk-client-mock testing.