Source profileQuality 95/100Review permissions

event4u-app/agent-config/src/skills/error-handling-patterns/SKILL.md

error-handling-patterns

Use when picking a failure-reporting strategy — exceptions vs Result types, recoverable vs not, retry / circuit-breaker / graceful degradation — decision framework only, catalogues externalized.

Source repository stars
7
Declared platforms
0
Static risk flags
1
Last source update
2026-07-28
Source checked
2026-07-28

Decision brief

What it does—and where it fits

Decision framework for picking an error-handling strategy. Catalogues of language-specific code live upstream (links in § Provenance) — this skill is the predicate, not the pattern library. Sunset-policy compliant: large language-specific catalogues stay in authoritative upstrea…

Best for

  • Designing how a new feature, API, or service reports failure.
  • Reviewing a diff that introduces a new exception class, Result, or sentinel return.
  • Debugging production noise that traces back to inconsistent error semantics.

Not for

  • Tasks that require unconfirmed production actions or broad system permissions.
  • Environments where the pinned source and install steps cannot be inspected.

Compatibility matrix

Platform support, with evidence labels

PlatformStatusEvidenceWhat to check
CodexNot declaredNo explicit evidencePortability before use
Claude CodeNot declaredNo explicit evidencePortability before use
CursorNot declaredNo explicit evidencePortability before use
Gemini CLINot declaredNo explicit evidencePortability before use
Open the compatibility checker

Installation

Inspect first. Install second.

The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.

Source-detected install commandSource
npx skills add https://github.com/event4u-app/agent-config --skill "src/skills/error-handling-patterns"
Safe inspection promptEditorial

Inspect the Agent Skill "error-handling-patterns" from https://github.com/event4u-app/agent-config/blob/0adf49a8ae84b0ff6e2de8759eea43257e020eff/src/skills/error-handling-patterns/SKILL.md at commit 0adf49a8ae84b0ff6e2de8759eea43257e020eff. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.

Workflow

What the source asks the agent to do

  1. 01

    Step 1 — Classify the failure

    Review the “Step 1 — Classify the failure” section in the pinned source before continuing.

    Review and apply the “Step 1 — Classify the failure” source section.
  2. 02

    Step 2 — Pick the reporting mechanism

    Review the “Step 2 — Pick the reporting mechanism” section in the pinned source before continuing.

    Review and apply the “Step 2 — Pick the reporting mechanism” source section.
  3. 03

    Step 3 — Pick the resilience strategy

    Review the “Step 3 — Pick the resilience strategy” section in the pinned source before continuing.

    Review and apply the “Step 3 — Pick the resilience strategy” source section.
  4. 04

    Step 4 — Shape the error payload

    Every produced error must carry: code (stable string), message (human-readable), cause (chained), context (sanitized inputs), correlationid (request / trace).

    Every produced error must carry: code (stable string), message (human-readable), cause (chained), context (sanitized inputs), correlationid (request / trace).Forbidden: secrets, raw SQL, full stack traces in user-facing surfaces, internal class names leaked through API boundaries.
  5. 05

    Step 5 — Define the boundary

    Exactly one layer translates internal errors to the egress format (HTTP status + body, queue requeue policy, CLI exit code). Anywhere else doing this duplication is the bug.

    Exactly one layer translates internal errors to the egress format (HTTP status + body, queue requeue policy, CLI exit code). Anywhere else doing this duplication is the bug.

Permission review

Static risk signals and limitations

Runs scripts

medium · line 46

The documentation asks the agent to run terminal commands or scripts.

Python/PHP/JS: exceptions)

Evidence record

Why each signal appears

EvidenceSourceComputedTestedEditorial
SignalValueEvidence typeMeaning
Quality score95/100ComputedDocumentation, specificity, maintenance, and trust rules
Repository stars7SourceRepository attention, not individual Skill quality
Compatibility0 platformsSourceDeclared in the catalog source record
Usage guideautomated source guideEditorialGenerated or reviewed according to the visible evidence level

Pinned source

Provenance and original SKILL.md

Repository
event4u-app/agent-config
Skill path
src/skills/error-handling-patterns/SKILL.md
Commit
0adf49a8ae84b0ff6e2de8759eea43257e020eff
License
MIT
Collected
2026-07-28
Default branch
main
View the original SKILL.md

error-handling-patterns

Decision framework for picking an error-handling strategy. Catalogues of language-specific code live upstream (links in § Provenance) — this skill is the predicate, not the pattern library. Sunset-policy compliant: large language-specific catalogues stay in authoritative upstream docs.

