hexagonal-architecture
/hexagonal-architecture
Isolate domain logic behind ports it owns while frameworks, databases, and transports live in adapters that plug into those ports. Use when business rules keep getting entangled with the web framework or database and you want the core testable and swappable in isolation.
- Author
- Amey-Thakur ↗
- Repository
- AI-SKILLS ↗
- Licence
- MIT
- Last repository change
- 05.09.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 05.09.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Isolate domain logic behind ports it owns while frameworks, databases, and transports live in adapters that plug into those ports. Use when business rules keep getting entangled with the web framework or database and you want the core testable and swappable in isolation.
Original author description
Isolate domain logic behind ports it owns while frameworks, databases, and transports live in adapters that plug into those ports. Use when business rules keep getting entangled with the web framework or database and you want the core testable and swappable in isolation.
How it works
- Method
- Checks
- Boundaries
SKILL.md preview
--- name: hexagonal-architecture description: Isolate domain logic behind ports it owns while frameworks, databases, and transports live in adapters that plug into those ports. Use when business rules keep getting entangled with the web framework or database and you want the core testable and swappable in isolation. --- # Hexagonal architecture Also called ports and adapters. The idea is a hard rule: the domain depends on nothing, and everything depends on the domain. When the HTTP handler and the SQL query bleed into the business rules, you cannot test the rules without a server and a database, and you cannot change either without risking the rules. ## Method 1. **Define ports as interfaces the domain owns.** A port is a Python Protocol, a Java interface, a Go interface declared inside the domain package. The domain names the shape it needs, `PaymentGateway.charge(amount)`, and never imports the thing that fulfills it. 2. **Keep the domain import-clean.** No `import requests`, no ORM base class, no framework annotation inside the core. Grep the domain package for your web and database libraries: a single hit is a leak to fix, not to tolerate. 3. **Split ports into driving and driven.** Driving (primary) ports are how the outside calls in: a use-case interface a REST controller invokes. Driven (secondary) ports are how the domain calls out: repositories, gateways, clocks. Naming the two directions keeps the wiring legible. 4. **Put every concrete detail in an adapter.** The REST adapter drives a primary port; the Postgres adapter implements a secondary port; a Stripe adapter implements the payment port. Each adapter is replaceable without the domain noticing. 5. **Wire everything at a composition root.** One place, usually `main`, that constructs adapters and injects them into the domain. The domain receives its dependencies; it never reaches out and builds them. 6. **Test the core with fakes.** Swap in an in-memory repository and a stub gateway to test business rules with no network and no I/O. If a domain test needs a running database, a boundary has been crossed. 7. **Translate at the adapter edge.** Map request payloads and database rows to domain models inside the adapter, so external formats never reach the core. ## Checks - Do the domain tests run with no database, no HTTP server, and no clock skew? - Could you replace Postgres with an in-memory store by writing one adapter and changing one line at the composition root? - Does any domain file import a framework, driver, or transport library? ## Boundaries Domain-driven design supplies the model that lives inside the hexagon: this skill governs the boundary around it, not the modeling within. For a thin CRUD service with no real business rules, the indirection buys little worth its cost.
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · Amey-Thakur/AI-SKILLS | 90 | MIT |
| affaan-m/ECC | 100 | MIT |
| rrezartprebreza/spring-boot-skills | 100 | MIT |
| rrezartprebreza/spring-boot-skills | 100 | MIT |
| SHRIJANAGAIN/Nemo-Cli | 100 | Apache-2.0 |
| zernie/vigiles | 100 | MIT |
| bdfinst/agentic-dev-team | 100 | MIT |
| fatonh/symfony-skills | 100 | MIT |
| FlameMida/spec-dev | 95 | MIT |
Database snapshot: 13.11.2026 · package version ea246104f870 (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. - 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. - 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… - 100hexagonal-pattern-guide
Use when isolating an application or domain core from its I/O and delivery mechanisms behind interfaces: hexagonal / ports-and-adapters / clean / onion architecture. Triggers on decoupling the domain from the database/UI/framework, driving (primary) vs driven (secondary)… - 100ddd-architecture-hexagonal
Comprehensive guidance for Hexagonal Architecture (Ports & Adapters) — Alistair Cockburn's hexagonal architecture with domain core, port definitions, adapter implementations, and full Java/Spring Boot implementation steps. Covers primary/driving adapters, secondary/driven… - 100hexagonal
Hexagonal Architecture (Ports and Adapters), Onion Architecture, and their relationship to Clean Architecture -- enabling technology-independent domain logic with high testability. USE FOR: hexagonal architecture, ports and adapters, onion architecture, driving/driven adapters,…