agentleFS
DevelopersGlobalDevelopersGlobal/ai-agent-skills/skills/error-handling/SKILL.md

error-handling

Skill69 starsChanged 7 months agoMITView on GitHub

Graceful degradation and meaningful error messages. Errors are first-class citizens, not afterthoughts. Every error path is designed, not discovered.

44 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use logging, state-management and 7 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • diego-tobalinaSkill

    logging

    Logging best practices for Java (SLF4J/Logback) and Node.js (Winston/Pino). Use for structured logging, log levels, and avoiding sensitive data exposure.

    Also in 5 projects that use this

  • conorluddySkill

    state-management

    Cache management, configuration best practices, and progressive disclosure patterns for efficient context window usage. Use when working with large responses, optimizing token costs, or managing plugin state across operations.

    Also in 5 projects that use this

  • DatabricksSkill

    load-testing

    Load test a Databricks App to find its maximum QPS. Use when: (1) User says 'load test', 'benchmark', 'QPS', 'throughput', or 'performance test', (2) User wants to find how many queries per second their app can handle, (3) User wants to set up load testing scripts for their agent, (4) User wants to view load test results/dashboard, (5) User wants to validate results or observe latency/error rate with MLflow tracing.

    Also in 3 projects that use this

  • JohnJBorenSkill

    ci-cd

    CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies

    Also in 5 projects that use this

  • ffsshhttiikkSkill

    i18n

    Internationalization and localization

    Also in 5 projects that use this

  • benshapyroSkill

    react-patterns

    Modern React patterns for TypeScript applications including hooks, state management, and component composition. Use when building React components, managing state, or implementing React best practices.

    Also in 4 projects that use this

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 7 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 37 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When writing any code that can fail (I/O, network, parsing, user input)

    line 15
  2. Distinctive:

    When reviewing error handling in existing code

    line 16
  3. Distinctive:

    Before any service goes to production

    line 17
  4. Distinctive:

    Every error message answers: what went wrong?

    line 34
  5. Distinctive:

    Never expose internal system details (DB schema, file paths) in user-facing errors.

    line 39
  6. Distinctive:

    After max retries: fail with a clear error, log the final failure.

    line 47
  7. Distinctive:

    Verify: Every non-critical dependency has a defined degraded state.

    line 58

“Common” is measured: kept by at least 6 in 10 of the 37 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Overview

Error handling is not defensive programming — it's a user experience. When things go wrong (and they will), the system should degrade gracefully, give users actionable information, and leave enough telemetry to diagnose and fix the problem.

When to Use

  • When writing any code that can fail (I/O, network, parsing, user input)
  • When reviewing error handling in existing code
  • Before any service goes to production

Process

Step 1: Design Error Paths Explicitly

  1. For every operation, list: what can fail? What does failure look like?
  2. Classify failures:
    • Transient: Retry likely to succeed (network blip, temporary unavailability)
    • Client error: Bad input from the caller (4xx) — don't retry
    • System error: Internal failure (5xx) — alert, investigate
  3. Design the failure path for each class before writing the happy path.

Verify: Error classes defined for every external operation.

Step 2: Meaningful Error Messages

  1. Every error message answers: what went wrong? How can the caller fix it?
    • ✅ "Invalid email format. Expected: user@domain.com"
    • ❌ "Validation error"
  2. User-facing errors: friendly language, no stack traces.
  3. Developer-facing errors (logs): full context, request ID, stack trace.
  4. Never expose internal system details (DB schema, file paths) in user-facing errors.

Verify: Each error message would help a user or developer understand and fix the problem.

Step 3: Retry with Backoff

  1. Transient errors: retry with exponential backoff + jitter.
  2. Maximum retries: 3 (not infinite).
  3. After max retries: fail with a clear error, log the final failure.
  4. Non-transient errors (validation, auth): never retry.

Verify: Retry logic has a maximum. Non-transient errors don't retry.

Step 4: Graceful Degradation

  1. Identify non-critical dependencies. If they fail, degrade — don't crash.
  2. Example: recommendation engine fails → show default content, not 500.
  3. Circuit breaker pattern for failing dependencies: fail fast after threshold, recover automatically.

Verify: Every non-critical dependency has a defined degraded state.

Step 5: Structured Error Responses (APIs)

  1. API errors return consistent structure:
    {
      "error": {
        "code": "INVALID_EMAIL",
        "message": "The email address format is invalid.",
        "requestId": "req_abc123"
      }
    }
  2. HTTP status codes used correctly: 400 (client error), 404 (not found), 429 (rate limited), 500 (server error).

Common Rationalizations (and Rebuttals)

ExcuseRebuttal
"I'll add error handling later"Later means in production, under pressure, while users are impacted.
"This can't fail"Everything can fail. Network calls, disk writes, parsing — all can fail.
"The error message doesn't matter"It matters when a developer is debugging at 2am.

Verification

  • Error classes defined for every external operation
  • Error messages answer: what went wrong? How to fix?
  • Transient errors retry with max limit
  • Non-critical dependencies have graceful degraded states
  • API errors return consistent structured format
  • No internal system details in user-facing errors

References

  • observability skill
  • debugging-methodology skill

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.