Error semantics recovery path design

From Vrooli/Vrooli · View interactive version

Error semantics recovery path design is an AI agent skill from the GitHub repository Vrooli/Vrooli. Prioritize **making errors meaningful, structured, and recoverable** for both users and agents.

How to use this skill

Skill file

Steer focus: Error Semantics & Recovery Path Design

Prioritize making errors meaningful, structured, and recoverable for both users and agents.

Your goal is to turn “something went wrong” into clear categories with explicit recovery paths, without breaking existing behavior.

Do not regress tests, weaken protections, or introduce unrelated features. All changes must maintain or improve completeness and reliability.

Required reading:


**1. Clarify Error Domains & Categories**

Focus on crisp, high-signal categories, not an explosion of tiny types.

Principles for Good Error Categories

When deriving categories, apply these criteria:

  1. Mutually exclusive: Each error should map to exactly one category. If you're unsure where an error belongs, the categories need refinement.
  1. Recovery-distinct: Two categories should have different recovery paths. If "network timeout" and "service unavailable" both mean "retry after backoff," they might be one category.
  1. User-recognizable: Category names should make sense to users, not just developers. "Validation error" is good; "schema mismatch" is too internal.
  1. Aim for 4-8 categories: Fewer than 4 means overly generic (everything is "error"). More than 8 means hard to maintain consistency.
  1. Stable across the codebase: The same category should mean the same thing everywhere. If "not found" sometimes means "resource deleted" and sometimes "URL typo," split them.

**1.5 Error Handling Audit**

Before improving error semantics, understand the current state:

Step 1: Inventory Error Origins
# Where are errors created/thrown?
rg "throw |new Error|Error\(" --type ts --type go -l

# Where are errors caught/handled?
rg "catch|\.catch\(|if.*err != nil" --type ts --type go -l

# What error types/shapes exist?
rg "type.*Error|interface.*Error|class.*Error" --type ts --type go
Step 2: Assess Error Message Quality
# Find generic/unhelpful messages
rg "Something went wrong|An error occurred|Unknown error|Error:" --type ts

# Find messages that might leak internals
rg "stack|stackTrace|internal|debug" --type ts -i
Step 3: Find Recovery Path Gaps
# Error UI without recovery actions
rg "error|Error" --type tsx -A 5 | rg -v "retry|try again|go back|refresh"

# Catch blocks that swallow errors
rg "catch.*\{" --type ts -A 2 | rg -B 2 "^\s*\}"

Red flags:


**2. Normalize & Structure Error Representations**

Do not introduce a brand-new global error framework; prefer incremental normalization of existing patterns.

Documenting Error Categories

When defining error categories, add protective comments explaining the design:

/**
 * ╔════════════════════════════════════════════════════════════════╗
 * ║  ERROR CATEGORIES - Read before modifying                      ║
 * ║                                                                ║
 * ║  Each category has a specific recovery path. Changing these    ║
 * ║  affects UI error states and automated retry logic.            ║
 * ║                                                                ║
 * ║  To add a new category:                                        ║
 * ║  1. Ensure it has a distinct recovery path                     ║
 * ║  2. Update error UI components to handle it                    ║
 * ║  3. Add to API error mapping if client-facing                  ║
 * ╚════════════════════════════════════════════════════════════════╝
 */

This prevents future agents from creating ad-hoc error types that fragment the error handling system.


**3. Define Explicit Recovery Paths**

For each major error category, make the intended recovery action clear and consistent:

Avoid speculative recovery flows; focus on concrete, realistic failure modes that the scenario actually encounters.

Criteria for Choosing Recovery Paths

When deciding what recovery action fits an error category, consider:

| Question | If YES → | If NO → |

|----------|----------|---------|

| Can the user fix the cause? | Guide them to fix it (show what's wrong, keep their input) | Don't blame them |

| Is the cause likely transient? | Retry automatically (with backoff) or offer retry button | Don't suggest retry |

| Is partial progress valuable? | Preserve it, let user continue from checkpoint | Clean abort is fine |

| Does the user need to know? | Show clear message with next steps | Log only, don't interrupt |

| Can an agent reasonably handle this? | Return structured error with machine-readable hints | User escalation path |

Common anti-patterns:


**4. Improve User- & Agent-Facing Error Surfaces**

Where relevant, align status codes, UI messages, and internal error objects so they tell a coherent story.


**5. Tie Errors to Observability & Diagnosis**

The goal is to help future agents and humans quickly answer:

“What kind of error is this, and where should I look to debug it?”


**6. Preserve Behavior While Improving Semantics**

Favor small, coherent improvements over wide, speculative changes.


**7. Memory Management with Visited Tracker**

Use the visited-tracker-tools skill for tracking visited files, with LOCATION set to scenarios/{{TARGET}} and TAG set to error-semantics.


**8. Documentation**

Use knowledge-observatory-tools to read the current error-semantics doc for {{TARGET}}, then update it with your findings (error categories discovered/refined, recovery paths, error patterns improved and remaining).


**9. Output Expectations**

You may update:

You must:

Focus this loop on practical, high-impact improvements that make errors:

Avoid superficial changes (e.g. renaming error variables without changing semantics) that do not materially improve how the system communicates and handles failure.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.