What does this skill do?

The Hexagonal Architecture Skill designs, implements, and refactors systems based on Ports and Adapters with clear domain boundaries and dependency inversion. It defines use cases with pure orchestration, output ports that model capabilities without being tied to specific technologies, and adapters that isolate infrastructure details. It generates testable designs with in-memory mocks in TypeScript, Java, Kotlin, and Go.

New, maintainable features
Build new features where long-term maintainability and testability are critical from the very first commit.
Refactoring Tightly Coupled Code
Decouples domain logic that is intertwined with I/O concerns and frameworks, separating transport from business rules.
One use case, multiple interfaces
It supports HTTP, CLI, queue workers, and cron jobs for the same use case without duplicating logic.
Infrastructure Replacement
Change the database, external APIs, or message bus without rewriting the domain's business rules.

Usage examples

🚀 New system
Design the hexagonal architecture for an order creation use case in TypeScript, including persistence and payment ports.
🧹 Refactor
Refactor this Express controller, which mixes domain logic with PostgreSQL access, by applying ports and adapters.
🔀 Multi-interface
Define the same payment processing user case so that it works via HTTP, CLI, and a queue worker without duplicating logic.
🔄 Change infrastructure
Replace the PostgreSQL adapter with a MongoDB adapter without changing the order creation use case.

Features

Use Case Boundary Modeling Define unique use cases with clear input and output DTOs, keeping transport details out of the scope.
Departure Ports by Capacity Identify each side effect as a port that models capabilities, not specific technologies.
Use Cases Involving Pure Orchestration The use case receives ports by constructor, validates invariants, and returns flat structures without being coupled to I/O.
Adapters on the edge Input and output adapters convert protocol contracts into application contracts without affecting the domain.
Centralized Root Composition Create adapter instances and inject them into the use cases at a single point, avoiding hidden service locators.

Frequently asked questions

The same applies to TypeScript, Java, Kotlin, and Go. Only the syntax and wiring style change; the Ports and Adapters pattern remains the same.
No. The skill generates framework-agnostic designs. The adapters are then implemented on top of the infrastructure you use (Express, Spring, etc.).
Using unit tests that inject fake ports into memory, without touching the actual infrastructure. The adapters are tested using integration tests, and the flows are tested using E2E tests.
Yes. The skill suggests a feature-based structure with folders named domain/application/adapters/composition, but you can adapt it to your project's conventions.
Hexagonal Architecture — Ports and Adapters with Claude AI

¿Prefieres escuchar el contenido? Genera la narración de audio con un clic.