Skip to content

feat: add hexagonal architecture SKILL.#1034

Merged
affaan-m merged 1 commit into
affaan-m:mainfrom
Divya-Somashekar:feat/hexagonal-architecture
Mar 31, 2026
Merged

feat: add hexagonal architecture SKILL.#1034
affaan-m merged 1 commit into
affaan-m:mainfrom
Divya-Somashekar:feat/hexagonal-architecture

Conversation

@Divya-Somashekar

@Divya-Somashekar Divya-Somashekar commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

🚀 Add Hexagonal Architecture Skill

📌 Overview

This PR introduces a new skill: Hexagonal Architecture (Ports & Adapters).

The goal of this skill is to guide AI agents in designing and refactoring systems using a clean, maintainable, and testable architecture pattern that decouples business logic from infrastructure concerns.


🎯 Why this is useful

Hexagonal Architecture is widely used in modern backend systems to:

  • Improve separation of concerns
  • Enable easier testing (domain without infrastructure)
  • Reduce coupling to frameworks (Spring, DBs, external APIs)
  • Support long-term maintainability and scalability

This aligns well with the repository’s focus on high-quality engineering patterns and reusable workflows.


🧠 What this skill provides

The skill helps agents:

  • Identify core domain logic vs infrastructure
  • Define ports (interfaces) and adapters (implementations)
  • Refactor tightly coupled code into modular layers
  • Enforce clean boundaries between:
    • Domain
    • Application
    • Infrastructure

⚙️ Capabilities

  • Analyze existing codebases for architectural issues
  • Suggest hexagonal refactoring strategies
  • Generate boilerplate structure for:
    • Ports (interfaces)
    • Adapters (DB, messaging, REST)
  • Guide testability improvements (mocking ports)

💡 Example use cases

  • Refactoring legacy Spring Boot applications
  • Designing microservices with clear boundaries
  • Improving testability of business logic
  • Preparing codebases for scalability and maintainability

📂 Structure

  • Added new skill under skills/hexagonal-architecture/
  • Includes:
    • Clear instructions for agents
    • Step-by-step transformation guidance
    • Practical examples

🔍 Notes for reviewers

  • Follows existing skill structure and conventions
  • Designed to be generic (framework-agnostic)
  • Complements existing architecture/design skills

📈 Impact

This contribution enhances the repository by adding:

  • A widely adopted architectural pattern
  • A high-value backend engineering workflow
  • Better support for real-world system design problems

🙌 Future improvements (optional)

  • Add framework-specific variants (e.g., Spring Boot)
  • Combine with testing/TDD skills
  • Integrate with microservices orchestration workflows

@coderabbitai

coderabbitai Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

A new Hexagonal Architecture skill documentation file is added, covering architectural principles, design patterns, implementation examples in TypeScript, cross-language guidance, anti-patterns, migration strategies, and testing practices.

Changes

Cohort / File(s) Summary
Hexagonal Architecture Documentation
skills/hexagonal-architecture/SKILL.md
New skill document introducing Hexagonal Architecture concepts, including domain model definitions, port/adapter patterns, dependency direction rules, architectural diagrams, TypeScript implementation examples with use cases and adapters, cross-language mapping, anti-patterns, incremental migration guidance, and testing strategies.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • affaan-m

Poem

🐰 A rabbit hops through ports and walls so fine,
Where adapters dance and boundaries align,
Hexagons bloom with knowledge pure and bright,
Architecture documented—what a delight!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a new Hexagonal Architecture documentation skill file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps

