Claude Marketplaces
SkillsMCP serversMarketplacesDigestTools
Submit

This week in Claude

Every Monday: Claude Code, Agent SDK, MCP, and the Anthropic platform moves worth your time.

Skills by category
Frontend DevelopmentBackend & APIsTesting & QASecurityDevOps & CI/CDGit & Pull RequestsDocumentationCode Review & QualityAI & Agent BuildingSkill Development
MCP servers by category
Sales & MarketingWeb & Browser AutomationDatabasesAI & LLM ToolsCloud & InfrastructureCommunication & MessagingDeveloper ToolsDesign & CreativeDocuments & KnowledgeSearch & Web Crawling
Marketplaces by category
AI Agents & OrchestrationLLM IntegrationDevelopment ToolsFrontend & UIBackend & APIsDatabasesTesting & Code QualityDevOps & CloudSecurity & ComplianceGit & Version Control
Claude Marketplaces

An independent directory of skills, plugins and MCP servers for Claude Code. Not affiliated with Anthropic.

Browse

  • Skills
  • MCP servers
  • Marketplaces
  • Weekly digest
  • Skill index
  • MCP index
  • Marketplace index

Site

  • About
  • Tools
  • Submit
  • Feedback
  • Privacy
  • llms.txt
  • Plugins reference

Maker

  • Snug
  • Agent Caffeine
  • knobs
  • Wax
  • Vectoys
  • mertduzgun.com
Crafted at
Skills/Debugging
zhanghandong avatar

M13 Domain Error

zhanghandong/rust-skills

Domain error handling strategy resource for Rust developers designing error types and recovery mechanisms. It addresses who needs to handle errors (end users, developers, or operations) and how to categorize them (transient vs. permanent, user-facing vs. internal) to determine appropriate recovery strategies like retries, fallbacks, and circuit breakers. The skill solves the problem of inconsistent error handling across application layers by providing a framework that connects domain requirements to implementation patterns.

installs
738
GitHub stars
1.3K
last updated
Jul 14, 2026
View on GitHubSave

Install

$ npx -y skills add zhanghandong/rust-skills --skill m13-domain-error --agent claude-code

Installs into .claude/skills of the current project.

Files

Domain Error Strategy

Layer 2: Design Choices

Core Question

Who needs to handle this error, and how should they recover?

Before designing error types:

  • Is this user-facing or internal?
  • Is recovery possible?
  • What context is needed for debugging?

Error Categorization

Error TypeAudienceRecoveryExample
User-facingEnd usersGuide actionInvalidEmail, NotFound
InternalDevelopersDebug infoDatabaseError, ParseError
SystemOps/SREMonitor/alertConnectionTimeout, RateLimited
TransientAutomationRetryNetworkError, ServiceUnavailable
PermanentHumanInvestigateConfigInvalid, DataCorrupted

Thinking Prompt

Before designing error types:

  1. Who sees this error?

    • End user → friendly message, actionable
    • Developer → detailed, debuggable
    • Ops → structured, alertable
  2. Can we recover?

    • Transient → retry with backoff
    • Degradable → fallback value
    • Permanent → fail fast, alert
  3. What context is needed?

    • Call chain → anyhow::Context
    • Request ID → structured logging
    • Input data → error payload

Trace Up ↑

To domain constraints (Layer 3):

"How should I handle payment failures?"
    ↑ Ask: What are the business rules for retries?
    ↑ Check: domain-fintech (transaction requirements)
    ↑ Check: SLA (availability requirements)
QuestionTrace ToAsk
Retry policydomain-*What's acceptable latency for retry?
User experiencedomain-*What message should users see?
Compliancedomain-*What must be logged for audit?

Trace Down ↓

To implementation (Layer 1):

"Need typed errors"
    ↓ m06-error-handling: thiserror for library
    ↓ m04-zero-cost: Error enum design

"Need error context"
    ↓ m06-error-handling: anyhow::Context
    ↓ Logging: tracing with fields

"Need retry logic"
    ↓ m07-concurrency: async retry patterns
    ↓ Crates: tokio-retry, backoff

Quick Reference

