Agent-skills-standard golang-architecture
Structure Go projects with Clean Architecture and standard layout conventions. Use when structuring Go projects or applying Clean Architecture in Go. (triggers: go.mod, internal/**, architecture, structure, folder layout, clean arch, dependency injection)
install
source · Clone the upstream repo
git clone https://github.com/HoangNguyen0403/agent-skills-standard
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/HoangNguyen0403/agent-skills-standard "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/golang/golang-architecture" ~/.claude/skills/hoangnguyen0403-agent-skills-standard-golang-architecture && rm -rf "$T"
manifest:
skills/golang/golang-architecture/SKILL.mdsource content
Golang Architecture
Priority: P0 (CRITICAL)
Principles
- Clean Architecture: Inner layers (Domain) rely on nothing. Outer layers (Adapters) rely on inner.
- Project Layout: Follow standard Go layout (
,cmd
,internal
).pkg - Dependency Injection: Pass dependencies via constructors. Avoid global singletons.
- Package Oriented Design: Organize by feature/domain, not by layer.
- Interface Segregation: Define interfaces where they used (consumer side).
Implementation Workflow
- Set up project layout — Use
for entry points,cmd/
for private packages,internal/
for shared libraries.pkg/ - Define domain layer — Inner-most layer with zero external dependencies.
- Build use cases — Depend only on Domain interfaces.
- Implement adapters — Outer layer depends on UseCase/Domain. Contains HTTP handlers, DB repos, etc.
- Wire in main — Compose full dependency graph in
.main.go
See constructor injection and wiring examples
Verification Checklist
- No global singletons or package-level mutable variables
- Dependencies explicitly passed via constructors
- Interfaces defined at consumer side
-
zero external dependenciesinternal/domain - Dependencies wired together in
main.go
Anti-Patterns
- No global singletons: use DI; avoid package-level mutable variables.
- No layer violations: keep Domain imports isolated from adapter/infrastructure layers.
- No god services: split services into single-responsibility components.