Ports and adapters — domain core independent of frameworks and I/O, driving (inbound) and driven (outbound) ports, adapters for HTTP, queues, databases and external APIs, testing the core with fakes. Use to structure a service so business logic is isolated and testable (hexagonal, ports and adapters, adapters, dependency inversion).
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Hexagonal Architecture?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/vectora-os-hexagonal-architecture)
---
name: hexagonal-architecture
description: Ports and adapters — domain core independent of frameworks and I/O, driving (inbound) and driven (outbound) ports, adapters for HTTP, queues, databases and external APIs, testing the core with fakes. Use to structure a service so business logic is isolated and testable (hexagonal, ports and adapters, adapters, dependency inversion).
metadata:
category: design-patterns
---
# Hexagonal architecture
## Purpose
Keep business logic independent of delivery mechanisms and infrastructure.
**Use when:** services with meaningful business logic and several integrations.
**Not for:** thin glue services.
## Inputs
- Use cases, external dependencies.
## Outputs
- Port interfaces, adapter list, folder layout, test strategy.
## Read first
- [Project Brain](../../../project-brain/README.md) — `npm run brain -- query "hexagonal architecture"` for prior decisions, patterns and anti-patterns.
- [Architecture standard](../../../standards/architecture.md)
- [Folder structure standard](../../../standards/folder-structure.md)
## Steps
1. **Core.** List use cases as application services in the core.
Done when core has no framework imports.
2. **Ports.** Define inbound ports (use case interfaces) and outbound ports (repositories, gateways).
Done when every external dependency is behind a port.
3. **Adapters.** Implement adapters per technology.
Done when adapters contain no business rules.
4. **Tests.** Test core with in-memory fakes; test adapters with integration tests.
Done when core tests run without I/O.
## Best practices
- Name ports in domain language.
- Enforce dependency direction with a lint rule.
## Common mistakes
- Leaking ORM entities into the core.
- Ports mirroring vendor APIs.
## Example
`PaymentGateway` port with `StripeAdapter` and `FakeGateway`; checkout use case tested in milliseconds.
## Reusable prompt
```text
Apply the Hexagonal architecture skill (.agents/skills/hexagonal-architecture/SKILL.md).
Context: {{task card or question; links to PRD, ADRs, code paths}}
Constraints: {{approved thresholds, deadlines, allowed files}}
Define the core use cases, inbound and outbound ports, adapters and the testing split for the service.
Return: Port interfaces, adapter list, folder layout, test strategy..
Cite evidence (file:line, command output, source) for every claim; list open questions separately.
```