principle-error-handling

principle-error-handling is a skill for Claude Code from lugassawan/swe-workbench. It costs 74 tokens per session (1,515 once invoked), scanned A, original, MIT.

A guide to treating failures as part of a program's normal contract. It explains when to return errors, when to raise exceptions, and how to retry or stop safely.

In plain words
What is it for?
Use it to classify failures, add context, implement backoff and circuit breakers, and choose between failing fast or degrading temporarily.
Why use it?
Retrying the wrong failures wastes time, while hiding useful context makes incidents difficult to diagnose.

Skill for Claude Code

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

Part of the swe-workbench plugin — 60 skills, 25 commands, 22 agents, 4 hooks shipped together

Good fit Use it to classify failures, add context, implement backoff and circuit breakers, and choose between failing fast or degrading temporarily.

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

Made for: Claude Code.

Or install swe-workbench, the plugin that ships this one along with the rest of its 60 skills, 25 commands, 22 agents, 4 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 principle-error-handling

README.md
[![agentmods](https://agentmods.dev/badge/skills/lugassawan/swe-workbench/principle-error-handling.svg)](https://agentmods.dev/skills/lugassawan/swe-workbench/principle-error-handling)
Your own site
<a href="https://agentmods.dev/skills/lugassawan/swe-workbench/principle-error-handling"><img src="https://agentmods.dev/badge/skills/lugassawan/swe-workbench/principle-error-handling.svg" alt="Measured on agentmods" height="20"></a>
Per session 74 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,515 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.00074 $0.01515
Opus 5 $0.00037 $0.00758
Sonnet 5 $0.00015 $0.00303
Haiku 4.5 $0.00007 $0.00152

Measured 4d ago against content hash efcc8b3262e2, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

principle-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 4d 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/principle-error-handling/SKILL.md · 104 lines

How it starts

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

Error Handling

Errors are part of the contract. Handling them is not defensive programming — it is the design.

Errors as Values vs Exceptions

Use the language's native error style; don't fight it.

  • Go error values, Rust Result<T, E>, TypeScript typed unions: errors are explicit return paths, visible in signatures, handled by callers.
  • Exceptions (Java, Python, C#) work best for truly unexpected conditions — programmer errors, not business failures.
  • Reserve panic / throw / unchecked exceptions for unrecoverable programmer errors. Expected failures (network timeout, not found) must be value-level errors.

Classify Before Handling

Not all errors deserve the same response.

  • Transient — network blip, timeout, lock contention: retry with backoff (fail soft — degrade gracefully while recovering).
  • Permanent — bad input, not found, permission denied: fail fast — surface immediately to the caller, never retry.
  • Programmer — nil deref, index out of bounds, invariant violated: panic/crash, fix the code.
  • Misclassifying a permanent error as transient wastes retry budget and delays the caller.

Wrap, Don't Swallow

At each layer boundary, add context to the error and preserve the original cause for downstream inspection.

  • Go: fmt.Errorf("loading user config: %w", err)%w preserves errors.Is / errors.As traversal.
  • Rust: anyhow::Context / .with_context(|| ...) — attach human-readable context without losing the source.
  • TypeScript: native Error supports a cause option — new Error("fetch failed", { cause: err }).
  • Never discard the original error (return errors.New("failed") with no wrapping). The original context is lost forever.

Sentinel vs Typed vs Coded Errors

Three models; choose based on callsite needs.

Sentinel errors (Go io.EOF, Rust ErrorKind::NotFound)

  • Use when: callers need to branch on a single known condition without importing a type.
  • Costs: error set is open; callers do string-equal or errors.Is identity checks; hard to carry payload.
  • Don't use when: the error needs structured data (retry-after, field name, status code).

Read the full file on GitHub · 104 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. 4d ago First seen · 104 lines · 74 tokens per session scan A efcc8b3262e2

Subscribe to this mod's changes

principle-error-handling is a skill published in the GitHub repository lugassawan/swe-workbench (2 stars, last pushed 2d ago), licensed MIT. It adds 74 tokens to every session and 1,515 once invoked, about $0.0004 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-09-03.

Related

Other skills, from other repositories

printing-press-amend

Amend a published CLI from one of two input sources: (1) dogfood mode mines the active Claude Code session transcript for friction (missing flags, hand- rolled API payloads, silent-null returns); (2) direct-input mode accepts user-supplied asks (rename a command, add commands or feeds, fix a named bug, optionally…

mvanhorn/cli-printing-press · 222 tokens

tidewave-integration

Tidewave MCP runtime tools — debugging, smoke testing, live state inspection, SQL queries, hex docs. Use when evaluating code in a running Phoenix app.

oliver-kriska/claude-elixir-phoenix · 38 tokens

perf

Analyze Elixir/Phoenix performance — N+1 queries, assign bloat, ecto optimization, genserver bottlenecks. Use when slowness, timeouts, or high memory reported.

oliver-kriska/claude-elixir-phoenix · 43 tokens

api-error-handling

Implements standardized API error responses with proper status codes, logging, and user-friendly messages. Use when building production APIs, implementing error recovery patterns, or integrating error monitoring services.

secondsky/claude-skills · 40 tokens

bug-fix

Investigate, reproduce, and safely fix a bug with regression protection. Composes context, diagnosis, architecture, code quality, and testing guardrails into a reproduce-first repair workflow. Use when the user says 'fix this bug', 'debug this', 'investigate this failure', 'patch this regression', 'repair this issue'…

techygarg/lattice · 77 tokens

code-forge

Generate implementation code from an approved design blueprint or verbal requirements. Composes context anchoring, architecture, clean code, DDD, security, and test quality into an inside-out implementation workflow. Use when moving from design to code, implementing approved contracts, or when the user says…

techygarg/lattice · 81 tokens