greptile-apps Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds skills/hexagonal-architecture/SKILL.md, a new curated skill document for Ports & Adapters (Hexagonal Architecture) design. The skill covers core concepts, a step-by-step workflow, a TypeScript reference implementation, multi-language mapping (TypeScript, Java, Kotlin, Go), anti-patterns, a migration playbook, testing guidance, and a best-practices checklist. It follows the existing skill format (YAML frontmatter, origin: ECC, clear section structure) and slots correctly into skills/ as a curated document per the placement policy in CLAUDE.md.

  • The content is accurate, comprehensive, and internally consistent with the hexagonal architecture pattern.
  • The TypeScript examples (port interfaces, use case, outbound adapter, composition root) are syntactically and logically correct.
  • The immutability principle (returning authorizedOrder from markAuthorized rather than mutating order) is called out explicitly in comments — a minor inconsistency exists where order.id is used in the return value instead of authorizedOrder.id, though the values are identical at runtime.
  • The ## TypeScript Example section is missing an inbound adapter code snippet, despite the module layout and all conceptual sections treating it as a first-class boundary.
  • The PR description template was left entirely unfilled (no "What Changed", "Why This Change", or testing notes), and none of the checklist boxes are checked.

Confidence Score: 5/5

Safe to merge — this is a documentation-only addition with no executable code, no secrets, and no impact on existing functionality.

All findings are P2 style/completeness suggestions (one minor wording consistency in the immutable-return example, one missing inbound adapter snippet). There are no P0 or P1 issues. The skill follows the established format, is placed in the correct directory, and the content is technically sound.

No files require special attention; the single changed file is a markdown skill document with no executable logic.

Important Files Changed

Filename Overview
skills/hexagonal-architecture/SKILL.md New skill document for Hexagonal (Ports & Adapters) architecture — well-structured with core concepts, TypeScript examples, multi-language mapping, migration playbook, and testing guidance; no logic or security issues found.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    Client["Client (HTTP / CLI / Worker)"] --> InboundAdapter["Inbound Adapter\n(e.g. createOrderRoute.ts)"]
    InboundAdapter -->|"maps protocol input →\nuse-case input"| UseCase["Use Case\n(CreateOrderUseCase)"]
    UseCase -->|"calls"| OutboundPort1["Outbound Port\n(OrderRepositoryPort)"]
    UseCase -->|"calls"| OutboundPort2["Outbound Port\n(PaymentGatewayPort)"]
    UseCase -->|"orchestrates"| Domain["Domain Model\n(Order, OrderPolicy)"]
    OutboundAdapter1["Outbound Adapter\n(PostgresOrderRepository)"] -->|"implements"| OutboundPort1
    OutboundAdapter2["Outbound Adapter\n(StripePaymentGateway)"] -->|"implements"| OutboundPort2
    OutboundAdapter1 --> DB[("PostgreSQL")]
    OutboundAdapter2 --> Stripe["Stripe API"]
    CompositionRoot["Composition Root\n(ordersContainer.ts)"] -.->|"wires"| UseCase
    CompositionRoot -.->|"instantiates"| OutboundAdapter1
    CompositionRoot -.->|"instantiates"| OutboundAdapter2
Loading

Reviews (1): Last reviewed commit: "feat: add hexagonal architecture SKILL." | Re-trigger Greptile

Comment on lines +165 to +170
return {
orderId: order.id,
authorizationId: auth.authorizationId,
};
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Use authorizedOrder.id for consistency in return value

The execute method saves authorizedOrder (the post-markAuthorized instance) to the repository, but the returned DTO still references order.id. Since markAuthorized only changes the authorization state and not the ID, the values are identical at runtime — however, for a reference document that explicitly demonstrates immutable transformations, using authorizedOrder.id in the output would reinforce the principle and avoid any reader confusion about which object's data is being returned.

Suggested change
return {
orderId: order.id,
authorizationId: auth.authorizationId,
};
}
}
return {
orderId: authorizedOrder.id,
authorizationId: auth.authorizationId,
};

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

