| name | hexagon-scaffold |
|---|---|
| description | Use when implementing a new feature slice in the template's hexagonal architecture across core, ports, adapters, and tests. |
Use when you need to add a new business capability that should follow the repository's ports-and-adapters structure from the start.
application/src/main/java/.../core/domainapplication/src/main/java/.../core/ports/inputapplication/src/main/java/.../core/ports/outputapplication/src/main/java/.../core/usecasesapplication/src/main/java/.../adapters/input/*application/src/main/java/.../adapters/output/*- matching tests under
application/src/test/java/...
- new aggregates or domain concepts
- new commands or queries exposed via REST or messaging
- new outbound integrations such as database, HTTP, or event publishing
- feature slices that need the usual DTO, mapper, port, use case, and adapter wiring
- Business capability and observable operations
- Domain fields and invariants
- Required inbound adapters such as REST or Kafka
- Required outbound adapters such as JPA, Feign, or Kafka
- Validation, error, and persistence expectations
- Start with
tdd-loop: pick the smallest failing test that describes the next behavior increment, preferably in the core. - Define domain records or value objects and the smallest input or output port set that expresses the use case.
- Implement package-private use cases that implement input ports and depend only on output ports and domain types.
- Add inbound adapters that translate transport concerns into the input-port API.
- Add outbound adapters that implement output ports and keep framework details out of the core.
- Add mapper, DTO, and entity layers only where boundaries require them.
- Mirror existing patterns before inventing new ones:
UserCreatorUseCase,UserController,UserRepository,AddressClient, andUserEventDispatcher. - Keep the red-green-refactor cycle tight: make the smallest production change for the current failing test, then let
archunit-guardverify the structure.
- Domain model and exceptions or value objects as needed
- Input and output ports with the
Portsuffix - Package-private use case implementations with the
UseCasesuffix - Adapter implementations, DTOs or entities, and mappers only where needed
- Unit test coverage for core logic and adapter boundaries, written first through the TDD loop
- Keep the core framework-agnostic.
- Use cases must not depend on other use cases directly.
- Prefer package-private implementations to hide internals.
- Reuse existing naming, packaging, and mapper patterns.
- Use
make run-unit-testsas the default validation target. - If the feature changes long-lived architecture constraints, route to
docs-adrordocs-design-docbefore scaffolding.