Agent skill

Rust Error Handling

by rocky-data in rocky-data/rocky

Decision tree for thiserror (library crates) vs anyhow (CLI/binary) in the Rocky engine workspace.

Apache-2.0Auto-check passedDatabases

Install Rust Error Handling

skills CLI
$ npx skills add rocky-data/rocky --skill rust-error-handling -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install rocky-data/rocky rust-error-handling --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/rocky-data/rocky.git skills-src && mkdir -p .claude/skills && cp -r skills-src/engine/.claude/skills/rust-error-handling .claude/skills/rust-error-handling && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
rust-error-handling
GitHub stars
304
Token cost
~2.3k tokens
SKILL.md length
998 words
Files
1
Skills in repo
22
Repo updated
First seen
Licence
Apache-2.0

At a glance

Decision tree for thiserror (library crates) vs anyhow (CLI/binary) in the Rocky engine workspace.

  • Works in 6 steps: Error enums are crate-local. Don't… → Every #[error("...")] message starts… → Use #[from] for automatic ? conversion… → …
  • Adding a new error type
  • SKILL.md covers Which crates use which, Library crates: thiserror…, Binary / CLI: anyhow pattern and How errors surface to Dagster, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Rust Error Handling is an agent skill from rocky-data/rocky. Decision tree for thiserror (library crates) vs anyhow (CLI/binary) in the Rocky engine workspace. Use when adding a new error type, adding a new From impl, deciding where to attach context, or triaging how an error surfaces to Dagster/JSON output.

Its SKILL.md is about 2.3k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Databases, covering Error handling and Data warehousing. It works with Rust and Dagster. The repository describes itself as: A SQL transformation engine that type-checks your whole pipeline and catches breaking changes before they run — branches, replay, column-level lineage, compile-time contracts… The licence is Apache-2.0.

When your agent uses it

  • Adding a new error type
  • Adding a new From impl
  • Deciding where to attach context
  • Triaging how an error surfaces to Dagster/JSON output

Example prompts

  • “/rust-error-handling”

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Error enums are crate-local. Don't define a "one error to rule them all" at workspace level — the enums are supposed to be small and…
  2. Every #[error("...")] message starts lowercase, does not end with a period, and includes the values that make this specific instance…
  3. Use #[from] for automatic ? conversion when there's only one reasonable way the child error could arise in this variant. If the same child…
  4. Use #[error(transparent)] only when the wrapper adds zero information — i.e. when it's literally a newtype pass-through.
  5. Derive Debug always. Do not derive Clone on errors unless a test harness or a background-task broadcast specifically needs it; cloning…
  6. Don't add an #[error("other: {0}")] Other(String) catch-all. That's an anyhow smell leaking into a library — if the library can't name the…

What it can do on your machine

Read from SKILL.md and the folder at commit 0cb7c7b. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are rust).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Rust Error Handling loads about 2.3k tokens when it runs. Until then it costs about 68 tokens; SKILL.md has 998 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~68
When it runs · the whole SKILL.md, loaded when a task matches
~2.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from rocky-data/rocky at commit 0cb7c7b, republished under its Apache-2.0 licence (© rocky-data). 998 words, ~2,291 tokens.

