implement-usecase

Implements Go usecase layer commands and queries with transaction and aggregate coordination conventions.

Updated Sep 14, 2026
One-click install
npx skills add https://github.com/nakamori-naoya/go-convention-plugins --skill implement-usecase-nakamori-naoya
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: implement-usecase
Source: https://github.com/nakamori-naoya/go-convention-plugins/tree/main/plugins/go-convention/skills/implement-usecase
Command: npx skills add https://github.com/nakamori-naoya/go-convention-plugins --skill implement-usecase-nakamori-naoya

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing the application (usecase) layer in Go DDD projects often leads to inconsistent transaction boundaries, business logic leaking out of the domain, and unclear handling of multi-aggregate coordination. This Skill enforces a single convention for implementing usecases so every command and query follows the same structure. ## Core Features & Use Cases - Command implementation: Writes one type per business event with a single Execute method following the fixed pipeline: resolve inputs, open a transaction via tx.Manager.Run, restore or generate the aggregate, narrow state, operate, and save. - Query implementation: Defines read ports and DTO read models owned by the usecase side, with no aggregate restoration, no writes, and no transactions. - Cross-aggregate coordination: Decides between same-transaction operations and event-driven separate usecases based on the consistency rules in domain-model documents. - Use Case: Given a domain-model document describing a room reservation aggregate, generate the HoldReservation and ConfirmReservation usecases with correct ID generation, time handling via Input At, sentinel error wrapping, and overlap invariant checks. ## Quick Start Implement the reservation confirm usecase in Go following the implement-usecase conventions from this domain-model document.

Frequently Asked Questions about implement-usecase

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a Go usecase command in DDD?▼

Create one type per business event with a single Execute method that resolves primitive inputs into value objects, opens a transaction with tx.Manager.Run, then restores or generates the aggregate, narrows its state, calls the operation, and saves the result. Keep all business decisions inside the domain.

How should transactions be handled in a Go usecase layer?▼

Only command usecases open transactions, using tx.Manager.Run with one transaction per business event. Queries never open transactions. Repositories and read port implementations join the transaction from context rather than starting their own.

Where should ID generation and timestamps live in DDD usecases?▼

The usecase generates IDs through an IDGenerator interface only when creating new aggregates, while timestamps arrive via the Input At field set by the caller. The usecase never holds a Clock or calls time.Now, keeping execution deterministic and testable.

How do I coordinate multiple aggregates in one Go usecase?▼

Follow the consistency rule in the domain-model document: use a single transaction when the document says same operation, or a separate usecase triggered by a domain event for eventual consistency. Never let one usecase call another usecase directly.

What belongs outside the usecase layer in Go DDD?▼

Business rules stay in aggregates and value objects, SQL stays in repository and query implementations, transport concerns like proto and connect stay at the RPC boundary, and error classification, logging, and testing follow their own separate conventions.