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 — 62 skills, 26 commands, 23 agents, 5 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 62 skills, 26 commands, 23 agents, 5 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/github.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/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 principle-error-handling

Your own site · 80×15
<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="Reviewed on agentmods" width="80" 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.5 $0.00030 $0.00606
Sonnet 5.5 $0.00015 $0.00303
Haiku 4.5 $0.00007 $0.00152

Measured 3mo ago against content hash efcc8b3262e2, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-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 3mo 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. 3mo 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 (3 stars, last pushed 2d ago), licensed MIT. It adds 74 tokens to every session and 1,515 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-03.

Related

principle-error-handling compared with skills from other repositories

principle-error-handling next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
principle-error-handlinglugassawan/swe-workbenchSkill32d agoMITA74Claude Code
functions-developmentCrowdStrike/foundry-skillsSkill40yesterdayMITA124Claude Code
printing-press-amendmvanhorn/cli-printing-pressSkill5.1ktodayMITA222Claude Code
tidewave-integrationoliver-kriska/claude-elixir-phoenixSkill580yesterdayMITA38Claude Code
perfoliver-kriska/claude-elixir-phoenixSkill580yesterdayMITA50Claude Code
brooks-verifyhyhmrright/brooks-lintSkill1.6kyesterdayMITA145Claude Code
api-error-handlingsecondsky/claude-skillsSkill2576d agoMITA40Claude Code