Skip to content
Development
Skill

/golang-error-handling

Standards for error wrapping, checking, and definition in Golang. Use when wrapping errors, defining sentinel errors, or handling errors idiomatically in Go.

From plugin
agent-skills-standard
583200 skills21 agents33 commands1 MCP

Claude Code

$ npx -y skills add hoangnguyen0403/agent-skills-standard --skill golang-error-handling --agent claude-code

SKILL.md

golang-error-handling.SKILL.md
name: golang-error-handling
description: Standards for error wrapping, checking, and definition in Golang. Use when wrapping errors, defining sentinel errors, or handling errors idiomatically in Go.
metadata:
  triggers:
    files:
    - 'fmt.Errorf'
    - 'errors.Is'
    - 'errors.As'
    keywords:
    - error wrapping
    - sentinel error
    - error handling

Golang Error Handling Standards

**Priority: P0 (CRITICAL)**

Principles

  • **Errors Values**: Handle them like any other value.
  • **Handle Once**: Log OR Return. Never Log AND Return (creates duplicate logs).
  • **Add Context**: Don't return `err` bubble up. Wrap it with context: `fmt.Errorf("failed to open file: %w", err)`.
  • **Use Standard Lib**: Go 1.13+ `errors` package (`Is`, `As`, `Unwrap`) sufficient. Avoid `pkg/errors` (deprecated).

Guidelines

  • **Sentinel Errors**: Expoted, fixed errors (`io.EOF`, `sql.ErrNoRows`). Use `errors.Is(err, io.EOF)`.
  • **Error Types**: Structs implementing `error`. Use `errors.As(err, &target)`.
  • **Panic**: Only for unrecoverable startup errors.

Anti-Patterns

  • **No bare return err**: Wrap with `fmt.Errorf("context: %w", err)` to preserve call chain.
  • **No string error checks**: Use `errors.Is`/`errors.As`; string comparison brittle.
  • **No swallowed errors**: Never assign errors to `_`; always handle or propagate.

References

  • [Error Wrapping Patterns](references/error-wrapping.md)
Read more
@hoangnguyen0403
Ships withagent-skills-standard

The portable standards layer for AI coding agents. Sync once, then work in your own runtime.

583200 skills21 agents1 MCP
Get the whole plugin

Stars on GitHub

Momentum

stars in total
583
Star history of hoangnguyen0403/agent-skills-standard on GitHub, a chart by star-history.com

Other skills on agent-skills-standard.

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills10d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc12d293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react1d252k
@facebook@facebookInstall Skill

Questions about golang-error-handling.

Which coding agents can use golang-error-handling?
golang-error-handling installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.