hexagonal

Decouple business logic from infrastructure using ports and adapters.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/aitchwhy/dotfiles --skill hexagonal
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hexagonal
Source: https://github.com/aitchwhy/dotfiles/tree/main/config/quality/generated/skills/hexagonal
Command: npx skills add https://github.com/aitchwhy/dotfiles --skill hexagonal

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Isolates business logic from infrastructure via ports and adapters.

Core Features & Use Cases

  • Define ports with Context.Tag
  • Create adapters and test adapters
  • Run tests without mocks

Quick Start

Define a port and implement a live adapter; create a test adapter.

Frequently Asked Questions about hexagonal

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

FAQPage Schema
How do I decouple business logic from infrastructure in my application?

Hexagonal architecture decouples business logic from infrastructure by defining Ports as interfaces and implementing Adapters as interchangeable layers. This isolates core logic so storage, external services, and dependencies can swap without affecting business rules.

What's the difference between ports and adapters in hexagonal architecture?

Ports define contracts that business logic depends on, typically as Context.Tag interfaces. Adapters implement those contracts as Layer implementations—production adapters connect real infrastructure, while test adapters provide in-memory alternatives for testing without mocks.

How can I test my application without using mocks?

Hexagonal architecture enables mock-free testing by swapping production adapters with test adapters. Implement a test adapter that provides in-memory storage or stub services, inject it via dependency injection, and run tests against real business logic with predictable test data.

When should I use hexagonal architecture instead of layered architecture?

Use hexagonal architecture when your application requires stable core logic with interchangeable storage and external services. It suits systems where you need multiple implementations of the same dependency—such as different databases or payment providers—without modifying business logic.

Can I implement hexagonal architecture with dependency injection?

Yes. Hexagonal architecture is built on dependency injection principles. Define Ports as interfaces, create Adapter implementations, and inject the appropriate adapter at runtime. This enables switching between production and test adapters without code changes.

Does hexagonal architecture work for applications with external service integrations?

Yes. External services are implemented as Adapters behind Ports. Define a Port interface for the service contract, create a live Adapter that calls the real service, and a test Adapter that returns stub responses. Dependency injection swaps them as needed.