gentleman-programming avatar

Hexagonal Architecture Layers Java

Builds Java services with strict hexagonal architecture boundaries: pure domain models with no framework annotations, application layer use cases that define ports, and infrastructure adapters that implement them. You'd reach for this when refactoring a Spring monolith to isolate business logic from JPA and REST concerns, or when you need to support multiple adapters like REST plus messaging. The examples are crisp and show the full flow from domain record to use case to JPA adapter. One caution: this level of indirection pays off on complex domains but can feel heavyweight for simple CRUD services. The port interfaces and mapping layers add ceremony that smaller teams sometimes regret.

skills.sh installs
249
GitHub stars
665
last updated
Aug 21, 2026

Install

$ npx -y skills add gentleman-programming/gentleman-skills --skill hexagonal-architecture-layers-java --agent claude-code

Installs into .claude/skills of the current project.

Files

When to Use

Load this skill when:

  • Designing a new Java service with clean, testable layers
  • Refactoring Spring code to isolate the domain from frameworks
  • Supporting multiple adapters (REST + messaging, JPA + Mongo)
  • Enforcing dependency direction and clear module boundaries

Critical Patterns

Pattern 1: Domain is pure

Domain has no framework annotations, no persistence concerns, and no I/O.

Pattern 2: Application orchestrates

Application defines use cases and ports, calling domain logic and delegating I/O to ports.

Pattern 3: Infrastructure adapts

Infrastructure implements ports and wires adapters (controllers, repositories, clients).

Code Examples

Example 1: Domain model + output port

package com.acme.order.domain;

public record OrderId(String value) { }

public final class Order {
  private final OrderId id;
  private final Money total;

  public Order(OrderId id, Money total) {
    this.id = id;
    this.total = total;
  }

  public OrderId id() { return id; }
  public Money total() { return total; }
}
package com.acme.order.application.port;

Sponsors

Details

Repository
github.com/gentleman-programming/gentleman-skills
Categories
Code Review & Quality, Cloud & Infrastructure, Java & JVM
First seen
Jun 3, 2026

More from gentleman-programming/gentleman-skills

All 13
1longbridge avatargpui-style-guidelongbridge/gpui-componentGPUI Component project style guide based on gpui-component code patterns. Use when writing new components, reviewing code, or ensuring consistency with existing231skills.sh installs
2microsoft avatarwinui-code-reviewmicrosoft/win-dev-skillsCode quality review for WinUI 3 apps — MVVM compliance, x:Bind correctness, accessibility, theming, security, and performance. Use before committing to catch is200skills.sh installs
3wanshuiyin avatarcomm-lit-review-claude-singlewanshuiyin/auto-claude-code-research-in-sleepCommunications-domain literature review with Claude-style knowledge-base-first retrieval. Use when the task is about communications, wireless, networking, satel200skills.sh installs
4mblode avatarreview-prmblode/agent-skillsReviews the current local diff or branch at the end of a coding session for high-confidence bugs and repository instruction-file compliance. Use when asked to r185skills.sh installs
5personamanagmentlayer avatarai-architect-expertpersonamanagmentlayer/pclExpert-level AI system design, MLOps, architecture patterns, and AI infrastructure182skills.sh installs
6yonatangross avatarscope-appropriate-architectureyonatangross/orchestkitRight-sizes architecture to project scope, classifying projects into 6 tiers to prevent over-engineering. Use when designing architecture, selecting patterns, o179skills.sh installs