# Improve Rust Error Handling

Many Rust codebases hide failures behind panics or vague errors. This skill reviews patterns and suggests idiomatic Result, thiserror, and anyhow improvements.

## Install

```bash
npx skillstore add emillindfors/error-handler-advisor
```

## Metadata

- Status: approved
- Slug: emillindfors-error-handler-advisor
- Version: 1.0.0
- Author version: 1.0.0
- Skillstore revision: r1
- Version status: valid
- Tree hash: 9845282962cccd72bd7ee0368a6096cbae37b2b6ad22bfa09d1085492c590829
- Author: EmilLindfors
- GitHub username: EmilLindfors
- License: MIT
- Repository: https://github.com/EmilLindfors/claude-marketplace/tree/main/plugins/rust-error-handling/skills/error-handler-advisor
- Ref: a06681402992ceae98ba04d54cfd4ab004862696
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands
- Quality score: 80
- Quality tier: silver
- Public page: https://skillstore.pages.dev/skills/emillindfors-error-handler-advisor
- Manifest: https://skillstore.pages.dev/api/skills/emillindfors-error-handler-advisor/manifest

## Capabilities

- Identifies unwrap, expect, and panic usage in Rust error handling.
- Suggests Result and Option propagation with the ? operator.
- Recommends typed library errors with thiserror.
- Recommends anyhow context for application-level failures.
- Explains automatic error conversion with From and \#\[from\].
- Highlights tests for expected error cases.

## Use Cases

- Remove Panic Paths: Find production unwrap, expect, and panic usage and convert failures into recoverable errors.
- Design Library Errors: Create specific error enums that preserve source errors and support clear caller handling.
- Review Error Quality: Check pull requests for missing context, broad error variants, and untested failure cases.

## Prompt Templates

### Review Basic Error Handling

```
Review this Rust function for unwrap, expect, panic, and missing Result handling. Explain the safest simple improvement.
```

### Improve Error Context

```
Review this Rust workflow and suggest where anyhow context would make failures easier to debug.
```

### Design Typed Errors

```
Review these library errors and suggest a thiserror enum with specific variants and preserved source errors.
```

### Audit Error Boundaries

```
Analyze this Rust module for error propagation, conversion, caller ergonomics, and tests for important failure cases.
```

## Limitations

- Focuses on Rust error handling, not general application architecture.
- Provides review guidance and examples, not formal verification.
- Does not run builds, tests, or benchmarks by itself.
- Needs user-provided code context to make precise recommendations.

## Best Practices

- Return Result from fallible functions instead of panicking in reusable code.
- Use thiserror for library error types and anyhow for application boundaries.
- Test expected failure cases, not only successful paths.

## Anti Patterns

- Using unwrap or expect in production paths without a clear invariant.
- Returning generic string errors that callers cannot match safely.
- Dropping source errors during manual conversion.

## Security Audit

- Audited at: 2026-07-06T14:50:12.491\+00:00
- Summary: I reviewed SKILL.md and found a Rust error-handling guidance skill with no executable code or malicious intent. All static findings are false positives caused by Markdown backticks, Rust examples, thiserror attributes, and a punctuation heuristic. No external command execution, system reconnaissance, obfuscation payload, or prompt injection evidence was found.

## Stats

- Views: 159
- Downloads: 10
- Favorites: 0
- Popularity score: 0
