# Improve Rust Errors with thiserror

Rust error enums can become verbose and lose source context. This skill guides Claude, Codex, and Claude Code to create idiomatic thiserror types.

## Install

```bash
npx skillstore add emillindfors/thiserror-expert
```

## Metadata

- Status: approved
- Slug: emillindfors-thiserror-expert
- Version: 1.0.0
- Author version: 1.0.0
- Skillstore revision: r1
- Version status: valid
- Tree hash: 311bb77fd47e2a61d05e3042a3a4a73aedfbbeb9a0e9df02b84c38ab192a2f17
- Author: EmilLindfors
- GitHub username: EmilLindfors
- License: MIT
- Repository: https://github.com/EmilLindfors/claude-marketplace/tree/main/plugins/rust-error-handling/skills/thiserror-expert
- 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: 79
- Quality tier: bronze
- Public page: https://skillstore.pages.dev/skills/emillindfors-thiserror-expert
- Manifest: https://skillstore.pages.dev/api/skills/emillindfors-thiserror-expert/manifest

## Capabilities

- Reviews Rust error enums for thiserror derive usage.
- Suggests \#\[error\] messages for unit, tuple, and struct variants.
- Explains when to use \#\[from\], \#\[source\], and \#\[error\(transparent\)\].
- Shows patterns for layered domain, infrastructure, and application errors.
- Identifies missing source chains and vague error messages.
- Provides focused guidance for Result aliases and custom error construction.

## Use Cases

- Refactor manual error implementations: Convert hand-written Display and Error implementations into concise thiserror enums.
- Design library error APIs: Create stable public error types with clear messages and preserved source chains.
- Review error propagation patterns: Check whether \#\[from\], \#\[source\], or transparent wrappers fit each error boundary.

## Prompt Templates

### Review one error enum

```
Review my Rust error enum and suggest a thiserror version with clear messages and correct derives.
```

### Improve source chains

```
Check my error variants for missing source chains. Explain where #[from] or #[source] should be used.
```

### Design layered errors

```
Design thiserror enums for my domain, infrastructure, and application layers. Explain the conversion boundaries.
```

### Audit public error API

```
Audit my public Rust error API for thiserror usage, stable variant names, source preservation, and actionable messages.
```

## Limitations

- Does not compile or test Rust projects by itself.
- Does not replace project-specific API design review.
- Focuses on thiserror and not every Rust error-handling crate.
- May need project context to choose public error variants.

## Best Practices

- Use actionable error messages that include useful context without exposing secrets.
- Preserve underlying causes with \#\[from\], \#\[source\], or transparent wrappers when appropriate.
- Keep public library errors stable and avoid leaking private implementation details.

## Anti Patterns

- Using vague messages such as Error or Something went wrong.
- Wrapping dependency errors without preserving the source chain.
- Using \#\[from\] when custom context must be added during construction.

## Security Audit

- Audited at: 2026-07-06T15:33:07.383\+00:00
- Summary: The static findings are false positives from Markdown backticks, Rust code fences, and Rust validation examples in SKILL.md. I found no prompt injection, command execution instructions, network access, filesystem writes, or data exfiltration intent.

## Stats

- Views: 192
- Downloads: 9
- Favorites: 0
- Popularity score: 0
