# Darwin Hexagonal

> Hexagonal Architecture (Ports & Adapters) patterns for code review and planning. Use when reviewing code structure, planning new features, or evaluating coupling. Use when this capability is needed.

- Skill: `tomevault-io/darwin-hexagonal` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/darwin-hexagonal`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/darwin-hexagonal/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/darwin-hexagonal

---


# Hexagonal Architecture (Ports & Adapters)

## Core Principles

- **Core domain isolation**: Business logic MUST have zero import dependencies on infrastructure. No `import redis`, `import kubernetes`, `import requests` in domain modules.
- **Ports**: Interfaces defined BY the core domain (e.g., `class EventStore(Protocol)`, `class MetricsProvider(Protocol)`). The core says what it needs; adapters provide it.
- **Adapters**: Implementations of ports for specific technologies (e.g., `RedisEventStore`, `K8sMetricsProvider`). Adapters import infrastructure libraries; the core never does.
- **Dependency direction**: Always inward. Adapters depend on ports. Core depends on nothing external.

## When Reviewing Code

- Flag any business logic file that directly imports a database client, HTTP library, or cloud SDK
- Recommend extracting a port (interface) to decouple
- If a change modifies both a port interface and its adapter, flag it in the risk assessment

## When Planning New Features

- Specify which port the new code enters through
- Specify which adapter will implement it
- If the port doesn't exist yet, design it as part of the plan
- Boundary crossings (modifying port + adapter) carry higher risk

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/the-darwin-project) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-13 -->

