AGENT SKILL

error-recovery

Consistent error patterns, validation approaches, and recovery strategies. Use when implementing input validation, designing error responses, handling failures gracefully, or establishing logging practices. Covers operational vs programmer errors, user-facing vs internal errors, and recovery mechanisms.

License 许可
MIT
最近更新
2026-11-01
Stars
★ 3
Forks
1

01 前言 Front Matter

name
error-recovery
description
Consistent error patterns, validation approaches, and recovery strategies. Use when implementing input validation, designing error responses, handling failures gracefully, or establishing logging practices. Covers operational vs programmer errors, user-facing vs internal errors, and recovery mechanisms.

02 资源文件 1

03 SKILL.md 正文

Error Handling

When to Use

  • Implementing input validation at system boundaries
  • Designing error responses for APIs or user interfaces
  • Building recovery mechanisms for transient failures
  • Establishing logging and monitoring patterns
  • Distinguishing between errors that need user action vs system intervention

Philosophy

Errors are not exceptional - they are expected. Good error handling treats errors as first-class citizens of the system design, not afterthoughts. The goal is to fail safely, provide actionable feedback, and enable recovery.

Error Classification

Operational Errors

Runtime problems that occur during normal operation. These are expected and must be handled.

Characteristics:

  • External system failures (network, database, filesystem)
  • Invalid user input
  • Resource exhaustion (memory, disk, connections)
  • Timeout conditions
  • Rate limiting

Response: Handle gracefully, log appropriately, provide user feedback, implement recovery.

Programmer Errors

Bugs in the code that should not happen if the code is correct.

Characteristics:

  • Type errors caught at runtime
  • Null/undefined access on required values
  • Failed assertions on invariants
  • Invalid internal state

Response: Fail fast, log full context, alert developers. Do not attempt recovery - fix the bug.

Core Patterns

Input Validation

Validate early, validate completely, provide specific feedback.

PATTERN: Fail-Fast Validation

1. Validate at system boundaries (API entry, user input, file reads)
2. Check all constraints before processing
3. Return ALL validation errors, not just the first one
4. Include field name, actual value (if safe), and expected format
5. Never trust data from external sources

Validation checklist:

  • Required fields present
  • Types correct
  • Values within allowed ranges
  • Formats match expectations (email, URL, date)
  • Business rules satisfied

Error Messages

Different audiences need different information.

User-facing errors:

  • Clear action the user can take
  • No technical jargon or stack traces
  • Consistent tone and format
  • Localization-ready

Internal/logged errors:

  • Full technical context
  • Request/correlation IDs
  • Timestamp and service identifier
  • Stack trace for programmer errors
  • Sanitized sensitive data

Recovery Strategies

Retry with backoff:

  • Transient failures (network timeouts, rate limits)
  • Exponential backoff with jitter
  • Maximum retry count with circuit breaker

Fallback:

  • Degraded functionality over complete failure
  • Cached data when live data unavailable
  • Default values when configuration missing

Compensation:

  • Undo partial operations on failure
  • Maintain consistency in distributed operations
  • Saga pattern for multi-step processes

Logging Levels

Level Use For
ERROR Operational errors requiring attention
WARN Recoverable issues, degraded performance
INFO Significant state changes, request lifecycle
DEBUG Detailed flow for troubleshooting

What to log:

  • Correlation/request ID
  • User context (sanitized)
  • Operation being attempted
  • Error type and message
  • Duration and timing

What NOT to log:

  • Passwords, tokens, secrets
  • Full credit card numbers
  • Personal identifiable information (PII)
  • Raw request/response bodies containing sensitive data

Best Practices

  • Fail fast on programmer errors - do not mask bugs
  • Handle operational errors gracefully with recovery options
  • Provide correlation IDs for tracing requests across services
  • Use structured logging (JSON) for machine parseability
  • Centralize error handling logic - avoid scattered try/catch blocks
  • Test error paths as rigorously as success paths
  • Monitor error rates and set alerts for anomalies

Anti-Patterns

  • Catching all exceptions silently (catch {})
  • Logging sensitive data in error messages
  • Returning generic "Something went wrong" without context
  • Retrying non-idempotent operations without safeguards
  • Mixing validation errors with system errors in responses
  • Treating all errors the same regardless of recoverability

References

04 同仓库更多 Skills

shengdabai
shengdabai/Tony-Claude-Code-Skills

seedance-prompt-en

Write effective prompts for Jimeng Seedance 2.0 multimodal AI video generation. Use when users want to create video prompts using text, images, videos, and audio inputs with the @ reference system. Covers camera movements, effects replication, video extension, editing, music beat-matching, e-commerce ads, short dramas, and educational content.

★ 3
shengdabai
shengdabai/Tony-Claude-Code-Skills

onepage-pdf

Convert an HTML page into a single continuous-page PDF (one tall page, no pagination breaks), preserving desktop layout, backgrounds and selectable text. Use when the user asks to turn an HTML file/report/proposal into a "single-page PDF", "long PDF", "不分页 PDF", "单页 PDF", "长图式 PDF", or complains that an HTML-to-PDF export breaks into pages or cuts content. Supports optional string redaction with leak verification.

★ 3
shengdabai
shengdabai/Tony-Claude-Code-Skills

native-feel-cross-platform-desktop

Use when the user is designing, prototyping, or rewriting a desktop app that must run on multiple OSes (macOS + Windows, optionally Linux) AND feel indistinguishable from a native app to its users — fast launch, native windowing, native input handling, native materials. Trigger words include "cross-platform desktop", "Electron alternative", "Tauri vs native", "WebView wrapper", "near-native performance", "Raycast architecture", "WebKit/WebView2 quirks", "WKWebView", "system tray app", "global hotkey app", "launcher app". Do NOT trigger this skill for pure web apps, pure mobile apps, or for greenfield projects that have no native-feel requirement.

★ 3
shengdabai
shengdabai/Tony-Claude-Code-Skills

gstack

Router for the gstack skill suite. (gstack)

★ 3
shengdabai
shengdabai/Tony-Claude-Code-Skills

fireworks-tech-graph

Use when the user wants to create any technical diagram - architecture, data flow, flowchart, sequence, agent/memory, or concept map - and export as SVG+PNG. Trigger on: "画图" "帮我画" "生成图" "做个图" "架构图" "流程图" "可视化一下" "出图" "generate diagram" "draw diagram" "visualize" or any system/flow description the user wants illustrated.

★ 3
shengdabai
shengdabai/Tony-Claude-Code-Skills

dbs-video-extract

接收抖音、小红书、微信视频号等短视频链接或分享文案,查询作品/账号数据并提取语音文字稿,按作者和标题归档为 Markdown。用户希望完整解析短视频、取得数据或文字稿时使用;运行前检查 TikHub 与轻抖使用凭证,缺少时用新手能理解的方式引导购买和安全配置。

★ 3