go-error-hygiene

go-error-hygiene is a skill for Claude Code from gonzaloserrano/gopilot. It costs 92 tokens per session (2,205 once invoked), scanned A, original, MIT.

A Go code-review aid for finding places where the same error is handled more than once, such as logging it and then returning it.

In plain words
What is it for?
Use it to audit a Go codebase, find error-handling violations, and clean up patterns such as log-and-return or helpers that log while wrapping errors.
Why use it?
It helps prevent duplicate log messages and keeps the original error context clearer when failures move through a program.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the gopilot plugin — 3 skills, 2 hooks shipped together

Good fit Use it to audit a Go codebase, find error-handling violations, and clean up patterns such as log-and-return or helpers that log while wrapping errors.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/gonzaloserrano/gopilot/go-error-hygiene
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add gonzaloserrano/gopilot --skill go-error-hygiene
Clone the repo
git clone --depth 1 https://github.com/gonzaloserrano/gopilot

Made for: Claude Code.

Or install gopilot, the plugin that ships this one along with the rest of its 3 skills, 2 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for go-error-hygiene

README.md
[![agentmods](https://agentmods.dev/badge/skills/gonzaloserrano/gopilot/go-error-hygiene/github.svg)](https://agentmods.dev/skills/gonzaloserrano/gopilot/go-error-hygiene)
Your own site
<a href="https://agentmods.dev/skills/gonzaloserrano/gopilot/go-error-hygiene"><img src="https://agentmods.dev/badge/skills/gonzaloserrano/gopilot/go-error-hygiene/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for go-error-hygiene

Your own site · 80×15
<a href="https://agentmods.dev/skills/gonzaloserrano/gopilot/go-error-hygiene"><img src="https://agentmods.dev/badge/skills/gonzaloserrano/gopilot/go-error-hygiene.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 92 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,205 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00092 $0.02205
Opus 5 $0.00046 $0.01103
Sonnet 5 $0.00018 $0.00441
Haiku 4.5 $0.00009 $0.00220

Measured 11d ago against content hash 41071546df27, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

go-error-hygiene scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/go-error-hygiene/SKILL.md · 255 lines

How it starts

The opening of the file, as written. The whole thing — 255 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Go Error Hygiene

Detect and fix the "handle errors more than once" antipattern across a Go codebase.

The Rule

An error should be handled exactly once. Handling means one of:

  • Logging it (to stdout, a logger, or a tracing span)
  • Returning it to the caller (wrapped with context)
  • Degrading gracefully (fallback, retry, default value)

If you do more than one at the same call site, you're double-handling. The most common violation: log AND return.

Why It Matters

  • Duplicate log lines obscure root cause during incidents
  • Callers that receive the returned error may log it again, tripling noise
  • Coupling observability (tracing/logging) with error propagation makes both harder to change
  • Interior log noise buries the wrapped error chain that actually tells the story

Detection Procedure

Step 1: Find helper functions that log AND wrap

Search for functions that combine logging/tracing with error wrapping in a single call:

# Find definitions (handles both functions and methods)
rg -n "^func\b.*\b(Log|Trace|Record)\w*(Wrap|Error|Return)" --type go
rg -n "^func\b.*\b(Wrap|Return)\w*(Log|Trace|Record)" --type go

# Find usages of common helpers
rg -n "LogAndWrapError|logAndReturn|wrapAndLog|traceAndWrap" --type go

Read each definition. If the function both logs/traces AND returns a wrapped error, it's a codified antipattern.

Step 2: Find explicit log-then-return blocks

Search for logging calls near error returns:

# Standard library log (exclude Fatal -- it's terminal, not double-handling)
rg -n "log\.(Printf|Println|Print)\b" --type go -A 3

# Zap
rg -n "zap\.L\(\)\.(Error|Warn)|logger\.(Error|Warn|Errorw|Warnw)" --type go -A 3

# Slog
rg -n "slog\.(Error|Warn)" --type go -A 3

# OpenTracing/OpenTelemetry span logging
rg -n "span\.(LogFields|SetTag|RecordError|AddEvent)|tracing\.LogError" --type go -A 3

For each match, check whether a return ...err follows within 1-3 lines. If yes, it's a double-handle candidate.

Read the full file on GitHub · 255 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 255 lines · 92 tokens per session scan A 41071546df27

Subscribe to this mod's changes

go-error-hygiene is a skill published in the GitHub repository gonzaloserrano/gopilot (17 stars, last pushed 2mo ago), licensed MIT. It adds 92 tokens to every session and 2,205 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.