From fuse-rust
Use when designing Rust error handling — picking thiserror for libraries vs anyhow for applications, building typed error enums, converting errors with
How this skill is triggered — by the user, by Claude, or both
Slash command
/fuse-rust:rust-error-handlingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
The consensus split: **thiserror for libraries, anyhow for applications.** A library
The consensus split: thiserror for libraries, anyhow for applications. A library
exposes a typed error its callers can match; an application wants one ergonomic error
type and rich context. Getting this boundary right is the whole discipline.
thiserror / anyhow API
before writing derives (verification chain: fuse-browser fast-path on
docs.rs/thiserror and docs.rs/anyhow → Context7 → Exa).cargo clippy.| Crate kind | Tool | Why |
|---|---|---|
| Library (others depend on it) | thiserror | Typed enum, #[derive(Error)], callers can match on variants |
| Application (binary, top level) | anyhow | anyhow::Result<T>, ? everywhere, .context() for breadcrumbs |
| Simple / dep-free | hand-written std::error::Error | No dependency when one or two variants suffice |
anyhow::Error in a library's public API. It erases the type, so
callers cannot match or handle specific failures. Return a typed enum error.
thiserror is designed to not appear in your public API — switching to/from a
hand-written impl is not a breaking change.anyhow; libraries use thiserror. Do not pull anyhow into
a reusable library's signatures..context("...") /
.with_context(|| ...) turns "No such file or directory" into a traceable chain.#[from] for zero-boilerplate conversion, so ? lifts a source error into your
enum. #[from] implies #[source] — never write both.Result for anything a caller could
reasonably recover from. Reserve panic!/unwrap/expect for broken invariants.| Topic | Reference | Load when |
|---|---|---|
| thiserror (libraries) | thiserror-libraries.md | Building a typed error enum for a library API |
| anyhow (applications) | anyhow-applications.md | Handling errors in a binary / top-level app |
| Error design | error-design.md | Shaping enums, #[from] conversion, recoverable vs panic, the anyhow/thiserror boundary |
| Template | Load when |
|---|---|
| library-error.md | Need a complete thiserror library error module |
| application-error.md | Need a complete anyhow application entry point with context |
enum deriving thiserror::Error — no anyhow in the public APIanyhow::Result<T> and adds .context(...)#[from] used for source conversions; no redundant #[source] alongside it? used instead of unwrap() on fallible valuescargo clippy clean, sniper passednpx claudepluginhub fusengine/agents --plugin fuse-rustGuides completion of development work by verifying tests, detecting environment, and presenting structured options for merge, PR, or cleanup.
Guides creation and editing of skills using test-driven development with pressure scenarios and subagents to verify agent compliance.
Dispatches multiple subagents concurrently for independent tasks without shared state. Use when facing 2+ unrelated failures or subsystems that can be investigated in parallel.