Agent skill

Hexagonal Architecture

by yamcodes in yamcodes/arkenv

Design, implement, and refactor Ports & Adapters systems with clear domain boundaries, dependency inversion, and testable use-case orchestration across TypeScript, Java, Kotlin, and Go services.

MITAuto-check passedMobile

Install Hexagonal Architecture

skills CLI
$ npx skills add yamcodes/arkenv --skill hexagonal-architecture -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install yamcodes/arkenv hexagonal-architecture --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/yamcodes/arkenv.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/hexagonal-architecture .claude/skills/hexagonal-architecture && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
hexagonal-architecture
GitHub stars
145
Used in
4 other repos
Token cost
~2.9k tokens
SKILL.md length
966 words
Files
1
Skills in repo
20
Repo updated
First seen
Licence
MIT

At a glance

Design, implement, and refactor Ports & Adapters systems with clear domain boundaries, dependency inversion, and testable use-case orchestration across TypeScript, Java, Kotlin, and Go services.

  • Works in 6 steps: model a use case boundary → define outbound ports first → implement the use case with pure… → …
  • Tasks that involve Android development
  • SKILL.md covers When to use, Core concepts, How it works and Architecture diagram, plus 7 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Hexagonal Architecture is an agent skill from yamcodes/arkenv. Design, implement, and refactor Ports & Adapters systems with clear domain boundaries, dependency inversion, and testable use-case orchestration across TypeScript, Java, Kotlin, and Go services.

Its SKILL.md is about 2.9k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Mobile, covering Android development and Refactoring. It works with TypeScript, Java and Kotlin. The repository describes itself as: ⛯ Typesafe environment variables with ArkType, Zod, or Valibot. The licence is MIT.

When your agent uses it

  • Tasks that involve Android development
  • Tasks that involve Refactoring

Example prompts

  • “/hexagonal-architecture”

Workflow steps

6 steps, taken from the step headings in SKILL.md.

  1. model a use case boundary
  2. define outbound ports first
  3. implement the use case with pure orchestration
  4. build adapters at the edge
  5. wire everything in a composition root
  6. test per boundary

What it can do on your machine

Read from SKILL.md and the folder at commit 7340aa2. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript and mermaid).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Hexagonal Architecture loads about 2.9k tokens when it runs. Until then it costs about 54 tokens; SKILL.md has 966 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~54
When it runs · the whole SKILL.md, loaded when a task matches
~2.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from yamcodes/arkenv at commit 7340aa2, republished under its MIT licence (© yamcodes). 966 words, ~2,855 tokens.

