go-error-handling
Go Error Handling Skill
Idiomatic Go error handling through context-rich wrapping, sentinel errors, custom error types, and proper error chain inspection. Every error return tells a story -- when read top-to-bottom, wrapped errors form a narrative of what happened and where.
Available Scripts
scripts/check-errors.sh-- Detect barereturn errand log-and-return anti-patterns. Runbash scripts/check-errors.sh --helpfor options.
Instructions
Phase 1: Understand the Context
Read the repository CLAUDE.md before implementing any error handling, because project-specific conventions (error prefixes, logging patterns, custom base types) override generic Go idioms.
Scan existing error patterns in the package to understand what is already in use. When gopls MCP is available, use go_symbol_references to find all usages of sentinel errors across the codebase, and go_diagnostics to verify error handling correctness after edits. Fallback: gopls references CLI or LSP tool.
Phase 2: Select the Right Error Pattern
Choose the simplest pattern that fits the situation, because over-engineering error types creates unnecessary abstraction that callers must learn and maintain. A simple wrap handles most cases; do not create custom types when a sentinel suffices, or sentinels when a simple wrap is enough.
More from notque/claude-code-toolkit
generate-claudemd
Generate project-specific CLAUDE.md from repo analysis.
12fish-shell-config
Fish shell configuration and PATH management.
12pptx-generator
PPTX presentation generation with visual QA: slides, pitch decks.
12codebase-overview
Systematic codebase exploration and architecture mapping.
10image-to-video
FFmpeg-based video creation from image and audio.
9data-analysis
Decision-first data analysis with statistical rigor gates.
9