golang-error-handling
Idiomatic Golang error handling — creation, wrapping with %w, errors.Is/As, errors.Join, custom error types, sentinel errors, panic/recover, the single handling rule, structured logging with slog, HTTP request logging middleware, and samber/oops for production errors. Built to make logs usable at scale with log aggregation 3rd-party tools. Apply when creating, wrapping, inspecting, or logging errors in Go code. For samber/oops specifics → See `samber/cc-skills-golang@golang-samber-oops` skill; for slog handler ecosystem → See `samber/cc-skills-golang@golang-samber-slog` skill.
Install
git clone https://github.com/samber/cc-skills-golang /tmp/cc-skills-golang && ln -s /tmp/cc-skills-golang/skills/golang-error-handling ~/.claude/skills/golang-error-handling
From README
Go Error Handling Best Practices This skill guides the creation of robust, idiomatic error handling in Go applications. Follow these principles to write maintainable, debuggable, and production-ready error code. Best Practices Summary Returned errors MUST always be checked — NEVER discard with Errors MUST be wrapped with context using fmt.Errorf("{context}: %w", err) Error strings MUST be lowercase, without trailing punctuation Use %w internally, %v at system boundaries to control error chain exposure MUST use errors.Is for sentinel matching and errors.As/errors.AsType for typed chain inspection instead of direct comparison or bare type assertions. For Go 1.26+, prefer errors.AsTypeT when T implements error; use errors.As(err, &target) for Go <1.26 or for non-error interface targets.
More from this repo
golang-google-wire
Compile-time dependency injection in Golang using google/wire — wire.NewSet, wire.Build, wire.Bind...
golang-gopls
Golang semantic code intelligence via `gopls`, the official Go language server — go-to-definition, find references,...
golang-how-to
Golang skills orchestrator — always active on any Golang coding, review, debug, or setup task.