Download SKILL.mdSave it as .claude/skills/rust-error-handling/SKILL.md (or your agent's skills folder).
name
rust-error-handling
description
Decision tree for thiserror (library crates) vs anyhow (CLI/binary) in the Rocky engine workspace. Use when adding a new error type, adding a new `From` impl, deciding where to attach context, or triaging how an error surfaces to Dagster/JSON output.

Rust error handling in Rocky

Rocky uses a two-tier error handling strategy. The rule, from engine/CLAUDE.md § Coding Standards:

Use thiserror for library errors, anyhow for binary/CLI errors.

This skill is the decision tree: when to reach for which, what From impls to derive, how to attach context, and how errors flow out of the binary into Dagster JSON.

Which crates use which

LayerCrateError crateWhy
Libraryevery library crate — rocky-core, rocky-ir, rocky-sql, rocky-compiler, rocky-lang, rocky-adapter-sdk, the adapter crates (rocky-databricks, rocky-snowflake, rocky-bigquery, rocky-trino, rocky-duckdb, rocky-fivetran, rocky-airbyte, rocky-iceberg), rocky-catalog-core, rocky-cache, rocky-engine, rocky-ai, rocky-observe, rocky-server, rocky-mcpthiserrorLibrary errors need to be matchable by callers, namable, and stable.
Binary / CLIrocky-cli, rockyanyhowThe CLI is the top of the call stack — we don't care about matching errors, we care about printing them with context.

If a crate imports both thiserror and anyhow, that's usually a smell — check whether the library's error enum is leaking into the binary uselessly, or whether an anyhow::Error is being stashed into a #[error(transparent)] variant.

Library crates: thiserror pattern

Every library crate defines its errors as a named enum with #[derive(Debug, thiserror::Error)]. The #[error("…")] attribute provides the Display impl; #[from] derives From for automatic ? conversion.

Concrete examples already in the codebase:

  • crates/rocky-core/src/hooks/mod.rs — HookError with variants for command-failed / timeout / aborted / I/O / serialization / webhook (uses #[from] to chain std::io::Error, serde_json::Error, and WebhookError)
  • crates/rocky-core/src/hooks/webhook.rs — WebhookError with variants for request-failed / timeout / HTTP-status / template / HTTP-client
  • crates/rocky-core/src/circuit_breaker.rs — CircuitBreakerError with a single variant carrying consecutive_failures, threshold, and last_error
  • crates/rocky-databricks/src/{catalog,permissions,workspace}.rs — each module owns a small error enum scoped to its concerns

Template:

rust
use thiserror::Error;

#[derive(Debug, Error)]
pub enum FooError {
    /// Context-bearing message — include the values that make this specific.
    #[error("foo failed for {key}: {reason}")]
    Failed { key: String, reason: String },

    /// Transparent wrap of a child error — use when Foo is a thin shim and
    /// the caller should see the child error's Display directly.
    #[error(transparent)]
    Inner(#[from] BarError),

    /// External crate errors go behind `#[from]` so `?` works.
    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),
}

pub type Result<T> = std::result::Result<T, FooError>;

Rules:

  1. Error enums are crate-local. Don't define a "one error to rule them all" at workspace level — the enums are supposed to be small and scoped. rocky-core has separate errors per subsystem (HookError, WebhookError, CircuitBreakerError, ModelError, etc.).
  2. Every #[error("...")] message starts lowercase, does not end with a period, and includes the values that make this specific instance distinguishable from other instances of the same variant (see the hook command failed: {command} (exit code {exit_code}) style).
  3. Use #[from] for automatic ? conversion when there's only one reasonable way the child error could arise in this variant. If the same child type could come from two different code paths, split them into two variants and use .map_err(...) at the call site instead.
  4. Use #[error(transparent)] only when the wrapper adds zero information — i.e. when it's literally a newtype pass-through.
  5. Derive Debug always. Do not derive Clone on errors unless a test harness or a background-task broadcast specifically needs it; cloning errors usually means they're being held past their useful lifetime.
  6. Don't add an #[error("other: {0}")] Other(String) catch-all. That's an anyhow smell leaking into a library — if the library can't name the error, it probably shouldn't be producing it.

Binary / CLI: anyhow pattern

rocky-cli and the rocky binary use anyhow::Result<T> as the return type for command handlers. Errors are built from:

  • Library errors bubbling up through ? (anyhow auto-converts anything Debug + Display + Send + Sync + 'static)
  • .context("...") / .with_context(|| format!("...")) to attach extra information at each layer
  • anyhow::bail!("...") / anyhow::ensure!(cond, "...") for inline failures

Template:

rust
use anyhow::{Context, Result, bail, ensure};

pub fn run(config_path: &Path) -> Result<RunOutput> {
    let config = rocky_core::config::load(config_path)
        .with_context(|| format!("failed to load config at {}", config_path.display()))?;

    ensure!(!config.pipelines.is_empty(), "config has no pipelines");

    let Some(adapter) = config.adapters.get("default") else {
        bail!("no default adapter configured");
    };

    adapter.run()
        .context("pipeline run failed")
        // ↑ top-level context. Each library-level .context() below adds a layer.
}

Rules:

  1. Always attach context. A bare ? in a CLI handler throws away the "what were we trying to do" half of the story. Wrap every library call with .context("...") or .with_context(|| ...). Use with_context when the message needs runtime data (it's lazy), plain context when it's a static string (it's cheaper).
  2. bail! and ensure! are fine at command-handler level for preconditions that aren't worth their own library error type. Don't use them inside library crates.
  3. Don't .unwrap() or .expect() outside tests. The CLI should always return an error up to main.rs, which formats it with the full chain.
  4. Don't downcast anyhow errors unless you genuinely need to take a different action based on a specific root cause — it's rare and usually means the library should have exposed a typed predicate instead (e.g. is_rate_limit() on rocky-databricks/src/connector.rs).
Show full SKILL.md (351 more words)Show less

How errors surface to Dagster

The CLI emits JSON on stdout for every --output json invocation. When a handler returns Err(anyhow::Error):

  1. The rocky binary's entry point (rocky/src/main.rs) prints the error chain to stderr with all .context() layers.
  2. The process exits with code 1 (hard failure) or 2 (partial success — some tables failed, but a valid RunOutput JSON was still written to stdout).
  3. The Dagster integration at integrations/dagster/ reads the exit code and (for code 2) the partial-success JSON. It has allow_partial=True handling specifically for this case.

Implication for error messages: the Dagster integration surfaces your .context("...") strings to the Dagster event log. Make them operator-readable. "failed to load config at /path/rocky.toml" is useful; "load failed" is not.

Implication for library errors: if a library error variant needs to be distinguishable by Dagster (e.g. "transient, retry" vs "permanent, alert"), expose a predicate method on the error enum — don't make Dagster pattern-match on stringified messages. See rocky-databricks/src/connector.rs::is_transient and is_rate_limit for the canonical shape.

Common mistakes

MistakeFix
New library crate imports anyhow::Result in its public API.Swap to a thiserror enum. anyhow belongs to the CLI.
.unwrap() in a non-test code path.Use ? with a proper library error or .context() in the CLI.
#[error("Failed")] with no context.Include the runtime values — #[error("failed to parse {file}: {message}")].
A From<std::io::Error> impl on an error that has two places I/O can arise.Split into two variants; use .map_err(...) at each call site so the variant names where the I/O happened.
Other(String) catch-all variant in a library error.Delete it. If you genuinely don't know the error type, the caller also doesn't — bubble up the concrete child error instead.
eprintln!("error: {:?}", e) in the CLI.Return Err(e) from the handler. main.rs has a single error-printing path that handles the chain formatting.
  • rust-doc — public library errors need # Errors sections on the functions that return them.
  • rust-async-tokio — async errors flow through the same two-tier model (library returns Result<_, FooError>, CLI wraps with anyhow).
  • rocky-codegen (monorepo root) — when an error shape ends up in a *Output struct, the codegen cascade produces Pydantic + TypeScript bindings for it.

© rocky-data, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in engine/.claude/skills/rust-error-handling of rocky-data/rocky.

Open the folder on GitHubat commit 0cb7c7b

Compare with similar skills

Rust Error Handling next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Rust Error Handling compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Rust Error Handling this skillrocky-data/rocky304—~2.3kAutomated safety check: PassApache-2.0
SeekDB Code Reviewoceanbase/seekdb3.1k—~2.1kAutomated safety check: PassApache-2.0
Webapp Buildersidequery/sidemantic129—~5.5kAutomated safety check: PassAGPL-3.0
Querying Tempotempoxyz/tidx107—~3.1kAutomated safety check: PassMIT
Rust Projectmajiayu000/spellbook286—~2.9kAutomated safety check: PassMIT
Adding Ingestion WarningsPostHog/posthog-foss721—~3.7kAutomated safety check: PassMIT

Similar skills

  • SeekDB Code Review

    oceanbase/seekdb

    Reviews seekdb pull requests and diffs for real defects in correctness, resources, concurrency, security and tests, reporting only Blocker or Major findings.

    3.1k GitHub stars~2.1k tokensUpdated 4 days ago
    DevelopmentAuto-check passed
  • Webapp Builder

    sidequery/sidemantic

    Build interactive analytics webapps, demos, dashboards, or embedded app surfaces from Sidemantic semantic models using copyable component primitives and deterministic query inspection.

    129 GitHub stars~5.5k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Querying Tempo

    tempoxyz/tidx

    Query indexed Tempo chain data via tidx HTTP API and CLI. An agent skill from tempoxyz/tidx.

    107 GitHub stars~3.1k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Rust Project

    majiayu000/spellbook

    Modern Rust project architecture guide for 2025. An agent skill from majiayu000/spellbook.

    286 GitHub stars~2.9k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Adding Ingestion Warnings

    PostHog/posthog-foss

    Official

    How to add a new ingestion warning type to the event ingestion pipeline.

    721 GitHub stars~3.7k tokensUpdated today
    DatabasesAuto-check passed
  • Clickhouse Rust View Column Order

    divinevideo/divine-mobile

    Debug ClickHouse deserialization errors in Rust caused by column ORDER mismatch when using SELECT alias.

    265 GitHub stars~1.6k tokensUpdated today
    DatabasesAuto-check passed

More from rocky-data/rocky

All 22 skills in this repo
  • Fivetran

    rocky-data/rocky

    Fivetran REST API reference for Rocky's source adapter. An agent skill from rocky-data/rocky.

    304 GitHub stars~914 tokensUpdated yesterday
    Auto-check passed
  • Databricks

    rocky-data/rocky

    Databricks REST API and SQL reference for Rocky's warehouse adapter.

    304 GitHub stars~2k tokensUpdated yesterday
    Auto-check passed
  • Rocky Codegen

    rocky-data/rocky

    Rocky CLI JSON-output schema cascade. An agent skill from rocky-data/rocky.

    304 GitHub stars~1.9k tokensUpdated yesterday
    Auto-check passed
  • Rocky Dev

    rocky-data/rocky

    Top-level router for Rocky development tasks. An agent skill from rocky-data/rocky.

    304 GitHub stars~2.1k tokensUpdated yesterday
    Auto-check passed
  • Rocky Dsl Change

    rocky-data/rocky

    Rocky DSL (.rocky file) cross-subproject cascade. An agent skill from rocky-data/rocky.

    304 GitHub stars~1.3k tokensUpdated yesterday
    Auto-check passed
  • Rocky New Adapter

    rocky-data/rocky

    Adding a new warehouse or source adapter crate to the Rocky engine.

    304 GitHub stars~2k tokensUpdated yesterday
    Auto-check passed

Works with

Questions about Rust Error Handling

What does Rust Error Handling do?

Decision tree for thiserror (library crates) vs anyhow (CLI/binary) in the Rocky engine workspace. Rust Error Handling is an agent skill from rocky-data/rocky. Decision tree for thiserror (library crates) vs anyhow (CLI/binary) in the Rocky engine workspace.

When should I use Rust Error Handling?

Rust Error Handling fits situations like: adding a new error type; adding a new From impl; deciding where to attach context; triaging how an error surfaces to Dagster/JSON output.

How do I install Rust Error Handling in Claude Code?

Run `npx skills add rocky-data/rocky --skill rust-error-handling -a claude-code`. Or copy the skill folder (engine/.claude/skills/rust-error-handling in rocky-data/rocky) into .claude/skills/rust-error-handling in your project. Claude Code loads it when a task matches its description.

How do I install Rust Error Handling in Codex?

Run `npx skills add rocky-data/rocky --skill rust-error-handling -a codex`. Or copy the skill folder (engine/.claude/skills/rust-error-handling in rocky-data/rocky) into .agents/skills/rust-error-handling in your project. Codex loads it when a task matches its description.

Can I use Rust Error Handling in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add rocky-data/rocky --skill rust-error-handling -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/rust-error-handling, .gemini/skills/rust-error-handling, .github/skills/rust-error-handling and .opencode/skills/rust-error-handling in your project.

What does Rust Error Handling need to run?

SKILL.md names no scripts, command-line tools or credentials: Rust Error Handling is instructions for the agent only.

Does Rust Error Handling access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Rust Error Handling safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Rust Error Handling use?

Rust Error Handling is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Rust Error Handling use?

About 2.3k tokens (SKILL.md is roughly 9.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Rust Error Handling?

Skills that share tags, products or a category with Rust Error Handling: SeekDB Code Review (oceanbase/seekdb, 3.1k stars), Webapp Builder (sidequery/sidemantic, 129 stars), Querying Tempo (tempoxyz/tidx, 107 stars) and Rust Project (majiayu000/spellbook, 286 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Rust Error Handling?

rocky-data (a GitHub organization) maintains it in rocky-data/rocky, which has 304 GitHub stars. The repository holds 22 skills in this directory. The repository was last updated on October 7, 2026.

Source: rocky-data/rocky on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.