error-handling

error-handling is a skill for Claude Code, Codex from tmj-90/gaffer. It costs 84 tokens per session (1,344 once invoked), scanned A, original, Apache-2.0.

A method for designing how software reports and responds to failures. It covers errors from invalid input, unavailable services, timeouts, conflicts, and bugs.

In plain words
What is it for?
Use it when adding error types, retries, fallbacks, validation, API error responses, or code that catches exceptions.
Why use it?
It prevents code from silently ignoring failures or showing unclear messages. It helps decide when to recover, when to pass an error upward, and what information users or operators need.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when adding error types, retries, fallbacks, validation, API error responses, or code that catches exceptions.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/tmj-90/gaffer/error-handling
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 tmj-90/gaffer --skill error-handling
Clone the repo
git clone --depth 1 https://github.com/tmj-90/gaffer

Made for: Claude Code, Codex.

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 error-handling

README.md
[![agentmods](https://agentmods.dev/badge/skills/tmj-90/gaffer/error-handling/github.svg)](https://agentmods.dev/skills/tmj-90/gaffer/error-handling)
Your own site
<a href="https://agentmods.dev/skills/tmj-90/gaffer/error-handling"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/error-handling/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 error-handling

Your own site · 80×15
<a href="https://agentmods.dev/skills/tmj-90/gaffer/error-handling"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/error-handling.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 84 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,344 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.00084 $0.01344
Opus 5.5 $0.00034 $0.00538
Sonnet 5.5 $0.00017 $0.00269
Haiku 4.5 $0.00008 $0.00134

Measured 16d ago against content hash 14ec0e424e7f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

error-handling 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 16d 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.

runner/skills/error-handling/SKILL.md · 86 lines

How it starts

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

Handle errors so failures are visible and recoverable

Every error is a decision: recover, translate, or propagate. An empty catch makes that decision silently and wrongly. Design the error path with the happy path: typed errors with stable codes, context added on the way up with the cause preserved, and one place at the top that logs and decides what the caller sees.

Steps

  1. Map the failure modes. For the code the ticket touches, list what can fail: invalid input, not found, conflict, permission, dependency down, timeout, and bugs. For each, decide who must know (caller, user, operator) and whether anything can be done. Call search_lore for the repo's error base class or result type and the API error envelope.
  2. Use the repo's error shape. A typed error hierarchy or result type carrying a stable machine code (NOT_FOUND, CONFLICT) separate from the human message. Never throw strings. Use return values for expected outcomes where the language favours them (Go error, Rust Result) and exceptions for exceptional ones elsewhere.
  3. Fail fast at boundaries. Validate input where it enters (the security-input-validation skill) and reject with the documented code before any side effect. Inside the boundary, trust your own types.
  4. Wrap with context, keep the cause. Add what the caller needs (which record, which operation) and preserve the original:
    • JavaScript/TypeScript: new AppError(msg, { cause: err }); never throw "msg".
    • Python: raise AppError(msg) from err; add_note() for context.
    • Go: fmt.Errorf("load order %s: %w", id, err); test with errors.Is / errors.As; never compare error strings.
    • Rust: ? with thiserror types in libraries, anyhow::Context in binaries; no unwrap() on fallible runtime paths.
    • Java/Kotlin: pass the cause to the constructor; C#: throw; to rethrow, never throw ex; (it resets the stack trace).
  5. Recover only where recovery is real. Retry only transient failures of idempotent operations, with backoff, jitter and a cap (the idempotency-and-retries skill). Fall back only when the degraded result is acceptable and is logged or counted. Otherwise propagate. An empty catch, except: pass, except Exception that continues, an ignored err, or .catch(() => {}) is a bug: handle it or delete it. Do not catch an error to hide a race or a bug (e.g. retrying on a temp-file collision instead of fixing it with the concurrency-and-async skill).
  6. Leave no half-applied state. Fail before the first side effect, or make the sequence atomic (one transaction), or compensate explicitly. Release resources in finally / defer / using / with.
  7. Report once, at the top. The outermost handler (request middleware, job runner, CLI main) logs once with code, context, cause chain and correlation id through the structured logger (the structured-logging-and-tracing skill); intermediate layers wrap, they do not log and rethrow. It maps typed errors to the external contract: for HTTP, the repo's envelope or RFC 9457 problem details (type, title, status, detail) with the right status (400/422 validation, 404, 409 conflict, 503 dependency unavailable, 500 only for bugs). Stack traces, SQL, file paths and secrets never reach a client. Install process-level handlers (unhandled rejection, uncaught exception, panic recovery at the goroutine or request boundary) that log and exit or fail the request, never continue in an unknown state.
  8. Test the error paths as first-class cases, one test per AC exercising the AC's own behaviour: each failure mode asserts the error code or status, the body shape, that the cause is preserved (or logged), and that no partial write or side effect happened. Inject failures with fakes or fault hooks, not by editing production code.
  9. Evidence with the record-evidence skill.

Read the full file on GitHub · 86 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. 16d ago Changed · +22 lines 14ec0e424e7f
  2. 19d ago First seen · 64 lines · 84 tokens per session scan A 7a548e223d07

Subscribe to this mod's changes

error-handling is a skill published in the GitHub repository tmj-90/gaffer (2 stars, last pushed 17d ago), licensed Apache-2.0. It adds 84 tokens to every session and 1,344 once invoked, about $0.0003 per session on Opus 5.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-09-28.

Related

Other skills, from other repositories

issue-debugging

Systematic methodology for issue debugging including root cause analysis, impact mapping, tiered validation plans, and confidence assessment. Use when analyzing bugs, fixing issues, or validating fixes.

QBall-Inc/the-bulwark · 39 tokens

fix-bug

Run the Fix Validation pipeline to investigate, fix, and validate a bug. Ensures deterministic pipeline execution with IssueAnalyzer, FixWriter, TestWriter (conditional), TestAudit (conditional), and FixValidator stages.

QBall-Inc/the-bulwark · 46 tokens

pact-bug

Log a bug investigation using PACT's structured bug tracker.

jonathanmr22/pact · 11 tokens

express-error-handling

Express.js error handling patterns including async error catching, custom error classes, centralized error middleware, and the distinction between operational and programmer errors. Use when the user is handling errors in Express, writing async route handlers, creating custom error types, or debugging unhandled…

VersoXBT/claude-initial-setup · 84 tokens

deep-debug-api

Deep root-cause analysis for API endpoint crashes and frontend display bugs in the Cortex stack — Express route handlers, service layer queries, React component rendering, and data formatting. Use this skill when the user reports 500 errors, null reference crashes, "Cannot read properties of null/undefined", data that…

anotherben/claude-harness · 149 tokens

api-health-checker

Check api health checker operations. Auto-activating skill for API Integration. Triggers on: api health checker, api health checker Part of the API Integration skill category. Use when working with APIs or building integrations. Trigger with phrases like "api health checker", "api checker", "api".

nek1987/auto-agent-harness · 64 tokens