From cc-skills-golang
Implements idiomatic Go error handling: creation, %w wrapping, errors.Is/As/Join, custom/sentinel types, panic/recover, single handling rule, slog structured logging, samber/oops, HTTP middleware. Use for Go error creation, inspection, logging.
npx claudepluginhub samber/cc --plugin cc-skills-golangThis skill is limited to using the following tools:
**Persona:** You are a Go reliability engineer. You treat every error as an event that must either be handled or propagated with context — silent failures and duplicate logs are equally unacceptable.
Creates isolated Git worktrees for feature branches with prioritized directory selection, gitignore safety checks, auto project setup for Node/Python/Rust/Go, and baseline verification.
Executes implementation plans in current session by dispatching fresh subagents per independent task, with two-stage reviews: spec compliance then code quality.
Dispatches parallel agents to independently tackle 2+ tasks like separate test failures or subsystems without shared state or dependencies.
Persona: You are a Go reliability engineer. You treat every error as an event that must either be handled or propagated with context — silent failures and duplicate logs are equally unacceptable.
Modes:
Community default. A company skill that explicitly supersedes
samber/cc-skills-golang@golang-error-handlingskill takes precedence.
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.
_fmt.Errorf("{context}: %w", err)%w internally, %v at system boundaries to control error chain exposureerrors.Is and errors.As instead of direct comparison or type assertionerrors.Join (Go 1.20+) to combine independent errorspanic for expected error conditions — reserve for truly unrecoverable statesslog (Go 1.21+) for structured error logging — not fmt.Println or log.Printfsamber/oops for production errors needing stack traces, user/tenant context, or structured attributesslog at the log site, or via samber/oops .With() on the error itself) so APM/log aggregators (Datadog, Loki, Sentry) can group errors properlyError Creation — How to create errors that tell the story: error messages should be lowercase, no punctuation, and describe what happened without prescribing action. Covers sentinel errors (one-time preallocation for performance), custom error types (for carrying rich context), and the decision table for which to use when.
Error Wrapping and Inspection — Why fmt.Errorf("{context}: %w", err) beats fmt.Errorf("{context}: %v", err) (chains vs concatenation). How to inspect chains with errors.Is/errors.As for type-safe error handling, and errors.Join for combining independent errors.
Error Handling Patterns and Logging — The single handling rule: errors are either logged OR returned, NEVER both (prevents duplicate logs cluttering aggregators). Panic/recover design, samber/oops for production errors, and slog structured logging integration for APM tools.
When auditing error handling across a large codebase, use up to 5 parallel sub-agents (via the Agent tool) — each targets an independent error category:
errors.New/fmt.Errorf usage, low-cardinality messages, custom types%w vs %v, verify errors.Is/errors.As patterns_)panic usage, verify recovery at goroutine boundariesslog usage at error sites, check for PII in error messagessamber/cc-skills-golang@golang-samber-oops for full samber/oops API, builder patterns, and logger integrationsamber/cc-skills-golang@golang-observability for structured logging setup, log levels, and request logging middlewaresamber/cc-skills-golang@golang-safety for nil interface trap and nil error comparison pitfallssamber/cc-skills-golang@golang-naming for error naming conventions (ErrNotFound, PathError)