compact-error-handling

compact-error-handling is a skill for Claude Code from alivirgo/Major-AI-Skills. It costs 23 tokens per session (1,148 once invoked), scanned A, original, MIT.

A guide to writing shorter error-handling code by grouping related exceptions or using result values instead of repeating similar catch blocks. Exceptions are programming signals that report failures.

In plain words
What is it for?
Use it when creating backend handlers or API clients with several errors that receive the same treatment.
Why use it?
It reduces repeated boilerplate while keeping a defined response for expected failures. The source does not establish that every situation should use these patterns.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: mentions Codex.

Part of the major-ai-skills plugin — 147 skills, 7 plugins shipped together

Good fit Use it when creating backend handlers or API clients with several errors that receive the same treatment.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/alivirgo/major-ai-skills/compact-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 alivirgo/Major-AI-Skills --skill compact-error-handling
Clone the repo
git clone --depth 1 https://github.com/alivirgo/Major-AI-Skills

Made for: Claude Code.

Or install major-ai-skills, the plugin that ships this one along with the rest of its 147 skills, 7 plugins.

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

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/alivirgo/major-ai-skills/compact-error-handling"><img src="https://agentmods.dev/badge/skills/alivirgo/major-ai-skills/compact-error-handling.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 23 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,148 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.00023 $0.01148
Opus 5 $0.00012 $0.00574
Sonnet 5 $0.00005 $0.00230
Haiku 4.5 $0.00002 $0.00115

Measured today against content hash cc625b1a989b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

compact-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 today.

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/compact-error-handling/SKILL.md · 135 lines

How it starts

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

Compact Error Handling (Multi-Exception Tuples & Result Wrappers)

Overview

When generating backend handlers or API callers, default LLM outputs create repetitive, bloated exception cascades (30 lines of sequential catch or except blocks that each perform the identical logging or fallback action).

This repetitive error boilerplate wastes output tokens, clutters the codebase, and increases maintenance overhead.

The Compact Error Handling Protocol enforces dense, idiomatic exception consolidation: using Multi-Exception Tuples, contextlib.suppress, and Functional Result Wrappers to reduce error handling code size by 60% with zero loss of fault tolerance.


Repetitive Cascades vs. Consolidated Exception Handling

┌─────────────────────────────────────────────────────────────┐
│                 Error Handling Code Density                 │
│                                                             │
│  Repetitive Exception Cascade (35 Lines / 280 Tokens):      │
│  try:                                                       │
│      response = fetch_data(url)                             │
│  except ConnectionError as e:                               │
│      logger.error(f"Network failure: {e}")                  │
│      return None                                            │
│  except TimeoutError as e:                                  │
│      logger.error(f"Network failure: {e}")                  │
│      return None                                            │
│  except HTTPError as e:                                     │
│      logger.error(f"Network failure: {e}")                  │
│      return None                                            │
│                                                             │
│  Consolidated Multi-Exception Tuple (5 Lines / 45 Tokens):  │
│  try:                                                       │
│      return fetch_data(url)                                 │
│  except (ConnectionError, TimeoutError, HTTPError) as err:  │
│      logger.error(f"Network failure: {err}")                │
│      return None                                            │
└─────────────────────────────────────────────────────────────┘

Read the full file on GitHub · 135 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. today Changed · -20 tokens per session cc625b1a989b
  2. 6d ago First seen · 135 lines · 43 tokens per session scan A 654164f7c907

Subscribe to this mod's changes

compact-error-handling is a skill published in the GitHub repository alivirgo/Major-AI-Skills (1 stars, last pushed today), licensed MIT. It adds 23 tokens to every session and 1,148 once invoked, about $0.0001 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-05.

Related

Other skills, from other repositories

build-teaql-app

Build or change a TeaQL application in Java, Rust, Go, Swift, Python, C#/.NET, or TypeScript, including Kotlin/JVM applications that consume Java-generated libraries. Mandatory order: first draft and save a complete KSML model, then verify the client and evaluate that saved model, repair it through repeated evaluation…

teaql/teaql-agent-kit · 112 tokens

error-handling

Use when designing the reaction to a class of failures — typed error taxonomies, retry/backoff/timeout policy, circuit breakers, React/Next error boundaries, and the user-message vs operator-log split. NOT diagnosing one specific crash (that is debug), NOT logs/metrics/traces (that is observability), NOT the wire…

ericrisco/rsc-harness · 78 tokens

nodejs

Use when building or operating a plain Node.js / Express 5 backend service: project layout, async correctness, central error middleware, fail-fast config, graceful shutdown on SIGTERM. NOT DI modules/providers/guards (that is nestjs), NOT the type system or tsconfig (that is typescript), NOT REST contract design (that…

ericrisco/rsc-harness · 77 tokens

azure-communication-services

Expert knowledge for Azure Communication Services development including troubleshooting, best practices, decision making, architecture & design patterns, limits & quotas, security, configuration, integrations & coding patterns, and deployment. Use when building ACS calling/chat apps, SMS/email senders, Teams interop…

MicrosoftDocs/Agent-Skills · 127 tokens

algolia-search-v2

Algolia Search Integration workflow skill. Use this skill when the user needs Expert patterns for Algolia search implementation, indexing and the operator should preserve the upstream workflow, copied support files, and provenance before merging or handing off.

diegosouzapw/awesome-omni-skills · 50 tokens

amazon-alexa-v2

AMAZON ALEXA — Voz Inteligente com Claude workflow skill. Use this skill when the user needs Integracao completa com Amazon Alexa para criar skills de voz inteligentes, transformar Alexa em assistente com Claude como cerebro (projeto Auri) e integrar com AWS ecosystem (Lambda, DynamoDB, Polly, Transcribe, Lex, Smart…

diegosouzapw/awesome-omni-skills · 98 tokens