Skip to content
Skills Library
Programming · Planning

hexagonal-architecture

/hexagonal-architecture

Design with ports and adapters to separate business logic from infrastructure. Use when designing a new service, reviewing structural compliance, or deciding how to introduce a new external dependency without coupling the domain.

Licence
MIT
Last repository change
14.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 14.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Design with ports and adapters to separate business logic from infrastructure. Use when designing a new service, reviewing structural compliance, or deciding how to introduce a new external dependency without coupling the domain.

Original author description

Design with ports and adapters to separate business logic from infrastructure. Use when designing a new service, reviewing structural compliance, or deciding how to introduce a new external dependency without coupling the domain.

How it works

  1. Overview
  2. Core Concepts
  3. Project Structure
  4. Steps
  5. Output
  6. Constraints
  7. Guidelines
Original SKILL.md headings · 80 lines, 512 words
SKILL.md preview
---
name: hexagonal-architecture
description: Design with ports and adapters to separate business logic from infrastructure. Use when designing a new service, reviewing structural compliance, or deciding how to introduce a new external dependency without coupling the domain.
role: worker
user-invocable: true
---

# Hexagonal Architecture (Ports & Adapters)

## Overview
Design systems with clear separation between business logic and infrastructure. The domain core has zero dependencies on outer layers; all external interactions flow through explicitly defined ports and adapters.

## Core Concepts

### Ports
- Interfaces that express application intent independent of technology
- **Inbound ports** (driving): define use cases the application exposes (e.g., `CreateOrderUseCase`)
- **Outbound ports** (driven): define what the application needs from the outside world (e.g., `OrderRepository`, `PaymentGateway`)

### Adapters
- Concrete implementations that connect ports to external systems
- **Inbound adapters**: REST controllers, CLI handlers, message consumers, GraphQL resolvers
- **Outbound adapters**: database repositories, HTTP clients, message publishers, file storage

### Dependency Rule
- All dependencies point inward toward the domain core
- Domain knows nothing about adapters, frameworks, or infrastructure
- Adapters depend on ports, never the reverse

## Project Structure

```
src/
├── domain/              # Pure business logic, no framework dependencies
│   ├── model/           # Entities, value objects, aggregates
│   ├── service/         # Domain services
│   └── event/           # Domain events
├── application/         # Use cases / application services
│   ├── port/
│   │   ├── inbound/     # Use case interfaces (driving ports)
│   │   └── outbound/    # Repository/gateway interfaces (driven ports)
│   └── service/         # Use case implementations
├── infrastructure/      # Framework and technology concerns
│   ├── config/          # Dependency injection, app configuration
│   └── persistence/     # Database migrations, ORM config
└── adapter/
    ├── inbound/         # Controllers, CLI, event consumers
    └── outbound/        # Repository impls, API clients, message publishers
```

## Steps

### 1. Identify Boundaries
- Enumerate all external dependencies (databases, APIs, message brokers, file systems)
- Identify each as an inbound or outbound interaction
- **Graph-assisted discovery.** Prefer CodeGraph/Repowise over raw `Grep` for
  locating adapters, port implementations, and cross-layer imports — see
  [`knowledge/codegraph-vs-graphify.md`](../../knowledge/codegraph-vs-graphify.md)
  for tool selection and the fallback contract.

### 2. Define Ports
- Create an inbound port interface for each use case the application exposes
- Create an outbound port interface for each external dependency the application needs

### 3. Implement Adapters
- Build an adapter for each port connecting to the concrete technology
- Verify all dependencies point inward (adapters depend on ports, never the reverse)

### 4. Validate Structure
- Confirm domain layer has zero imports from infrastructure or adapter layers
- Confirm tests can substitute adapters without touching domain logic

## Output
Report structural compliance as a list of violations (port without adapter, domain importing infrastructure, etc.) or confirm the structure passes all checks. Be concise — violations only; no narration for passing checks.

## Constraints
- Do not embed framework dependencies in the domain layer
- Do not bypass ports with direct infrastructure access from application services

## Guidelines
- Every external dependency gets its own adapter behind a port
- Test domain logic by substituting adapters (e.g., in-memory repository for unit tests)
- Introduce a new port when a new category of external interaction appears
- Reuse existing ports when the interaction pattern is the same
- Keep the application layer thin: orchestrate domain objects, don't duplicate domain logic

Versions

RepositoryScoreLicence
This page · bdfinst/agentic-dev-team100MIT
affaan-m/ECC100MIT
rrezartprebreza/spring-boot-skills100MIT
rrezartprebreza/spring-boot-skills100MIT
SHRIJANAGAIN/Nemo-Cli100Apache-2.0
zernie/vigiles100MIT
fatonh/symfony-skills100MIT
FlameMida/spec-dev95MIT
packmindhub/packmind95Apache-2.0

Database snapshot: 13.11.2026 · package version 3f1ede8885dc (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100hexagonal-clean-onion-architecture
    Use this skill when isolating core domain business logic from external frameworks, databases, and transport layers via ports & adapters.
  • 100707-technologies-hexagonal-architecture
    Use when you need framework-agnostic Hexagonal architecture guidance for Java projects - ports and adapters boundaries, application core independence, driving and driven adapters, dependency direction, infrastructure leakage detection, optional architecture tests, and…
  • 100clean-architecture
    Apply Clean Architecture principles to define layer boundaries, identify dependency violations, and structure domain vs infrastructure code. Use when designing service boundaries, separating business logic from infrastructure, evaluating hexagonal/onion/ports-and-adapters…
  • 100hexagonal
    Expert Hexagonal Architecture (Ports and Adapters) assistance covering driving/driven ports, infrastructure adapters, domain core isolation, and test stubbing. Use when decoupling domain logic from databases/HTTP frameworks, improving testability, or modernizing enterprise applications.
  • 100clean-ddd-hexagonal
    Design or review backend domain and dependency boundaries using DDD, Clean Architecture, and ports/adapters. Use for aggregate modeling, bounded contexts, use-case isolation, or architecture refactoring; not routine CRUD changes.
  • 90backend-clean-architecture
    Use this skill when the user asks 'where does this code go', 'what layer', 'clean architecture', 'hexagonal', 'ports and adapters', 'domain layer', 'application layer', 'infrastructure layer', 'should this be in service or repository', or when designing or reviewing backend code…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.