Download SKILL.mdSave it as .claude/skills/hexagonal-architecture/SKILL.md (or your agent's skills folder).
name
hexagonal-architecture
description
Design, implement, and refactor Ports & Adapters systems with clear domain boundaries, dependency inversion, and testable use-case orchestration across TypeScript, Java, Kotlin, and Go services.
origin
ECC
metadata.internal
true

Hexagonal architecture

Hexagonal architecture (Ports and Adapters) keeps business logic independent from frameworks, transport, and persistence details. The core app depends on abstract ports, and adapters implement those ports at the edges.

When to use

  • Building new features where long-term maintainability and testability matter.
  • Refactoring layered or framework-heavy code where domain logic is mixed with I/O concerns.
  • Supporting multiple interfaces for the same use case (HTTP, CLI, queue workers, cron jobs).
  • Replacing infrastructure (database, external APIs, message bus) without rewriting business rules.

Use this skill when the request involves boundaries, domain-centric design, refactoring tightly coupled services, or decoupling application logic from specific libraries.

Core concepts

  • Domain model: Business rules and entities/value objects. No framework imports.
  • Use cases (application layer): Orchestrate domain behavior and workflow steps.
  • Inbound ports: Contracts describing what the application can do (commands/queries/use-case interfaces).
  • Outbound ports: Contracts for dependencies the application needs (repositories, gateways, event publishers, clock, UUID, etc.).
  • Adapters: Infrastructure and delivery implementations of ports (HTTP controllers, DB repositories, queue consumers, SDK wrappers).
  • Composition root: Single wiring location where concrete adapters are bound to use cases.

Outbound port interfaces usually live in the application layer (or in domain only when the abstraction is truly domain-level), while infrastructure adapters implement them.

Dependency direction is always inward:

  • Adapters -> application/domain
  • Application -> port interfaces (inbound/outbound contracts)
  • Domain -> domain-only abstractions (no framework or infrastructure dependencies)
  • Domain -> nothing external

How it works

Step 1: model a use case boundary

Define a single use case with a clear input and output DTO. Keep transport details (Express req, GraphQL context, job payload wrappers) outside this boundary.

Step 2: define outbound ports first

Identify every side effect as a port:

  • persistence (UserRepositoryPort)
  • external calls (BillingGatewayPort)
  • cross-cutting (LoggerPort, ClockPort)

Ports should model capabilities, not technologies.

Step 3: implement the use case with pure orchestration

Use case class/function receives ports via constructor/arguments. It validates application-level invariants, coordinates domain rules, and returns plain data structures.

Step 4: build adapters at the edge
  • Inbound adapter converts protocol input to use-case input.
  • Outbound adapter maps app contracts to concrete APIs/ORM/query builders.
  • Mapping stays in adapters, not inside use cases.
Step 5: wire everything in a composition root

Instantiate adapters, then inject them into use cases. Keep this wiring centralized to avoid hidden service-locator behavior.

Step 6: test per boundary
  • Unit test use cases with fake ports.
  • Integration test adapters with real infra dependencies.
  • E2E test user-facing flows through inbound adapters.

Architecture diagram

mermaid
flowchart LR
  Client["Client (HTTP/CLI/Worker)"] --> InboundAdapter["Inbound Adapter"]
  InboundAdapter -->|"calls"| UseCase["UseCase (Application Layer)"]
  UseCase -->|"uses"| OutboundPort["OutboundPort (Interface)"]
  OutboundAdapter["Outbound Adapter"] -->|"implements"| OutboundPort
  OutboundAdapter --> ExternalSystem["DB/API/Queue"]
  UseCase --> DomainModel["DomainModel"]

Suggested module layout

Use feature-first organization with explicit boundaries:

text
src/
  features/
    orders/
      domain/
        Order.ts
        OrderPolicy.ts
      application/
        ports/
          inbound/
            CreateOrder.ts
          outbound/
            OrderRepositoryPort.ts
            PaymentGatewayPort.ts
        use-cases/
          CreateOrderUseCase.ts
      adapters/
        inbound/
          http/
            createOrderRoute.ts
        outbound/
          postgres/
            PostgresOrderRepository.ts
          stripe/
            StripePaymentGateway.ts
      composition/
        ordersContainer.ts

TypeScript example

Port definitions
typescript
export interface OrderRepositoryPort {
  save(order: Order): Promise<void>;
  findById(orderId: string): Promise<Order | null>;
}

export interface PaymentGatewayPort {
  authorize(input: { orderId: string; amountCents: number }): Promise<{ authorizationId: string }>;
}
Use case
typescript
type CreateOrderInput = {
  orderId: string;
  amountCents: number;
};

type CreateOrderOutput = {
  orderId: string;
  authorizationId: string;
};

export class CreateOrderUseCase {
  constructor(
    private readonly orderRepository: OrderRepositoryPort,
    private readonly paymentGateway: PaymentGatewayPort
  ) {}

  async execute(input: CreateOrderInput): Promise<CreateOrderOutput> {
    const order = Order.create({ id: input.orderId, amountCents: input.amountCents });

    const auth = await this.paymentGateway.authorize({
      orderId: order.id,
      amountCents: order.amountCents,
    });

    // markAuthorized returns a new Order instance; it does not mutate in place.
    const authorizedOrder = order.markAuthorized(auth.authorizationId);
    await this.orderRepository.save(authorizedOrder);

    return {
      orderId: order.id,
      authorizationId: auth.authorizationId,
    };
  }
}
Outbound adapter
typescript
export class PostgresOrderRepository implements OrderRepositoryPort {
  constructor(private readonly db: SqlClient) {}

  async save(order: Order): Promise<void> {
    await this.db.query(
      "insert into orders (id, amount_cents, status, authorization_id) values ($1, $2, $3, $4)",
      [order.id, order.amountCents, order.status, order.authorizationId]
    );
  }

  async findById(orderId: string): Promise<Order | null> {
    const row = await this.db.oneOrNone("select * from orders where id = $1", [orderId]);
    return row ? Order.rehydrate(row) : null;
  }
}
Composition root
typescript
export const buildCreateOrderUseCase = (deps: { db: SqlClient; stripe: StripeClient }) => {
  const orderRepository = new PostgresOrderRepository(deps.db);
  const paymentGateway = new StripePaymentGateway(deps.stripe);

  return new CreateOrderUseCase(orderRepository, paymentGateway);
};

Multi-language mapping

Use the same boundary rules across ecosystems; only syntax and wiring style change.

  • TypeScript/JavaScript
    • Ports: application/ports/* as interfaces/types.
    • Use cases: classes/functions with constructor/argument injection.
    • Adapters: adapters/inbound/*, adapters/outbound/*.
    • Composition: explicit factory/container module (no hidden globals).
  • Java
    • Packages: domain, application.port.in, application.port.out, application.usecase, adapter.in, adapter.out.
    • Ports: interfaces in application.port.*.
    • Use cases: plain classes (Spring @Service is optional, not required).
    • Composition: Spring config or manual wiring class; keep wiring out of domain/use-case classes.
  • Kotlin
    • Modules/packages mirror the Java split (domain, application.port, application.usecase, adapter).
    • Ports: Kotlin interfaces.
    • Use cases: classes with constructor injection (Koin/Dagger/Spring/manual).
    • Composition: module definitions or dedicated composition functions; avoid service locator patterns.
  • Go
    • Packages: internal/<feature>/domain, application, ports, adapters/inbound, adapters/outbound.
    • Ports: small interfaces owned by the consuming application package.
    • Use cases: structs with interface fields plus explicit New... constructors.
    • Composition: wire in cmd/<app>/main.go (or dedicated wiring package), keep constructors explicit.
Show full SKILL.md (407 more words)Show less

Anti-patterns to avoid

  • Domain entities importing ORM models, web framework types, or SDK clients.
  • Use cases reading directly from req, res, or queue metadata.
  • Returning database rows directly from use cases without domain/application mapping.
  • Letting adapters call each other directly instead of flowing through use-case ports.
  • Spreading dependency wiring across many files with hidden global singletons.

Migration playbook

  1. Pick one vertical slice (single endpoint/job) with frequent change pain.
  2. Extract a use-case boundary with explicit input/output types.
  3. Introduce outbound ports around existing infrastructure calls.
  4. Move orchestration logic from controllers/services into the use case.
  5. Keep old adapters, but make them delegate to the new use case.
  6. Add tests around the new boundary (unit + adapter integration).
  7. Repeat slice-by-slice; avoid full rewrites.
Refactoring existing systems
  • Strangler approach: keep current endpoints, route one use case at a time through new ports/adapters.
  • No big-bang rewrites: migrate per feature slice and preserve behavior with characterization tests.
  • Facade first: wrap legacy services behind outbound ports before replacing internals.
  • Composition freeze: centralize wiring early so new dependencies do not leak into domain/use-case layers.
  • Slice selection rule: prioritize high-churn, low-blast-radius flows first.
  • Rollback path: keep a reversible toggle or route switch per migrated slice until production behavior is verified.

Testing guidance (same hexagonal boundaries)

  • Domain tests: test entities/value objects as pure business rules (no mocks, no framework setup).
  • Use-case unit tests: test orchestration with fakes/stubs for outbound ports; assert business outcomes and port interactions.
  • Outbound adapter contract tests: define shared contract suites at port level and run them against each adapter implementation.
  • Inbound adapter tests: verify protocol mapping (HTTP/CLI/queue payload to use-case input and output/error mapping back to protocol).
  • Adapter integration tests: run against real infrastructure (DB/API/queue) for serialization, schema/query behavior, retries, and timeouts.
  • End-to-end tests: cover critical user journeys through inbound adapter -> use case -> outbound adapter.
  • Refactor safety: add characterization tests before extraction; keep them until new boundary behavior is stable and equivalent.

Best practices checklist

  • Domain and use-case layers import only internal types and ports.
  • Every external dependency is represented by an outbound port.
  • Validation occurs at boundaries (inbound adapter + use-case invariants).
  • Use immutable transformations (return new values/entities instead of mutating shared state).
  • Errors are translated across boundaries (infra errors -> application/domain errors).
  • Composition root is explicit and easy to audit.
  • Use cases are testable with simple in-memory fakes for ports.
  • Refactoring starts from one vertical slice with behavior-preserving tests.
  • Language/framework specifics stay in adapters, never in domain rules.

© yamcodes, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/hexagonal-architecture of yamcodes/arkenv.

Open the folder on GitHubat commit 7340aa2

Used in 4 other repositories

We found 6 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 4 other GitHub owners. This page covers the copy in yamcodes/arkenv, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Hexagonal Architecture next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Hexagonal Architecture compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Hexagonal Architecture this skillyamcodes/arkenv1454 repos~2.9kAutomated safety check: PassMIT
Test Revieweraxelixlabs/axelix147—~3.2kAutomated safety check: PassLGPL-3.0
Test Writeraxelixlabs/axelix147—~2.2kAutomated safety check: PassLGPL-3.0
Build Teaql Appteaql/teaql-agent-kit2.8k—~4.6kAutomated safety check: PassMIT
Android Maps Ktxgooglemaps/android-maps-ktx360—~897Automated safety check: PassApache-2.0
Code Revieweralirezarezvani/claude-skills28k1 repos~1.6kAutomated safety check: PassMIT

Similar skills

  • Test Reviewer

    axelixlabs/axelix

    Reviews test code in GitHub pull requests for isolation, public-API contract coverage, AAA structure, and correct exception assertions.

    147 GitHub stars~3.2k tokensUpdated yesterday
    MobileAuto-check passed
  • Test Writer

    axelixlabs/axelix

    Writes new tests for Axelix source code (Java, Kotlin, TypeScript, JavaScript) that follow the project's testing standards — public-API contract coverage, test isolation, given/when/then structure…

    147 GitHub stars~2.2k tokensUpdated yesterday
    MobileAuto-check passed
  • Build Teaql App

    teaql/teaql-agent-kit

    Build or change a TeaQL application in Java, Rust, Go, Swift, Python, C/.NET, or TypeScript, including Kotlin/JVM applications that consume Java-generated libraries.

    2.8k GitHub stars~4.6k tokensUpdated 10 days ago
    MobileAuto-check passed
  • Android Maps Ktx

    googlemaps/android-maps-ktx

    Provides idiomatic Kotlin extension (KTX) patterns, reactive Flow event streams, and multi-subscriber shareIn rules for Google Maps SDK for Android and its Utility Library.

    360 GitHub stars~897 tokensUpdated 2 days ago
    MobileAuto-check passed
  • Code Reviewer

    alirezarezvani/claude-skills

    Code review automation for TypeScript, JavaScript, Python, Go, Swift, Kotlin, C, .NET, Java, C, C++, Rust, Ruby, PHP, and Dart/Flutter.

    28k GitHub starsUsed in 1 repo~1.6k tokens
    DevelopmentAuto-check passed
  • 设计、实现并重构端口与适配器系统,具有清晰的领域边界、依赖反转以及跨 TypeScript、Java、Kotlin 和 Go 服务的可测试用例编排。

    274k GitHub stars~1.6k tokensUpdated 2 days ago
    MobileAuto-check passed

More from yamcodes/arkenv

All 20 skills in this repo
  • Hallmark

    yamcodes/arkenv

    Anti-AI-slop design skill for greenfield pages, audits, redesigns, and design extraction from URLs or screenshots.

    145 GitHub starsUsed in 4 repos~18k tokens
    Auto-check passed
  • Bulletproof React

    yamcodes/arkenv

    Bulletproof React architecture patterns for scalable, maintainable applications.

    145 GitHub stars~1.8k tokensUpdated 2 days ago
    Auto-check passed
  • Arkenv

    yamcodes/arkenv

    Answer questions about ArkEnv and help implement environment variable validation.

    145 GitHub stars~2.5k tokensUpdated 2 days ago
    Auto-check passed
  • Code Review

    yamcodes/arkenv

    Fetch, analyze, and address code reviews and comments on GitHub, or perform a code review on changes in the workspace.

    145 GitHub stars~1.4k tokensUpdated 2 days ago
    Auto-check passed
  • Forward Port

    yamcodes/arkenv

    Manually forward-ports merged dev (v0) changes to the v1 branch, adapting code to v1's package layout and changeset names.

    145 GitHub stars~970 tokensUpdated 2 days ago
    Auto-check passed
  • Groom Issue

    yamcodes/arkenv

    Groom a poorly written issue by grilling the user to clarify requirements, updating the issue on GitHub via the gh cli, and utilizing the triage skill to apply the correct label and add an agent…

    145 GitHub stars~1k tokensUpdated 2 days ago
    Auto-check passed

Questions about Hexagonal Architecture

What does Hexagonal Architecture do?

Design, implement, and refactor Ports & Adapters systems with clear domain boundaries, dependency inversion, and testable use-case orchestration across TypeScript, Java, Kotlin, and Go services. Hexagonal Architecture is an agent skill from yamcodes/arkenv. Design, implement, and refactor Ports & Adapters systems with clear domain boundaries, dependency inversion, and testable use-case orchestration across TypeScript, Java, Kotlin, and Go services.

When should I use Hexagonal Architecture?

Hexagonal Architecture fits situations like: tasks that involve Android development; tasks that involve Refactoring.

How do I install Hexagonal Architecture in Claude Code?

Run `npx skills add yamcodes/arkenv --skill hexagonal-architecture -a claude-code`. Or copy the skill folder (skills/hexagonal-architecture in yamcodes/arkenv) into .claude/skills/hexagonal-architecture in your project. Claude Code loads it when a task matches its description.

How do I install Hexagonal Architecture in Codex?

Run `npx skills add yamcodes/arkenv --skill hexagonal-architecture -a codex`. Or copy the skill folder (skills/hexagonal-architecture in yamcodes/arkenv) into .agents/skills/hexagonal-architecture in your project. Codex loads it when a task matches its description.

Can I use Hexagonal Architecture in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add yamcodes/arkenv --skill hexagonal-architecture -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/hexagonal-architecture, .gemini/skills/hexagonal-architecture, .github/skills/hexagonal-architecture and .opencode/skills/hexagonal-architecture in your project.

What does Hexagonal Architecture need to run?

SKILL.md names no scripts, command-line tools or credentials: Hexagonal Architecture is instructions for the agent only.

Does Hexagonal Architecture access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Hexagonal Architecture safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Hexagonal Architecture use?

Hexagonal Architecture is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Hexagonal Architecture use?

About 2.9k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Hexagonal Architecture?

Skills that share tags, products or a category with Hexagonal Architecture: Test Reviewer (axelixlabs/axelix, 147 stars), Test Writer (axelixlabs/axelix, 147 stars), Build Teaql App (teaql/teaql-agent-kit, 2.8k stars) and Android Maps Ktx (googlemaps/android-maps-ktx, 360 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Hexagonal Architecture?

yamcodes (a GitHub user) maintains it in yamcodes/arkenv, which has 145 GitHub stars. The repository holds 20 skills in this directory. The repository was last updated on October 5, 2026.

Source: yamcodes/arkenv on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.