Go engineering policies and coding conventions. Always apply together with any Go-related skill or Go coding task. Overrides conflicting recommendations from generic Go style, lint, and general Go guidance. For application architecture and project structure, defer to `go-bounded-context-hexagonal` by default; use generic design-pattern and architecture skills mainly as supporting reference or when analyzing existing third-party codebases that already follow another style.
How this skill is triggered — by the user, by Claude, or both
Slash command
/go-engineering-policy:go-engineering-policyThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
This skill defines Go engineering preferences and conventions.
This skill defines Go engineering preferences and conventions.
When recommendations from other Go-related skills conflict:
go-bounded-context-hexagonal takes precedence for application boundaries, package layout, ports/adapters, wiring, and default project structure in the user's own or new Go applications.Apply these rules during:
Use go-bounded-context-hexagonal by default for:
golang-design-patterns and its architecture references remain useful when:
Overrides conflicting recommendations from:
golang-design-patterns main Architecture sectiongolang-design-patterns/references/architecture.md § Choose the Right Level of Architecturegolang-design-patterns/references/clean-architecture.mdgolang-design-patterns/references/hexagonal-architecture.mdgolang-design-patterns/references/ddd.mdgo.mod:
cmd/app-name/.main() must not contain any code which should be tested.wire.go conventions are defined by go-bounded-context-hexagonal, not by this file.internal/ when they are not part of any single app's public boundary.non-go-project
└── scripts
├── go.mod
├── go.work Contains go version and `use .`, needed for `gorun`.
└── some-name
└── main.go
To run a script: GOWORK="$PWD/scripts/go.work" gorun ./scripts/some-name [args…].
go-library
├── go.mod
├── doc.go
└── *.go
For CLI apps, backend services, modular monoliths, and multi-app repositories, defer to go-bounded-context-hexagonal for the canonical layout instead of using a separate structure from this policy.
Overrides conflicting recommendations from:
Use if init statement ONLY when:
// Good - separate operation and condition for readability.
err := validate(input)
if err != nil {
// code
}
// Bad - operation is not related to condition.
if err := validate(input); err != nil {
// code
}
// Good - same var, another representation needed for a condition.
if value, ok := m[key]; ok {
// code
}
// Bad - scope cluttering.
value, ok := m[key]
if ok {
// code using `value`
}
// code not using `value`
// Good - same var, keeps the same name in a new scope, another representation for a condition.
if err, ok := errors.AsType[*exec.ExitError](err); ok && err.ExitCode() == 2 {
// code
}
// Bad - creating alias; scope cluttering.
errExit, ok := errors.AsType[*exec.ExitError](err)
if ok && errExit.ExitCode() == 2 {
// code
}
If current project uses short type alias for context.Context somewhere then use it everywhere.
type Ctx = context.Context
func doSomething(ctx Ctx, args SomethingArgs) {}
Overrides conflicting recommendations from:
Prefer a Resolvable Config Struct over Functional Options.
The Resolvable Config Struct is a usual Config struct with few extra rules:
Clone() Config if it contains any references (pointer/map/slice/etc.);Resolve() (Config, error) which must:
call Clone() (if implemented), apply defaults, normalize and validate.type TLSMode uint8
const (
TLSDefault TLSMode = iota
TLSEnabled
TLSDisabled
tlsModeCount
)
func (m TLSMode) Valid() bool { return m < tlsModeCount }
// Sentinel.
const NoTimeout time.Duration = -1
type Config struct {
// --- Core fields (no default semantics) ---
AppName string
Tags []string
Headers map[string]string
// --- Options (has defaults) ---
// Zero value is not valid and thus means "use default".
Host string // "" = default
Port int // 0 = default
// Enum (alternative to *bool which does not enforce Clone requirement).
TLS TLSMode // default/enabled/disabled
// Pointer (all values are valid including zero).
WriteBufferBytes *int // nil = default, new(0) = explicit zero
// Sentinel (zero is a valid value, but not all values are valid).
ReadTimeout time.Duration // 0 = default, NoTimeout = disable
// Separate flag/enum (alternative to Pointer and Sentinel).
WriteTimeout time.Duration // 0 = default
NoWriteTimeout bool // true = disable (ignore WriteTimeout value)
}
// Required only if Config contains references.
func (c Config) Clone() Config {
c.Tags = slices.Clone(c.Tags)
c.Headers = maps.Clone(c.Headers)
if c.WriteBufferBytes != nil {
c.WriteBufferBytes = new(*c.WriteBufferBytes)
}
return c
}
// Required! Idempotent.
func (c Config) Resolve() (Config, error) {
c = c.Clone()
// Defaults.
if c.Host == "" {
c.Host = "localhost"
}
if c.Port == 0 {
c.Port = 1234
}
if c.TLS == TLSDefault {
c.TLS = TLSEnabled
}
if c.WriteBufferBytes == nil {
c.WriteBufferBytes = new(4096)
}
// Normalize.
c.AppName = strings.TrimSpace(c.AppName)
// Validate.
var err error
if c.AppName == "" {
err = errors.Join(err, ErrNoAppName)
}
if !c.TLS.Valid() {
err = errors.Join(err, ErrInvalidTLSMode)
}
if c.ReadTimeout < NoTimeout {
err = errors.Join(err, ErrInvalidReadTimeout)
}
if c.NoWriteTimeout && c.WriteTimeout != 0 {
err = errors.Join(err, ErrConflictingWriteTimeout)
}
return c, err
}
func NewClient(cfg Config) (*Client, error) {
cfg, err := cfg.Resolve()
if err != nil {
return nil, err
}
return &Client{cfg: cfg}, nil
}
client, err := NewClient(Config{
AppName: "example",
Port: 8080,
TLS: TLSEnabled,
WriteBufferBytes: new(0),
ReadTimeout: NoTimeout,
NoWriteTimeout: true,
})
Provides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
npx claudepluginhub powerman/skills --plugin go-engineering-policy