hexagonal-architecture
БесплатноБез исполняемых скриптовНе проверенWHEN a repository or user explicitly opts into hexagonal (ports and adapters) architecture via README, AGENTS.md, CLAUDE.md, ADR, or explicit adoption request…
от mintuz★ 38 звёзд на GitHubОб этом скилле
Hexagonal Architecture (Ports and Adapters)
Opt-In Gate
Before applying any pattern in this skill, verify that the repository or user has explicitly opted into hexagonal architecture:
- Valid opt-in evidence: a
README,AGENTS.md,CLAUDE.md, Architectural Decision Record (ADR), or explicit user request stating that the project uses or adopts hexagonal (ports and adapters) architecture. - If no opt-in exists, stop. Do not impose ports-and-adapters structure, driving/driven port hierarchies, or composition-root rewrites on a generic isolation, adapter, or test-seam request. Hand off to
test-seamsfor breaking a hidden dependency or toarchitectfor general module boundaries. - Once a repository has opted in, apply this skill to every code change in it — new features, bug fixes, SDK swaps, and small rule edits — alongside
tdd, never instead of it.
Before You Write Code
Follow these mandatory safeguards on every change in an opted-in codebase.
A vendor SDK is never a port
Any client, request model, or data-transfer object (DTO) exported by a third-party package or the repository's SDK folder is outside the hexagon. Every file that imports it — including type-only imports — is outside the hexagon.
- A dependency object whose fields are SDK client types is not a set of ports, even when tests supply fakes.
- Structural compatibility between an SDK client and your required interface never justifies skipping an adapter.
- Declare your own domain types inside and translate between SDK shapes and domain types inside a driven adapter (
principle-hide-representations).
Adding a feature (ordered procedure)
- Put business rules (time windows, eligibility checks, filters, message text, truncation, authorisation rules) in a pure inside function that receives domain values, clock values, and identifiers as inputs (
principle-keep-the-core-pure). Adapters receive finished values and translate them to technology shapes. - Declare ports inside, beside their innermost consumer:
- Driving ports name the actor capability (
For<Verb>ing<Noun>, such asForPlacingOrdersorForSendingReceipts). - Driven ports name the business role (
OrderRepository,PaymentGateway,ReceiptSender) or keep the repository's existingFor...convention if it already uses one. - Port signatures use domain types only; never expose wire, storage, framework, or SDK types.
- Driving ports name the actor capability (
- Write one thin driven adapter per driven port to translate between port types and external technology. Write a thin driving adapter (route, UI view, CLI command, queue handler, or system intent) that parses untrusted input (
principle-parse-at-the-boundary), invokes the driving port, and translates the result. - Wire concrete clients, adapters, and use cases in the composition root only. Keep the composition root's public caller signature unchanged: it still receives external clients or configuration from its caller and constructs adapters internally.
- Test the use case through its driving port using hand-written stateful or recording fakes of the driven ports (
principle-test-behavior-not-implementation). Test each adapter separately at its real technology boundary.
Changing a use case that still imports an SDK directly
When you touch an inside file that still imports a vendor package or the repository's SDK folder, porting all of its SDK dependencies is part of the change, not scope creep.
- Keep existing tests green and extract every SDK dependency of the touched file behind driven ports as a behaviour-preserving refactor step before writing the failing test for the new behaviour. Extracting only the single dependency named in the request leaves the next change coupled to the remaining SDKs.
- Declare an explicit driving port contract if the use case has none (a bare exported function is not a driving port).
- Put the new business rule inside. If the request says "just add it where the SDK call is", keep the rule inside and explain why in one sentence.
- Before finishing, inspect the use case's imports. If any import still references a vendor package, SDK folder, or SDK type, extract it before claiming done.
File placement when restructuring is not requested
Preserve the repository's existing layout for inside code when physical restructuring is out of scope. Adapters and fakes are first-party code: place them beside the feature they serve or in an adapters/ or testing/ location, never inside a folder that holds third-party SDK clients.
Fakes over mocks at use-case boundaries
Use-case tests must contain no mocking-framework helpers (no spy, stub, or module-mock calls) and no imports from vendor SDK folders. Build a hand-written stateful or recording fake for each driven port and assert observable outcomes and recorded state. When you touch an existing use-case test that mocks SDK clients, replace those mocks with fakes of the declared ports rather than extending them.
Core Ar
Установить hexagonal-architecture в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл hexagonal-architecture?
WHEN a repository or user explicitly opts into hexagonal (ports and adapters) architecture via README, AGENTS.md, CLAUDE.md, ADR, or explicit adoption request — apply to every code change in that opted-in repo alongside tdd; NOT for repositories that have not opted in, generic test-seam or isolation requests, or physical folder layout alone; enforces inside/outside zones, application-owned ports, thin adapters, composition roots, and stateful-fake testing.
Как установить скилл hexagonal-architecture?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл hexagonal-architecture запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic