From skills
Uber Go style guide. Use when writing, reviewing, or modifying Go code to ensure it follows best practices for style, performance, error handling, concurrency, and naming conventions.
How this skill is triggered — by the user, by Claude, or both
Slash command
/skills:uber-go-styleThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
When writing or modifying Go code, follow these rules based on the Uber Go Style Guide.
When writing or modifying Go code, follow these rules based on the Uber Go Style Guide.
var _ http.Handler = (*Handler)(nil)sync.Mutex and sync.RWMutex are valid; don't use new(sync.Mutex)mu sync.Mutexdefer to clean up resources (files, locks). The overhead is negligibleiota + 1 unless zero value is a meaningful defaulttime.Time for instants, time.Duration for periodstime.Duration can't be used: IntervalMilliserrors.New for static errors, fmt.Errorf for dynamicErrFoo) for caller matching via errors.Is; use custom types with Error suffix for errors.As%w (caller can match) or %v (opaque); avoid "failed to" prefixes: use "new store: %w" not "failed to create new store: %w"Err, unexported with errt, ok := i.(string)t.Fatal not panictemplate.Must(...)go.uber.org/atomic types (atomic.Bool, etc.) over raw sync/atomic for type safetyerror, string, len, cap, etc.)init(). Make it deterministic, no I/O, no global state mutationvar _defaultFoo = defaultFoo() or initialization in main()os.Exit or log.Fatal only in main(); all other functions return errorsrun() error function called from main() for testabilityjson:"price"sync.WaitGroup for multiple goroutines, a done channel for single onesinit(); expose objects with Shutdown()/Close() methodsstrconv over fmt for primitive-to-string conversion[]byte; do it oncemake([]T, 0, size) and maps: make(map[K]V, size)const, var, type) but only group related items_ (except error vars which use err prefix)NewXYZ() right after type definitionif err := doThing(); err != nil:= for local variables with explicit valuesvar for zero-value declarations and empty slicesnil is a valid slice; return nil not []int{}; check emptiness with len(s) == 0`unknown error:"test"`go vet)var s MyStruct for zero-value structs, not s := MyStruct{}&T{Name: "bar"} not new(T) for struct referencesmake(map[K]V) for empty/programmatic maps; use literals for fixed setsconst for go vet analysisf suffix: Wrapf, not Wraptests, each case tt, use give/want prefixesOption interface and unexported options structnpx claudepluginhub ferhatelmas/goodies --plugin skillsGo language conventions, idioms, and toolchain. Invoke when task involves any interaction with Go code — writing, reviewing, refactoring, debugging, or understanding Go projects.
Provides idiomatic Go patterns and best practices for error handling, concurrency like worker pools, simplicity, zero values, and interfaces. Activates for writing, reviewing, refactoring, or designing Go code.
Directs Go code style decisions: line breaks at semantic boundaries, zero-value variable declarations, explicit slice/map initialization, and control flow clarity.