Skip to content
alyn
Gentleman-Programming

Hexagonal Architecture Layers Java skill

Hexagonal architecture layering for Java services with strict boundaries. Trigger: When structuring Java apps by Domain/Application/Infrastructure, or refactoring toward clean architecture.

$npx skills add Gentleman-Programming/Gentleman-Skills --skill hexagonal-architecture-layers-java
View this skill on GitHubGentleman-Programming/Gentleman-Skills/community/hexagonal-architecture-layers-java/SKILL.md
Pack stars
665
Pack installs
5.6k
Alyn Score
43/99
Updated
8 months ago
License
MIT
– views – installs via Alyn

Gentleman-Programming

Hexagonal Architecture Layers Java

Install Hexagonal Architecture Layers Java

Pick your agent. Every command is ready to paste.

$npx skills add Gentleman-Programming/Gentleman-Skills --skill hexagonal-architecture-layers-java

The open skills CLI detects your agents (Claude Code, Cursor, Codex and 70+ more) and installs to the right folder. Add -g to install globally.

01

Install it

Run the command above, or upload the folder in Claude.

02

Ask naturally

Describe the task. Your agent loads hexagonal-architecture-layers-java when the request matches its description.

03

Name it if needed

If it does not trigger, say “use the hexagonal-architecture-layers-java skill”. In Codex, type $hexagonal-architecture-layers-java.

The skill itself

SKILL.md

FolderGitHub

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;

import com.acme.order.domain.Order;
import com.acme.order.domain.OrderId;

public interface OrderRepositoryPort {
  OrderId nextId();
  void save(Order order);
}

Example 2: Application use case + input port

package com.acme.order.application.usecase;

import com.acme.order.application.port.OrderRepositoryPort;
import com.acme.order.domain.Order;
import com.acme.order.domain.OrderId;
import com.acme.order.domain.Money;

public interface PlaceOrderUseCase {
  OrderId place(Money total);
}

public final class PlaceOrderService implements PlaceOrderUseCase {
  private final OrderRepositoryPort repository;

  public PlaceOrderService(OrderRepositoryPort repository) {
    this.repository = repository;
  }

  @Override
  public OrderId place(Money total) {
    OrderId id = repository.nextId();
    Order order = new Order(id, total);
    repository.save(order);
    return id;
  }
}

Example 3: Infrastructure adapter + wiring

package com.acme.order.infrastructure.persistence;

import com.acme.order.application.port.OrderRepositoryPort;
import com.acme.order.domain.Order;
import com.acme.order.domain.OrderId;
import org.springframework.stereotype.Repository;

@Repository
public final class OrderJpaAdapter implements OrderRepositoryPort {
  private final SpringOrderRepository repository;
  private final OrderMapper mapper;

  public OrderJpaAdapter(SpringOrderRepository repository, OrderMapper mapper) {
    this.repository = repository;
    this.mapper = mapper;
  }

  @Override
  public OrderId nextId() {
    return new OrderId(java.util.UUID.randomUUID().toString());
  }

  @Override
  public void save(Order order) {
    repository.save(mapper.toEntity(order));
  }
}

Anti-Patterns

Don't: Put framework annotations in domain

// BAD: domain tied to JPA
@jakarta.persistence.Entity
public class Order {
  @jakarta.persistence.Id
  private String id;
}

Don't: Call infrastructure directly from domain

// BAD: domain depends on Spring repository
public class Order {
  private final SpringOrderRepository repository;
}

Quick Reference

Task Pattern
Persist domain data Define output port in application, implement in infrastructure
Expose use case Define input port and service in application
Keep domain pure No annotations, no I/O, no framework imports

Resources

Tips for Hexagonal Architecture Layers Java

  • • Start a fresh session after installing so your agent picks up the new skill.
  • • It is part of a pack with 24 skills. Install only the ones you need with --skill to keep triggers precise.
  • • If two skills overlap, mention the one you want by name.

Questions about Hexagonal Architecture Layers Java

What does the Hexagonal Architecture Layers Java skill do?

Hexagonal architecture layering for Java services with strict boundaries. Trigger: When structuring Java apps by Domain/Application/Infrastructure, or refactoring toward clean architecture.

How do I install Hexagonal Architecture Layers Java?

Run "npx skills add Gentleman-Programming/Gentleman-Skills --skill hexagonal-architecture-layers-java" in your project. The skills CLI installs it for Claude Code, Cursor, Codex and 70+ other agents. In Claude on the web, upload the skill folder as a ZIP under Customize > Skills.

Does Hexagonal Architecture Layers Java work in Cursor and Codex?

Yes. Hexagonal Architecture Layers Java uses the open SKILL.md format, so it works in Claude Code, Claude, Cursor, OpenAI Codex, Gemini CLI, GitHub Copilot and other agents that support agent skills.

Is Hexagonal Architecture Layers Java free?

Hexagonal Architecture Layers Java is open source on GitHub under the MIT license. It is free to install; check the license before commercial use.

Who made Hexagonal Architecture Layers Java?

Hexagonal Architecture Layers Java is published by Gentleman-Programming in the Gentleman-Programming/Gentleman-Skills repository, together with 23 other skills.

Similar skills. From other creators.