agentleFS
troskatertroskater/flowdeck-claude/skills/hexagonal-architecture/SKILL.md

hexagonal-architecture

Skill0 starsChanged 23 days agoMITView on GitHub

Ports-and-adapters architecture patterns for testable, framework-independent domain logic.

24 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use domain-driven-design, improve-codebase-architecture and 1 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.
  • 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 4 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 3 projects that use this

  • GoogleSkill

    grill-me

    A relentless interview to sharpen a plan or design.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 23 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When building applications that must remain flexible to changing external systems (databases, APIs, UI frameworks) and need to support …

    line 10
  2. Distinctive:

    Define inbound ports: - Create interfaces (ports) for primary/ driving actors (UI, API controllers) that trigger application logic.

    line 14
  3. Distinctive:

    Define outbound ports: - Create interfaces (ports) for secondary/ driven actors (databases, external services) that the domain calls.

    line 15
  4. Distinctive:

    Implement primary adapters: - Create adapters for inbound traffic (REST controllers, GraphQL resolvers, CLI commands).

    line 16
  5. Distinctive:

    Implement secondary adapters: - Create adapters for outbound traffic (Postgres repositories, Redis caches, email gateways).

    line 17

“Common” is measured: kept by at least 6 in 10 of the 23 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

When to Activate

When building applications that must remain flexible to changing external systems (databases, APIs, UI frameworks) and need to support multiple entry points (ports) for the same business logic.

Steps

  1. Identify the core domain - Isolate the pure business logic that makes no references to infrastructure.
  2. Define inbound ports - Create interfaces (ports) for primary/ driving actors (UI, API controllers) that trigger application logic.
  3. Define outbound ports - Create interfaces (ports) for secondary/ driven actors (databases, external services) that the domain calls.
  4. Implement primary adapters - Create adapters for inbound traffic (REST controllers, GraphQL resolvers, CLI commands).
  5. Implement secondary adapters - Create adapters for outbound traffic (Postgres repositories, Redis caches, email gateways).
  6. Ensure domain has no external dependencies - The domain layer should compile and run with no imports from adapters.
  7. Wire via dependency injection - Connect adapters to ports at application startup.

Examples

// Domain Core - Pure business logic, no infrastructure dependencies
class Transfer {
  constructor(
    public readonly fromAccountId: string,
    public readonly toAccountId: string,
    public readonly amount: number
  ) {}

  execute(accounts: Map<string, Account>): TransferResult {
    const from = accounts.get(this.fromAccountId)
    const to = accounts.get(this.toAccountId)

    if (!from || !to) {
      return TransferResult.failed('Account not found')
    }

    if (!from.canDebit(this.amount)) {
      return TransferResult.failed('Insufficient funds')
    }

    from.debit(this.amount)
    to.credit(this.amount)

    return TransferResult.success()
  }
}

// Inbound Port (Primary Port) - Interface for driving operations
interface TransferUseCase {
  execute(transfer: Transfer): TransferResult
}

// Outbound Port (Secondary Port) - Interface for driven operations
interface AccountRepository {
  findById(id: string): Promise<Account | null>
  save(account: Account): Promise<void>
}

interface EventBus {
  publish(event: DomainEvent): Promise<void>
}

// Primary Adapter - REST API
class TransferController implements TransferUseCase {
  constructor(private readonly accounts: AccountRepository) {}

  async execute(transfer: Transfer): Promise<TransferResult> {
    const allAccounts = await this.accounts.findById(transfer.fromAccountId)
    // ... handle via injected port
  }
}

// Secondary Adapter - PostgreSQL implementation
class PostgresAccountRepository implements AccountRepository {
  constructor(private readonly db: Database) {}
  // ... implementation
}

Related Skills

  • clean-architecture
  • layered-architecture
  • ddd-architecture
  • backend-patterns

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.