When to use

  • Designing how a new feature, API, or service reports failure.
  • Reviewing a diff that introduces a new exception class, Result<T, E>, or sentinel return.
  • Debugging production noise that traces back to inconsistent error semantics.
  • Choosing between retry, circuit-breaker, fallback, and fail-fast for an external dependency.

Do NOT use when:

  • You only need the syntax for a try/catch in language X — read the upstream language guide directly.
  • The failure is a single-call Laravel validation error — route to laravel-validation.
  • The fix is a one-line null check in existing code — route to bug-analyzer.

Decision framework

Step 1 — Classify the failure

Failure is:
  caller's fault (bad input, missing auth)         → reject at boundary, structured error
  expected operational (timeout, 404, rate-limit)  → Result-type / typed return; retry-aware
  unexpected operational (DB down, OOM, deadlock)  → exception; observability + alert
  programmer bug (null deref, off-by-one)          → crash early; do not catch

Step 2 — Pick the reporting mechanism

IF failure is an EXPECTED, branchable outcome the caller will route on
  → Result type / tagged union / typed error return.
  Forces the caller to handle it; the type system is the proof.

IF failure is UNEXPECTED and most callers cannot do anything useful
  → exception, propagated to a single boundary handler.
  One layer (HTTP, queue, CLI) translates exceptions to user-facing errors.

IF failure is UNRECOVERABLE (invariant violated, data corruption)
  → fail loud, fail fast. No catch-and-continue.
  Log structured context, exit / panic / 500.

IF the language idiom forces one choice (Go: errors are values; Rust: Result;
   Python/PHP/JS: exceptions)
  → follow the idiom. Inventing a foreign mechanism is more cost than the
    correctness it buys.

Step 3 — Pick the resilience strategy

External call?
  Idempotent + transient failure mode  → retry with exponential backoff + jitter, cap.
  Non-idempotent                       → no blind retry; require an idempotency key.
  Repeated failure across instances    → circuit breaker; open → half-open probe → close.
  Optional functionality               → graceful degradation (cached / default / null result).
  Required functionality               → propagate; surface to user with a recovery hint.

Step 4 — Shape the error payload

Every produced error must carry: code (stable string), message (human-readable), cause (chained), context (sanitized inputs), correlation_id (request / trace).

Forbidden: secrets, raw SQL, full stack traces in user-facing surfaces, internal class names leaked through API boundaries.

Step 5 — Define the boundary

Exactly one layer translates internal errors to the egress format (HTTP status + body, queue requeue policy, CLI exit code). Anywhere else doing this duplication is the bug.

Procedure: Apply the framework to a new feature

  1. Inspect the feature surface — identify every failure mode (each external call, each invariant, each user input class) and write it down.
  2. Run Step 1 of the decision framework against each entry; write the classification next to it.
  3. Pick reporting mechanism per Step 2; reject combinations the language idiom rejects.
  4. For each external call, run Step 3 and write down the chosen resilience strategy.
  5. Sketch the error payload shape (Step 4) and the single boundary (Step 5).
  6. Hand the sketch to a reviewer before coding; cite this skill.

Output format

  1. The failure-mode table (mode · classification · mechanism · resilience strategy).
  2. The shared error payload definition (code, message, cause, context, correlation_id).
  3. The single boundary handler (file:line) where internal → egress translation happens.
  4. The retry / circuit-breaker config (attempts, base, jitter, breaker thresholds), if any.

Gotcha

  • "Catch everything, log it, return null" silently destroys signal — every catch must either rethrow, translate, or recover with a written reason.
  • Retries on non-idempotent calls are the second-most-common production incident; insist on idempotency keys before allowing retry.
  • Circuit breakers without a half-open probe never close — they degrade to permanent failure.
  • Mixing Result types and exceptions in the same module is worse than picking the wrong one — pick one per module and stay in it.
  • Upstream pattern catalogues drift; trust the link, not memory. Refresh per refresh_trigger above.

Do NOT

  • Do NOT introduce a custom error mechanism that fights the language idiom.
  • Do NOT swallow exceptions — every catch has a written purpose.
  • Do NOT leak stack traces, secrets, or internal class names across the boundary.
  • Do NOT retry without backoff + jitter + cap.
  • Do NOT inline language-specific code catalogues into this skill — externalize per Sunset Policy.

Auto-trigger keywords

  • error handling strategy
  • exceptions vs result
  • retry pattern
  • circuit breaker
  • graceful degradation
  • error payload shape

Provenance

Alternatives

Compare before choosing