ordersContainer.ts
```

## TypeScript Example

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing inbound adapter TypeScript example

The ## TypeScript Example section covers port definitions, the use-case class, the outbound adapter, and the composition root — but omits an inbound adapter example. The module layout references createOrderRoute.ts, and the "Core Concepts" and "How It Works" sections describe inbound adapters as a first-class concern. Adding a short Express/Fastify route snippet (mapping req.bodyCreateOrderInput → calling useCase.execute → mapping the result to an HTTP response) would make the section complete and directly illustrate the boundary that most readers will implement first.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
skills/hexagonal-architecture/SKILL.md (1)

119-202: LGTM! Comprehensive TypeScript example demonstrates key concepts.

The TypeScript example effectively illustrates:

  • Clean port interface definitions
  • Use case orchestration with dependency injection
  • Outbound adapter implementation
  • Explicit composition root wiring

The comment at line 161 explaining immutability is helpful. The example correctly shows ports as abstractions with concrete implementations in adapters.

Consider showing the Order domain entity.

The example references Order.create() (line 154), order.markAuthorized() (line 162), and Order.rehydrate() (line 188), but the Order domain entity implementation is not shown. While the focus is on architecture boundaries, showing a brief domain entity example would make the skill more complete and help readers understand what "business rules and entities/value objects" (line 22) look like in practice.

📝 Optional: Add Order domain entity example

Consider adding this example after line 122 or in a separate domain section:

// Domain entity - no framework dependencies
export class Order {
  private constructor(
    public readonly id: string,
    public readonly amountCents: number,
    public readonly status: 'pending' | 'authorized',
    public readonly authorizationId?: string
  ) {}

  static create(props: { id: string; amountCents: number }): Order {
    if (props.amountCents <= 0) {
      throw new Error('Order amount must be positive');
    }
    return new Order(props.id, props.amountCents, 'pending');
  }

  markAuthorized(authorizationId: string): Order {
    return new Order(this.id, this.amountCents, 'authorized', authorizationId);
  }

  static rehydrate(row: any): Order {
    return new Order(row.id, row.amount_cents, row.status, row.authorization_id);
  }
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/hexagonal-architecture/SKILL.md` around lines 119 - 202, Add a brief
Order domain-entity example to the TypeScript sample so the referenced methods
are defined: create a simple Order class that includes a static create(id,
amountCents), an instance method markAuthorized(authorizationId) that returns a
new Order, and a static rehydrate(row) to map DB rows to Order instances; insert
this class near the top of the example (before CreateOrderUseCase) so calls to
Order.create, order.markAuthorized, and Order.rehydrate resolve and readers can
see the business-rule checks and immutability behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@skills/hexagonal-architecture/SKILL.md`:
- Around line 119-202: Add a brief Order domain-entity example to the TypeScript
sample so the referenced methods are defined: create a simple Order class that
includes a static create(id, amountCents), an instance method
markAuthorized(authorizationId) that returns a new Order, and a static
rehydrate(row) to map DB rows to Order instances; insert this class near the top
of the example (before CreateOrderUseCase) so calls to Order.create,
order.markAuthorized, and Order.rehydrate resolve and readers can see the
business-rule checks and immutability behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e0fa87cc-dc22-4281-a335-48d9a984fff4

📥 Commits

Reviewing files that changed from the base of the PR and between e68233c and b611c6a.

📒 Files selected for processing (1)
  • skills/hexagonal-architecture/SKILL.md

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="skills/hexagonal-architecture/SKILL.md">

<violation number="1" location="skills/hexagonal-architecture/SKILL.md:156">
P2: The example authorizes payment before persisting the order, which can leave authorized payments without a saved order when persistence fails.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

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

const auth = await this.paymentGateway.authorize({

@cubic-dev-ai cubic-dev-ai Bot Mar 31, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The example authorizes payment before persisting the order, which can leave authorized payments without a saved order when persistence fails.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At skills/hexagonal-architecture/SKILL.md, line 156:

<comment>The example authorizes payment before persisting the order, which can leave authorized payments without a saved order when persistence fails.</comment>

<file context>
@@ -0,0 +1,276 @@
+  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,
</file context>
Fix with Cubic

@affaan-m affaan-m merged commit 9b611f1 into affaan-m:main Mar 31, 2026
4 checks passed
peiking88 pushed a commit to peiking88/everything-claude-code that referenced this pull request Apr 4, 2026
FrancescoRosciano pushed a commit to FRosciano-Mambo/everything-claude-code that referenced this pull request Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants