Skip to content
Skill

Go error handling

Guides an AI agent through Go error wrapping, sentinel errors and custom error types

Go error handling is an open-source agent skill for developer tools. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

Scripts
None
Platforms
Claude Code, Codex, Cursor
GitHub stars
90
Last commit
License
MIT
Listing updated

Similar skills

About Go error handling

This skill gives a coding agent a set of rules for creating, wrapping, checking and returning errors in Go projects. It includes a short decision tree for choosing between plain errors, wrapped errors, sentinel values and custom types, along with guidance on when to break the error chain with %v instead of %w.

The workflow covers the common mistakes it targets: comparing errors with ==, logging and returning the same error, leaking internal error text into responses, and custom types that hide their cause from errors.Is and errors.As. It also explains how to use errors.Join for collected failures and how to translate domain errors at HTTP and RPC boundaries. A reference file with checking patterns and examples is loaded on demand.

The skill expects a Go project with the Go toolchain installed. It suggests running go vet and golangci-lint with errcheck and errorlint enabled when those tools are available, and it notes that errors.AsType applies only on Go 1.26 and later.

When your agent uses it

Go error handling patterns, wrapping, sentinel errors, custom error types, and the errors package. Grounded in Effective Go, Go Code Review Comments, and production-proven idioms. Use when implementing error handling, designing error types, debugging error chains, or reviewing error handling patterns. Trigger examples: "handle errors", "error wrapping", "custom error type", "sentinel errors", "errors.Is", "errors.As". Not for: panic/recover in middleware (go-api-design), test assertions (go-test-quality).

From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.

What it can access

From a static check of its 2 files (10 KB) on GitHub on 3 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.

Check another skill before you install it.

Install

Download the skill folder from https://github.com/eduardo-sl/go-agent-skills and copy it into your agent's skills folder.

What it does

Error decision tree
A quick guide for choosing between errors.New, fmt.Errorf wrapping, sentinel values and custom types.
Sentinel error patterns
Naming and checking package-level sentinel errors with errors.Is instead of direct comparison.
Custom error types
Structured error types with Unwrap support so the error chain remains walkable.
Wrapping and boundaries
Rules for adding context with %w and translating errors before they reach users.
Single handling rule
Guidance to log or return an error once, not both, and to keep log messages stable.
Lint verification
Suggested go vet and golangci-lint checks for unchecked errors and misused wrapping.

Good for

  • Add context to errors returned from a database call in a Go service
  • Design a custom error type that carries a field name for validation failures
  • Replace direct error comparisons with errors.Is checks
  • Review a Go package for log-and-return error handling
  • Hide internal database errors from an exported API response

Go error handling FAQ

Which tools does the skill need?

It needs the Go toolchain. Its allowed tools include Go and gofmt commands, and it suggests running go vet and golangci-lint when they are installed.

Does Go error handling change Go version behavior?

No. It shows errors.AsType for Go 1.26 and later and errors.As for earlier versions, so the agent can use whichever fits the project.

When should an error be wrapped with %w versus %v?

Use %w to keep the chain for callers inside the module. Use %v when you want to hide an internal error from a public API.

Is the skill free to use?

It is released under the MIT license.

Does Go error handling run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

Which AI agents can use Go error handling?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

What are the best alternatives to Go error handling?

The closest alternatives to Go error handling are Error handling, Go backend, Go defensive coding, Go coding standards and M06 error handling.

Where this comes from

  • Description: from the skill's own SKILL.md.

More from eduardo-sl/go-agent-skills

  1. Guides Go agents in designing HTTP REST APIs, handlers, middleware and shutdown

    • Open source
    • 90 GitHub stars
    • Developer tools
  2. Reviews Go project structure, dependency direction and module boundaries

    • Open source
    • 90 GitHub stars
    • Developer tools
  3. Guides an AI agent to build Go command-line tools with clean flags, streams and exit codes

    • Open source
    • 90 GitHub stars
    • Developer tools
  4. Guides Go code toward constructor injection, explicit wiring and no global state

    • Open source
    • 90 GitHub stars
    • Developer tools
  5. Guides Go code toward idiomatic design patterns like functional options and factories

    • Open source
    • 90 GitHub stars
    • Developer tools
  6. Guides building Go GraphQL servers with gqlgen, covering N+1 batching and query limits

    • Open source
    • 90 GitHub stars
    • Developer tools