Recovery PatternWhenImplementation
RetryTransient failuresexponential backoff
FallbackDegraded modecached/default value
Circuit BreakerCascading failuresfailsafe-rs
TimeoutSlow operationstokio::time::timeout
BulkheadIsolationseparate thread pools

Error Hierarchy

#[derive(thiserror::Error, Debug)]
pub enum AppError {
    // User-facing
    #[error("Invalid input: {0}")]
    Validation(String),

    // Transient (retryable)
    #[error("Service temporarily unavailable")]
    ServiceUnavailable(#[source] reqwest::Error),

    // Internal (log details, show generic)
    #[error("Internal error")]
    Internal(#[source] anyhow::Error),
}

impl AppError {
    pub fn is_retryable(&self) -> bool {
        matches!(self, Self::ServiceUnavailable(_))
    }
}

Retry Pattern

use tokio_retry::{Retry, strategy::ExponentialBackoff};

async fn with_retry<F, T, E>(f: F) -> Result<T, E>
where
    F: Fn() -> impl Future<Output = Result<T, E>>,
    E: std::fmt::Debug,
{
    let strategy = ExponentialBackoff::from_millis(100)
        .max_delay(Duration::from_secs(10))
        .take(5);

    Retry::spawn(strategy, || f()).await
}

Common Mistakes

MistakeWhy WrongBetter
Same error for allNo actionabilityCategorize by audience
Retry everythingWasted resourcesOnly transient errors
Infinite retryDoS selfMax attempts + backoff
Expose internal errorsSecurity riskUser-friendly messages
No contextHard to debug.context() everywhere

Anti-Patterns

Anti-PatternWhy BadBetter
String errorsNo structurethiserror types
panic! for recoverableBad UXResult with context
Ignore errorsSilent failuresLog or propagate
Box everywhereLost type infothiserror
Error in happy pathPerformanceEarly validation

Related Skills

WhenSee
Error handling basicsm06-error-handling
Retry implementationm07-concurrency
Domain modelingm09-domain
User-facing APIsdomain-*
SKILL.md on GitHub

Sponsors

SnugThe clipboard manager you and your agent can use, safelyAgent CaffeineClose your lid, come back to finished workWaxBlock anything with supervision, without erasing your iPhoneOpen StepsSponsoredFree and open-source skills that make AI coding agents easier to understand, verify, and control.

Details

Repository
github.com/zhanghandong/rust-skills
Categories
Debugging, Rust

More from zhanghandong/rust-skills

All 34
  • Rust Trait Explorer731
  • Rust Code Navigator728
  • Unsafe Checker726
  • Domain Cli709
  • Rust Symbol Analyzer702
  • Rust Call Graph699
  • Rust Router698
  • Rust Learner688
  • Rust Deps Visualizer684
  • Rust Skill Creator670
  • Domain Web648
  • Meta Cognition Parallel635
  • Rust Daily635
  • Domain Embedded625
  • Domain Cloud Native596
  • Domain Fintech581
  • Domain Ml573
  • Domain Iot568
  • M15 Anti Pattern5.6K
  • Coding Guidelines1.2K
  • M10 Performance895
  • M07 Concurrency844
  • M06 Error Handling827
  • Rust Refactor Helper821

Recommended

More Debugging
1dimillian avatarbug-hunt-swarmdimillian/skillsParallel read-only multi-agent root-cause investigation for bugs, regressions, crashes, flaky behavior, or unexplained failures. Use when the user asks to inves715installs
2joellewis avatarperformance-metricsjoellewis/finance_skillsEvaluate investment performance on a risk-adjusted basis using industry-standard ratios and capture analysis. Use when the user asks about Sharpe ratio, Sortino714installs
3theqtcompanyrnd avatarqt-qml-profilertheqtcompanyrnd/agent-skills>-701installs
4joellewis avatarperformance-reportingjoellewis/finance_skillsGenerate clear, accurate performance reports for investment portfolios with benchmarks, attribution, and risk dashboards. Use when the user asks about portfolio697installs
5patternsdev avatarjs-performance-patternspatternsdev/skillsProvides framework-agnostic JavaScript runtime performance patterns. Use when optimizing hot paths, loops, DOM operations, caching, or data structure choices in688installs
6charon-fan avatardebuggercharon-fan/agent-playbookdebugger678installs