hexagonal-architecture

Implements ports and adapters architecture patterns with dependency inversion and domain isolation.

Updated May 30, 2026
One-click install
npx skills add https://github.com/chloebrett/snitchos --skill hexagonal-architecture-chloebrett
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: hexagonal-architecture
Source: https://github.com/chloebrett/snitchos/tree/main/.claude/skills/hexagonal-architecture
Command: npx skills add https://github.com/chloebrett/snitchos --skill hexagonal-architecture-chloebrett

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Business logic often becomes tangled with frameworks, databases, and HTTP handlers, making code untestable and resistant to change. This Skill guides the implementation of hexagonal (ports and adapters) architecture so domain logic stays isolated from infrastructure and adapters can be swapped without touching the core. ## Core Features & Use Cases - Ports and Adapters Design: Define port interfaces in the domain layer and implement driven adapters (repositories, payment gateways) plus thin driving adapters (route handlers, queue consumers). - Testing Strategy: Test use cases with in-memory fakes instead of mocks, complement with domain unit tests, adapter integration tests, and E2E verification. - CQRS-Lite and Cross-Cutting Concerns: Separate read query functions from write repositories, and place auth, logging, transactions, and error formatting in the correct layer. - Use Case: When refactoring a route handler that queries the database, applies business rules, and returns a response all in one function, follow the incremental adoption guide to extract a pure domain function, a repository port, and a thin adapter step by step. ## Quick Start Apply the hexagonal architecture skill to refactor my route handler so business logic moves into the domain layer behind repository ports.

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 with ports and adapters?▼

Define port interfaces in the domain layer named by business purpose, then create driven adapters that implement them for specific technologies like databases or payment gateways. Driving adapters such as route handlers stay thin: parse input, wire adapters, call the use case, and translate the result.

How to test use cases in hexagonal architecture?▼

Test use cases by injecting in-memory fakes that implement the real port interfaces and maintain state. Fakes break at compile time when interfaces change and verify behavior rather than call sequences, unlike mocks.

Should reads go through repositories in hexagonal architecture?▼

Writes should go through repositories to enforce aggregate boundaries, but reads that JOIN across aggregates can use query functions living in the adapter layer. This CQRS-lite approach returns read-optimized DTOs while domain pure functions transform the data.

Where do authentication and logging belong in hexagonal architecture?▼

Authentication lives in driving adapters since it is protocol-specific, while authorization rules belong in the domain. Logging is an adapter concern on both sides; domain code never imports a logger and instead returns results that adapters inspect.

When should I not apply hexagonal architecture?▼

Do not apply it to projects without an explicit ports/adapters structure or to simple CRUD endpoints with no business logic, where the pattern adds overhead without benefit. Stable code that rarely changes is also a low-priority migration candidate.

How do I introduce hexagonal architecture into an existing codebase?▼

Use the strangler fig approach: pick one tangled route handler, extract the business rule into a pure domain function, define a port interface, wrap existing database access in an adapter, and thin out the handler. Migrate one boundary at a time and prove each with a fake-based use case test.