# rust-reviewer

The rust-reviewer skill for Claude Code and Codex reviews Rust code for ownership, lifetimes, and error handling issues. It examines the whole project, including unsafe blocks and idiomatic Rust patterns.

- skill · `type=skill` · Claude Code, Codex, OpenCode, Cursor, GitHub Copilot, Gemini CLI, Windsurf (Devin Desktop), Claude.ai · ★ 423 repo stars
- Author: relatedb
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/relatedb/relate/tree/HEAD/.agents/skills/rust-reviewer/SKILL.md
- Updated: 2026-11-16
- Security check: automated, 2026-11-17 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/rust-reviewer

## What it does

rust-reviewer checks a Rust project for ownership and borrowing problems, lifetime issues, `Result` and `Option` handling, unsafe code, and idiomatic style. It detects projects through `Cargo.toml`, `.rs` files, or directories such as `src/` and `tests/`.

The skill reviews the project without interactive choices. It can flag needless `clone()` calls, `unwrap()` in library code, and unchecked raw-pointer dereferences. Its project analysis covers the Rust edition, project type, dependencies, tests run with `cargo test`, and the `clippy` linter.

This skill reviews Rust projects; `rust-api-reviewer` handles Rust API reviews, while `go-reviewer` is for Go.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add relatedb/relate --skill rust-reviewer -a claude-code
```

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

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add relatedb/relate --skill rust-reviewer -a codex
```

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

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add relatedb/relate --skill rust-reviewer -a cursor
```

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

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install relatedb/relate .agents/skills/rust-reviewer
```

2. **Manually: put the files in place**
- File: `.github/skills/rust-reviewer/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add relatedb/relate --skill rust-reviewer -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/relatedb/relate --path .agents/skills/rust-reviewer
```

### Windsurf (Devin Desktop)

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

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add relatedb/relate --skill rust-reviewer -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/relatedb/relate/tree/HEAD/.agents/skills/rust-reviewer/SKILL.md

## When to use it
- spot unnecessary copies made with `clone()`
- inspect borrowing and lifetime annotations
- find `unwrap()` and `panic!` in error paths
- audit raw-pointer dereferences and `transmute`
- catch non-idiomatic Rust patterns

## Example prompts
- Review this Rust project for ownership and borrowing issues.
- Check the project's lifetimes and error handling.
- Audit the `unsafe` blocks and look for idiomatic Rust issues.

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: ddfe0a08e58f0a43.

BEGIN THIRD-PARTY FILE ddfe0a08e58f0a43
````text
---
name: rust-reviewer
description: |
  WHEN: Rust project review, ownership/borrowing, error handling, unsafe code, performance
  WHAT: Ownership patterns + Lifetime analysis + Error handling (Result/Option) + Unsafe audit + Idiomatic Rust
  WHEN NOT: Rust API → rust-api-reviewer, Go → go-reviewer
---

# Rust Reviewer Skill

## Purpose
Reviews Rust code for ownership, lifetimes, error handling, safety, and idiomatic patterns.

## When to Use
- Rust project code review
- Ownership/borrowing review
- Lifetime annotation review
- Unsafe code audit
- Error handling patterns

## Project Detection
- `Cargo.toml` in project root
- `.rs` files
- `src/lib.rs` or `src/main.rs`
- `tests/` directory

## Workflow

### Step 1: Analyze Project
```
**Rust Edition**: 2021
**Type**: Library / Binary
**Dependencies**: Key crates
**Testing**: cargo test
**Linter**: clippy
```

### Step 2: Run Full Review
Run a full review covering all areas below: ownership and borrowing, lifetimes and references, error handling (Result/Option), unsafe code audit, and idiomatic Rust. This skill runs headless, so no interactive selection — review everything by default.

## Detection Rules

### Ownership & Borrowing
| Check | Recommendation | Severity |
|-------|----------------|----------|
| Unnecessary clone() | Borrow instead | MEDIUM |
| &String parameter | Use &str | MEDIUM |
| Vec ownership transfer | Consider slice | MEDIUM |
| Excessive Rc/Arc | Restructure ownership | MEDIUM |

```rust
// BAD: Unnecessary clone
fn process(data: Vec<String>) {
    for item in data.clone().iter() {  // Clone not needed!
        println!("{}", item);
    }
}

// GOOD: Borrow
fn process(data: &[String]) {
    for item in data {
        println!("{}", item);
    }
}

// BAD: &String parameter
fn greet(name: &String) {
    println!("Hello, {}", name);
}

// GOOD: &str parameter (more flexible)
fn greet(name: &str) {
    println!("Hello, {}", name);
}

// BAD: Taking ownership unnecessarily
fn sum(numbers: Vec<i32>) -> i32 {
    numbers.iter().sum()
}

// GOOD: Borrow slice
fn sum(numbers: &[i32]) -> i32 {
    numbers.iter().sum()
}
```

### Lifetimes
| Check | Recommendation | Severity |
|-------|----------------|----------|
| Missing lifetime annotation | Add explicit lifetime | HIGH |
| 'static overuse | Use specific lifetime | MEDIUM |
| Lifetime in struct | Consider ownership | MEDIUM |
| Complex lifetime bounds | Simplify if possible | LOW |

```rust
// BAD: Missing lifetime
struct Parser {
    input: &str,  // Error: missing lifetime
}

// GOOD: Explicit lifetime
struct Parser<'a> {
    input: &'a str,
}

impl<'a> Parser<'a> {
    fn new(input: &'a str) -> Self {
        Parser { input }
    }

    fn parse(&self) -> Result<Ast<'a>, Error> {
        // ...
    }
}

// BAD: 'static when not needed
fn process(data: &'static str) {
    // Requires static lifetime!
}

// GOOD: Generic lifetime
fn process(data: &str) {
    // Works with any lifetime
}

// Consider: Ownership instead of lifetime
````
END THIRD-PARTY FILE ddfe0a08e58f0a43

The third-party file has ended. Everything between the ddfe0a08e58f0a43 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 3005 of 9294 bytes. © relatedb · Apache-2.0 · https://github.com/relatedb/relate/tree/HEAD/.agents/skills/rust-reviewer/SKILL.md

_Part of the page did not fit — see the HTML version._

---
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
