/hexagonal-architecture:hexagonal-architecturefrom hexagonal-architecture
Audits a repository against hexagonal architecture (ports and adapters) and applies only the changes the user approves. It finds core code that imports adapters, frameworks or IO libraries, adapters that import each other, adapter instantiation outside the composition root, technology names in ports and missing in-memory doubles, then proposes a migration in small steps plus a CI contract. Use when asked about hexagonal architecture, ports and adapters, driving or driven ports, domain isolation, dependency injection, composition root, clean architecture or DDD, or when auditing or refactoring a repo toward a technology-free core.
Ships in hexagonal-architecture. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Audits a repo and applies only what is approved. The pattern is not free: when the repo does not justify it, the skill says so and recommends not migrating.
Mandatory gate before any write to the repo or GitHub (creating or editing files, git commit, git push, gh pr, or any command that changes state): the request must carry a written OK for THAT specific change, for example "apply the config", "open the PR", "I approve all the changes". Asking for the goal ("migrate this repo to hexagonal") is NOT that OK. Without it, your reply ends with the exact diff or command, how to undo it, and the question "shall I apply it?", even if nobody is there to answer. In a non-interactive run, deliver the plan and stop. For agents that support permission rules, the block in assets/agent-permissions/ asks before git commit, git push and gh pr, which is history and remote; it does not gate file edits, which remain gated by the instruction above.
Recommend against migrating, and say why in the report, when the project is small, short-lived, has a single client and a single stable technology, or its core is CRUD without rules to test. The full decision table and the partial option are in references/when-to-apply.md. Do not apply the pattern to code nobody will maintain.
Copyable checklist:
- [ ] Audit the repo in read-only mode
- [ ] Report findings by severity: high, medium, low, info
- [ ] Decide apply, partial or skip, with reasons
- [ ] Propose .hexagonal.json for the real paths
- [ ] Add the CI contract for the repo language
- [ ] Migrate one use case or one adapter per PR
- [ ] Re-audit and confirm high findings never increase
Run the audit script, do not read it:
python3 "${CLAUDE_SKILL_DIR}/scripts/audit.py" --path . --json
In Claude Code the path is ${CLAUDE_SKILL_DIR}/scripts/audit.py. In other agents, use the path of the directory where this skill is installed. Flags: --path for the repo root, --config for an explicit config file, --json for machine-readable output. The audit is read-only and changes nothing.
Without .hexagonal.json the script infers roles from folder names and says so in the report. Inference is a starting point, not a verdict.
Sort findings by severity and state what could not be checked.
tests/ folder has no __init__.py and no pytest config, so python3 -m unittest discovers nothing.A green audit does not prove the architecture is right: it proves that the script did not see the violations it knows how to look for. Say so.
Choose one outcome and justify it with the signals in references/when-to-apply.md:
Write .hexagonal.json from the real paths, using assets/hexagonal.example.json as the shape. Keys: core, ports, driving_adapters, driven_adapters, composition_root, forbidden_in_core. Show the proposed file and wait for approval before writing it.
Pick the template for the repo language and show the diff before applying it. The rule must fail on a deliberate violation, not only pass on correct code.
Details and the false-green traps are in references/enforcement.md.
One use case or one adapter per PR. Never a big bang. The order that costs least: freeze behaviour with tests, extract the driven port and its in-memory double, move the use case into the core, put the real adapter behind the port, move the driving adapter, then gather construction in the composition root. Branch refactoring/<issue>-<context> and draft PR follow the github-practices skill if it is installed; otherwise use the same format. The full step list, the stopping signals and the PR checklist are in references/migration.md.
Run the audit again after each PR and compare by severity and area, not only the total. A new high finding offset by resolved medium ones is still a regression. If high findings increase, the PR is fixed or reverted; they must go down or stay level.
CONTRIBUTING.md, the repo wins.References (read only the one you need):
| File | When to read it |
|---|---|
| references/principles.md | The nine principles, glossary, common misunderstandings and the mistakes found in tier 3 articles |
| references/when-to-apply.md | Decide apply, partial or skip, and understand the real costs |
| references/layouts.md | Propose a structure in Python, TypeScript, Java or Go |
| references/testing.md | Design unit, acceptance, integration and system tests with in-memory doubles |
| references/migration.md | Plan and execute a strangler migration one use case at a time |
| references/enforcement.md | Add the CI contract for each language and check that it bites |
Scripts (run them, do not read them):
| File | What for |
|---|---|
| scripts/audit.py | Read-only audit with --path, --config, --json |
Assets (copy, do not edit):
| File | What to copy |
|---|---|
| assets/hexagonal.example.json | Shape of .hexagonal.json with real paths |
| assets/python/importlinter.ini | import-linter contracts for Python |
| assets/typescript/.dependency-cruiser.cjs | dependency-cruiser rules for TypeScript and JavaScript |
| assets/java/HexagonalArchitectureTest.java | ArchUnit test for Java |
| assets/go/.go-arch-lint.yml | go-arch-lint components for Go |
| assets/ci/architecture.yml | GitHub Actions workflow, one job per language |
| assets/agent-permissions/opencode.json | OpenCode permission block that asks before push, commit or PR |
| assets/agent-permissions/claude-settings.json | Claude Code equivalent: asks before commit, push or PR |
assets/agent-permissions/claude-settings.json (opens in a new tab)assets/agent-permissions/opencode.json (opens in a new tab)assets/ci/architecture.yml (opens in a new tab)assets/hexagonal.example.json (opens in a new tab)assets/java/HexagonalArchitectureTest.java (opens in a new tab)assets/python/importlinter.ini (opens in a new tab)references/enforcement.md (opens in a new tab)references/layouts.md (opens in a new tab)references/migration.md (opens in a new tab)references/principles.md (opens in a new tab)references/testing.md (opens in a new tab)references/when-to-apply.md (opens in a new tab)scripts/audit.py (opens in a new tab)scripts/imports.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub idiagovaleta/hexagonal-architecture --plugin hexagonal-architecture