hexagonal-architecture
Context. Built in October 2026 as a personal project, when I had just started as an AI Engineer at Inditex after leading the back end at Auro AI. It belongs to the third phase of my GitHub, where I build tools to production standards with coding agents (Claude Code, opencode): CI, tests, releases and agent skills.

An agent skill for AI coding agents that audits a repository against hexagonal architecture (ports and adapters) and applies only the changes you approve. It works in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, Windsurf, ZCode and any agent that reads the open SKILL.md format. It checks the dependency rule in the code, not just the folder layout: domain isolation, adapter-to-adapter imports, and construction outside the composition root. It also proposes the architecture linting contract for the repo language: import-linter for Python, dependency-cruiser for TypeScript, ArchUnit for Java and go-arch-lint for Go.
Use it when the core of a codebase is drifting toward a framework, when clean architecture or DDD is being discussed without evidence, or when a migration to ports and adapters has to be planned without a big-bang rewrite. When the repo does not justify the pattern, it recommends not migrating and explains why.
What it checks
- Core code that imports an adapter, an ORM, a framework, an HTTP client or a database driver.
- Framework annotations or decorators in the core: Spring style annotations in Java (
@Service, @Entity, @Transactional) and web route decorators in Python (@app.get, @api_view).
- Adapters that import each other.
- Adapters instantiated outside the composition root.
- Ports named after a technology (
PostgresPort, HttpGateway).
- A controller or a route handler sitting under a ports folder.
- A driven port without an in-memory double in tests.
- A core with no tests isolated from infrastructure.
- Python tests that
python3 -m unittest discovers as zero without failing (no __init__.py and no pytest config).
- A structure it cannot recognise, reported as info with a
.hexagonal.json proposal.
Findings come in four severities: high (the dependency rule is broken), medium (the structure leaks), low (naming and hygiene) and info (not enough evidence). A green audit is not proof: it only means the script did not see the violations it knows how to look for.
Quick start
Install with the skills CLI, naming your agent:
npx skills add iDiagoValeta/hexagonal-architecture -a <agent>
Or with the GitHub CLI, which needs a recent gh with the skill command in preview:
gh skill install iDiagoValeta/hexagonal-architecture hexagonal-architecture --agent <agent> --scope user
gh skill supports every listed agent except Windsurf and ZCode, which use the skills CLI or install.sh.
<agent> is one of claude-code, codex, cursor, gemini-cli, github-copilot, opencode, windsurf or zcode. See Install for the install options for each agent, the manual symlink and how to invoke the skill.
Example
This tree breaks the dependency rule: the domain imports SQLAlchemy.
/tmp/hex-demo
└── src
├── domain/order.py # imports sqlalchemy.orm
├── ports/order_repository.py
├── adapters/driven/sql_orders.py
└── main.py # composition root
The domain file:
from dataclasses import dataclass
from sqlalchemy.orm import Session
python3 hexagonal-architecture/scripts/audit.py --path /tmp/hex-demo prints:
# Hexagonal architecture audit
- Path: `/tmp/hex-demo`
- Configuration: inferred from folder names (no `.hexagonal.json`)
## Findings
### High (1)
- **[high] core.forbidden-library** (core) `src/domain/order.py:3`: The core imports `sqlalchemy.orm`, a library for IO, a framework or persistence (matches `sqlalchemy`).
- Fix: Move that dependency behind a port and keep the library in an adapter.
...
## Summary
| Severity | Findings |
| --- | --- |
| High | 1 |
| Medium | 2 |
| Low | 0 |
| Info | 0 |
...
The trimmed medium findings are the driven port without an in-memory double and the core without isolated tests.
Install
Every agent reads the same hexagonal-architecture/ folder and the same SKILL.md; only the skills directory and the install command change. The table summarises the paths; the sections below give the commands for each agent, alphabetically.