apply-go-package-layout

Maps confirmed logical responsibilities onto Go package trees and enforces import direction rules.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Go projects often drift into tangled package structures with import cycles, misplaced responsibilities, and ambiguous ownership. This Skill translates already-decided logical responsibilities (domain, repository, usecase, query, handler) into a deterministic Go 1.27 directory and package layout, then fixes import direction violations. ## Core Features & Use Cases - Logical-to-physical mapping: Converts confirmed aggregate boundaries and Command/Query classifications into a per-aggregate package tree (domain, repository, usecase/command, usecase/query, query, handler). - Import direction enforcement: Applies a strict import permission table so domain never imports outer layers, query implementations depend on usecase/query contracts, and handlers never touch DB implementations directly. - Verification and repair: Rewrites import paths, generation configs, and composition roots, then validates with gofmt, go list, go build, go vet, and import cycle checks. - Use Case: Given a reservation aggregate with a read port and sqlc-based implementation, place the contract in reservation/usecase/query and the implementation in reservation/query, with imports flowing from implementation to contract. ## Quick Start Ask the AI to apply the Go package layout convention to your module by providing the module root path and the confirmed logical responsibilities for each code element.

Frequently Asked Questions about apply-go-package-layout

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

FAQPage Schema
How do I organize Go packages for DDD and CQRS?▼

Place each aggregate under its context with domain, repository, usecase/command, usecase/query, query, and handler directories. Keep query contracts in usecase/query and their implementations in query, with imports flowing from implementation to contract.

How to fix import cycles in a Go project?▼

Import cycles are resolved by enforcing a one-directional dependency table: domain imports nothing outward, usecases depend on inner ports, and only the composition root wires implementations. Cycles are never hidden with interface duplication, transfer types, or shim packages.

Where should query read models live in a Go DDD project?▼

Read ports and flat read models belong to usecase/query, which owns the read contract. The query package holds only the SQL implementation that satisfies that interface and returns the contract's types.

When should a command go into an orchestration package?▼

Only commands that write to two or more aggregate repositories go into orchestration/usecase/command. A command that merely reads another aggregate stays in the triggering aggregate's usecase/command package.

Does this approach create compatibility shim packages when moving code?▼

No. The convention explicitly forbids compatibility packages, aliases, or shims that keep old import paths alive. Moves are completed fully, with all references, generation configs, and tests updated and verified.