Skip to content
Agentmart
Submit a tool

golang-error-handling

Design or review Go error creation, wrapping, inspection, aggregation, logging boundaries, transport mapping, and panic recovery.

Skill by reagin

IndexedMIT
Write a review

Chalk Labs

Need help deploying golang-error-handling?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/reagin-golang-error-handling

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Design or review Go error creation, wrapping, inspection, aggregation, logging boundaries, transport mapping, and panic recovery. Use when callers must classify failures or errors cross package, process, or user-facing boundaries.

Use cases: design

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/golang-error-handling

What's inside

Skill name
golang-error-handling
Description
Design or review Go error creation, wrapping, inspection, aggregation, logging boundaries, transport mapping, and panic recovery. Use when callers must classify failures or errors cross package, process, or user-facing boundaries.
License
MIT
Instructions
59 lines in SKILL.md · view on GitHub

Files (4)

  • SKILL.md
  • error-creation.md · references/
  • error-handling.md · references/
  • error-wrapping.md · references/

SKILL.md (first lines)

# Go Error Handling

Treat errors as part of the API. Preserve enough identity and context for the owner to act, without leaking secrets or coupling callers to accidental implementation details.

## Inspect the existing contract

Before editing:

1. Read repository conventions, public documentation, tests, and callers using `errors.Is` or `errors.As`.
2. Identify the layer that can decide retry, fallback, user response, process exit, or logging.
3. Separate expected domain outcomes from infrastructure failures and programmer defects.
4. Preserve stable sentinels, types, status mappings, and wire responses unless changing the contract is requested.

## Propagate useful information

Check errors unless the API documents that they are ignorable and the code explains why. Add wrapping context when it identifies the failed operation or boundary:

```go
value, err := store.Load(ctx, id)
if err != nil {
    return Item{}, fmt.Errorf("loading item %q: %w", id, err)
}
```

Do not wrap at every stack frame mechanically; repeated “failed to” prefixes add noise. Use `%w` only when exposing the wrapped error's identity is part of the intended contract. At a public or trust boundary, translate to a stable domain or transport error instead of assuming `%v` makes the message safe—it breaks unwrapping but still includes the original text.

Use `errors.Is` for semantic matching through a chain and `errors.As` for typed detail. Avoid direct equality or type assertions when wrapping is allowed. See [wrapping and inspection](references/error-wrapping.md).

## Choose an error representation

- Use a package sentinel when callers need to recognize one stable condition and no extra fields are needed.
- Use a custom type when callers need structured detail. Keep its `Error` text safe for likely logs and implement `Unwrap` when the cause is intentionally exposed.
- Use an ordinary wrapped error for one-off operational context that callers do not classify more precisely.
- Use `errors.Join` when the project's Go version supports it, failures are independent, callers can meaningfully inspect a multi-error, and deterministic ordering is preserved where needed.

Read [creating error contracts](references/error-creation.md) for API decisions.

## Handle at an ownership boundary

Normally, lower layers annotate and return; a boundary that owns the outcome logs, maps, retries, or terminates. Logging and returning the same incident from several layers creates duplicate events. A lower layer may log and return when it records a distinct operational event, but the reason and deduplication behavior should be clear.

Keep log messages stable and put IDs, paths, counts, and the error in structured attributes. Redact credentials, tokens, personal data, query contents, and sensitive paths according to project policy. Do not return internal error text directly to untrusted users.

For boundary logging and panic decisions, read [handling and recovery](references/error-handling.md).

## Verification

Test observable behavior rather than exact incidental strings:

- `errors.Is` and `errors.As` contracts survive wrapping;
- domain and transport mappings remain correct;
- multi-errors retain all required causes;
- cancellation and deadline errors are not misclassified as internal failures;
- sensitive details do not cross public boundaries;
- cleanup errors are not lost.

When reviewing, state the caller action that fails because of the current error design. Style-only rewrites of already useful errors are low value.

From reagin/agent-skills, MIT.

More from reagin/agent-skills

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Aug 25, 2026 (2 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from reagin

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get golang-error-handling running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying golang-error-handling?

CallGet help
Cite this page

golang-error-handling skill. Agent Mart. https://agentmart.dev/skills/reagin-golang-error-handling (last updated 2026-10-24)