hexagonal-architecture

Designs and refactors Ports and Adapters systems with decoupled domain logic across TypeScript, Java, Kotlin, and Go.

Updated Mar 18, 2026
One-click install
npx skills add https://github.com/freedom909/real-estate-saas --skill hexagonal-architecture-freedom909
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: hexagonal-architecture
Source: https://github.com/freedom909/real-estate-saas/tree/main/.trae/skills/hexagonal-architecture
Command: npx skills add https://github.com/freedom909/real-estate-saas --skill hexagonal-architecture-freedom909

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Business logic often becomes tangled with frameworks, databases, and transport layers, making code hard to test, maintain, and migrate. This Skill guides you to separate domain rules from infrastructure using the Ports and Adapters pattern. ## Core Features & Use Cases - Boundary Design: Define use cases with explicit input/output DTOs, inbound ports, and outbound ports for every side effect like repositories, gateways, and clocks. - Multi-Language Guidance: Apply the same dependency-inversion rules in TypeScript, Java, Kotlin, and Go with language-specific package layouts and wiring styles. - Migration Playbook: Refactor legacy systems slice-by-slice using the strangler approach, facade-first wrapping, and characterization tests instead of big-bang rewrites. - Use Case: When a controller mixes SQL queries, Stripe calls, and business rules, use this Skill to extract a CreateOrderUseCase with OrderRepositoryPort and PaymentGatewayPort interfaces, then wire adapters in a single composition root. ## Quick Start Ask the AI to refactor a tightly coupled service or endpoint into a hexagonal architecture with explicit ports, adapters, and a composition root.

Frequently Asked Questions about hexagonal-architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement hexagonal architecture in TypeScript?▼

Define port interfaces in application/ports, implement use cases with constructor injection of those ports, and place concrete adapters in adapters/inbound and adapters/outbound. Wire everything in an explicit composition root factory module without hidden globals.

How to refactor legacy code into ports and adapters?▼

Use the strangler approach: pick one vertical slice, extract a use case boundary with explicit input/output types, wrap existing infrastructure behind outbound ports, and keep old adapters delegating to the new use case. Add characterization tests before extraction and migrate slice-by-slice.

What is the difference between inbound and outbound ports?▼

Inbound ports are contracts describing what the application can do, such as command and query interfaces called by controllers. Outbound ports are contracts for dependencies the application needs, like repositories, payment gateways, and event publishers, implemented by infrastructure adapters.

Does hexagonal architecture work with Spring or Go?▼

Yes, the same boundary rules apply across ecosystems. In Java use packages like application.port.in and adapter.out with Spring config wiring, while in Go define small interfaces owned by the consuming application package and wire constructors in main.go.

When should I not use hexagonal architecture?▼

Avoid it for simple CRUD scripts or prototypes where the overhead of ports, adapters, and composition roots outweighs maintainability benefits. It pays off when you need multiple interfaces, replaceable infrastructure, or long-term testability of business rules.

How do I test use cases in hexagonal architecture?▼

Unit test use cases with in-memory fakes or stubs for outbound ports, asserting business outcomes and port interactions. Separately run adapter integration tests against real infrastructure and contract test suites shared across adapter implementations.