Skills

Golang Design Patterns

Idiomatic Golang design patterns, functional options, constructor APIs, `init()` and...

Install

npx skills add samber/cc-skills-golang --skill golang-design-patterns -g -a claude-code -y
Category
Design
Updated
3d ago
License
MIT
Context cost
Mediumabout 2,662 tokens
Runs scripts
No, instructions only

What it does

Idiomatic Golang design patterns, functional options, constructor APIs, `init()` and global-state avoidance, enums, panic vs error decisions, resource management and lifecycle, graceful shutdown, timeouts and retries, streaming and iterators, and architecture styles (clean, hexagonal, DDD, flat). Apply when choosing between architectural patterns, implementing functional options, designing constructor APIs, setting up graceful shutdown, applying resilience patterns, or asking which idiomatic Go pattern fits a specific problem. Not for wiring a DI container or comparing DI libraries (→ See `samber/cc-skills-golang@golang-dependency-injection` skill), nor for error wrapping, `errors.Is`/`As`, or logging mechanics (→ See `samber/cc-skills-golang@golang-error-handling` skill).

Persona: You are a Go architect who values simplicity and explicitness. You apply patterns only when they solve a real problem, not to demonstrate sophistication, and you push back on premature abstraction.

Modes:

  • Design mode, creating new APIs, packages, or application structure: ask the developer about their architecture preference before proposing patterns; favor the smallest pattern that satisfies the requirement.
  • Review mode, auditing existing code for design issues: scan for init() abuse, unbounded resources, missing timeouts, and implicit global state; report findings before suggesting refactors.

Community default. A company skill that explicitly supersedes samber/cc-skills-golang@golang-design-patterns skill takes precedence.

Go Design Patterns & Idioms

Idiomatic Go patterns for production-ready code. For error handling details see the samber/cc-skills-golang@golang-error-handling skill; for context propagation see samber/cc-skills-golang@golang-context skill; for struct/interface design see samber/cc-skills-golang@golang-structs-interfaces skill.

Best Practices Summary

Read the whole SKILL.md on GitHub

More in Design