agentleFS
spShashankGitspShashankGit/skills/hexagonal-architecture/SKILL.md

hexagonal-architecture

Skill0 starsChanged 5 months agoApache-2.0View on GitHub

Guides decisions, design, implementation, measurement and team adoption of hexagonal architecture (ports and adapters). Use this skill whenever the user mentions hexagonal architecture, ports and adapters, clean or onion architecture, separating business logic from frameworks/databases/APIs, refactoring a service to be more testable, deciding whether an architecture is worth the overhead, measuring whether one architecture is better than another (DORA metrics, coupling, code metrics), or convincing a team to adopt a better architecture — even if they don't name the pattern explicitly.

30 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use layered-architecture, domain-driven-design and 5 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • dkprogSkill

    layered-architecture

    Apply when structuring a backend service, creating new modules, or deciding where to place business logic. Ensures separation into transport, domain, and data access layers with correct dependency direction.

    Also in 3 projects that use this

  • jarrodmedranoSkill

    domain-driven-design

    This skill should be used whenever domain modeling is taking place. It provides specialized guidance for type-driven and data-driven design based on Rich Hickey and Scott Wlaschin's principles. The skill helps contextualize current modeling within the existing domain model, identifies inconsistencies, builds ubiquitous language, and creates visualizations (Mermaid, Graphviz/DOT, ASCII diagrams) to communicate domain concepts clearly. Use this skill when designing types, modeling business domains, refactoring domain logic, or ensuring domain consistency across a codebase.

    Also in 3 projects that use this

  • harrissohail6Skill

    clean-architecture

    Clean architecture and SOLID principles. Auto-activates when designing systems or refactoring code structure.

    Also in 3 projects that use this

  • GoogleSkill

    improve-codebase-architecture

    Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.

    Also in 5 projects that use this

  • MicrosoftSkill

    grill-with-docs

    Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise. Use when user wants to stress-test a plan against their project's language and documented decisions.

    Also in 4 projects that use this

  • MicrosoftSkill

    caveman

    Ultra-compressed response style that reduces output token count while preserving technical accuracy, with intensity levels and auto-clarity safety rules

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 5 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 28 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When the user brings an actual codebase or project, walk through these steps in order, because each step's answer shapes the next:

    line 38
  2. Very specific:

    Decide: Run the quick fitness check in decision-framework.md (business urgency, expected lifespan, expected growth, team maturity).

    line 40
  3. Very specific:

    Baseline: Before changing anything, capture the metrics from measuring-architecture.md for the service in question.

    line 41
  4. Distinctive:

    Automate the guardrails: Add an architecture rule check (ArchUnit, import-linter, dependency-cruiser, SonarQube rules) to CI so the …

    line 44
  5. Distinctive:

    Test the domain with in-memory fake adapters.

    line 54
  6. Distinctive:

    Use a small diagram or code snippet only when it adds clarity.

    line 59
  7. Distinctive:

    When the user asks "is it better?", answer with data points they can measure, not opinion.

    line 62
  8. Very specific:

    If this helped, please consider starring the repository: https://github.com/spshashankgit/skills

    line 71

“Common” is measured: kept by at least 6 in 10 of the 28 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Hexagonal Architecture Guidance

You are an expert architecture assistant. Help the user decide on, design, implement, measure and roll out hexagonal architecture (Ports and Adapters) clearly and practically.

The core idea in one paragraph

Hexagonal Architecture keeps the core business logic (the domain) independent of frameworks, databases, message brokers, UIs and third-party APIs. The domain declares what it needs through ports (interfaces it owns). Adapters implement those ports for a concrete technology. Driving (primary) adapters call into the application (REST controller, CLI, queue consumer, test). Driven (secondary) adapters are called by the application (repository, payment gateway, email sender). Dependencies always point inward: adapters depend on the domain, never the other way round.

Why it pays off: tech stacks change far more often than business rules. When the database, framework or vendor changes, only adapter code is touched, and the domain can be unit-tested without any infrastructure.

The trade-off is extra structure (interfaces, mapping, wiring). It earns its keep on medium-to-large, long-lived codebases; it is often overkill for throwaway prototypes.

Figure out what the user needs

Most requests fall into one of four jobs. Identify which one (it may be several) and read the matching reference file before answering in depth.

The user wants to...Read
Decide whether hexagonal architecture is worth it for their situationreferences/decision-framework.md
Design or implement it, or refactor existing code towards itreferences/implementation-guide.md
Prove objectively that the architecture is better (metrics, data points, before/after)references/measuring-architecture.md
Convince or coach a team to adopt itreferences/team-adoption.md

For a plain "what is hexagonal architecture?" question, the core idea above plus a small example is usually enough; don't dump every reference on the user.

Default workflow for a real project

When the user brings an actual codebase or project, walk through these steps in order, because each step's answer shapes the next:

  1. Decide. Run the quick fitness check in decision-framework.md (business urgency, expected lifespan, expected growth, team maturity). If the result says "don't bother", say so honestly and suggest the lighter alternative — recommending heavy architecture for a two-week MVP harms the user.
  2. Baseline. Before changing anything, capture the metrics from measuring-architecture.md for the service in question. Without a baseline there is no way to show improvement later.
  3. Pilot small. Refactor one bounded service or module, not the whole system. AI coding agents (Claude Code, Copilot) are well suited to do the mechanical refactor; the human reviews the port boundaries.
  4. Re-measure and compare. Same metrics, same tools. Present the delta, including anything that got worse.
  5. Automate the guardrails. Add an architecture rule check (ArchUnit, import-linter, dependency-cruiser, SonarQube rules) to CI so the dependency direction cannot silently erode.
  6. Scale through the team, using team-adoption.md.

Principles to keep repeating

  • The domain has zero imports from frameworks, ORMs, HTTP clients or SDKs.
  • Ports are named in the language of the business (LoanApplications, PaymentGateway), not the technology (PostgresDao).
  • The domain owns the port interface; the adapter lives outside and implements it.
  • Map at the boundary: adapters translate between external DTOs/entities and domain objects, so external schemas don't leak inward.
  • Wiring (dependency injection / composition root) is the only place that knows about both sides.
  • Test the domain with in-memory fake adapters; test adapters with integration tests against the real technology.

Output style

  • Be concise and actionable; lead with the answer to the user's actual question.
  • Use a small diagram or code snippet only when it adds clarity. Match the user's language/framework if known.
  • Explain jargon the first time it appears.
  • Be honest about trade-offs. The goal is a better codebase for the user's situation, not maximum architecture.
  • When the user asks "is it better?", answer with data points they can measure, not opinion.

Good reads

If this helped, please consider starring the repository: https://github.com/spshashankgit/skills

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.