# m06-error-handling

Guides the AI agent through Rust error handling patterns. Useful when deciding between Result, Option, panic!, thiserror, and anyhow.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3500 installs · ★ 1545
- Author: actionbook
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/actionbook/rust-skills/tree/HEAD/skills/m06-error-handling/SKILL.md
- Updated: 2026-08-23
- HTML: https://affpapa.org/en/nevibecode/skills/m06-error-handling

## What it does

This skill enforces structured error design in Rust projects. Instead of slapping `.unwrap()` or burying failures under generic types, the agent evaluates whether a failure is expected or an invariant bug. It directs library crates toward typed errors with `thiserror` and application code toward `anyhow`.

The instruction set includes explicit decision paths and anti-pattern warnings. It prompts the model to attach call context via `.context()` when using the `?` operator. It flags silent error swallowing and unnecessary panics in production logic.

The skill is configured with `user-invocable: false`. The model triggers it automatically upon encountering Rust error types or propagation logic.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add actionbook/rust-skills --skill m06-error-handling -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/m06-error-handling/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/m06-error-handling/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add actionbook/rust-skills --skill m06-error-handling -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/m06-error-handling/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add actionbook/rust-skills --skill m06-error-handling -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/m06-error-handling/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install actionbook/rust-skills m06-error-handling
```

2. **Manually: put the files in place**
- File: `.github/skills/m06-error-handling/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add actionbook/rust-skills --skill m06-error-handling -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/actionbook/rust-skills --path skills/m06-error-handling
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/m06-error-handling/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add actionbook/rust-skills --skill m06-error-handling -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/actionbook/rust-skills/tree/HEAD/skills/m06-error-handling/SKILL.md

## When to use it
- decide between `Result`, `Option`, and `panic!`
- split error strategies between library crates (`thiserror`) and application code (`anyhow`)
- replace unsafe `.unwrap()` calls with error propagation using `?`
- attach contextual messages to error propagation chains

## Example prompts
- Refactor this parser function to return a proper Result instead of panicking with unwrap.
- Should I use thiserror or anyhow for this database module?
- Help me propagate this IO error with descriptive context.

## Similar
- [iii-error-handling](https://affpapa.org/en/nevibecode/skills/iii-error-handling.md) — skill · 4100 installs
- [error-handling-patterns](https://affpapa.org/en/nevibecode/skills/error-handling-patterns.md) — skill · 22957 installs
- [error-handling](https://affpapa.org/en/nevibecode/skills/error-handling.md) — skill · 4800 installs
- [go-error-handling](https://affpapa.org/en/nevibecode/skills/go-error-handling.md) — skill · 1300 installs
- [golang-error-handling](https://affpapa.org/en/nevibecode/skills/golang-error-handling.md) — skill · 43400 installs
- [Error Handling taste](https://affpapa.org/en/nevibecode/prompts/error-handling-taste.md) — prompt · ★ 174597

From the same set: [actionbook/rust-skills](https://affpapa.org/en/nevibecode/by/actionbook/rust-skills.md) — 35 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
