# write-rust-tests

The write-rust-tests skill writes Rust tests for public APIs, edge cases, errors, and branches. Use it when a Rust crate needs targeted coverage.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · ★ 6244 repo stars
- Author: RediSearch
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/RediSearch/RediSearch/tree/HEAD/.skills/write-rust-tests/SKILL.md
- Updated: 2026-10-29
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/write-rust-tests

## What it does

The skill creates tests for a Rust file, crate, or directory. It can work with several paths at once; a directory makes the skill consider the Rust files inside it. A path without `src/` is resolved under `src/redisearch_rs`, so `numeric_range_tree` points to that module location.

Before adding a test, it checks which new branch or execution path the case would cover. Inputs that leave control flow unchanged are treated as duplicates, and simple `Default` or `From` delegations are skipped when the constructor already exercises them. Coverage gaps can be inspected with `check-rust-coverage`, while test structure follows `rust-tests-guidelines`.

A file, crate, or directory path is required so the skill knows which Rust code to examine.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add RediSearch/RediSearch --skill write-rust-tests -a claude-code
```

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

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add RediSearch/RediSearch --skill write-rust-tests -a codex
```

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

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add RediSearch/RediSearch --skill write-rust-tests -a cursor
```

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

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install RediSearch/RediSearch .skills/write-rust-tests/SKILL.md
```

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

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add RediSearch/RediSearch --skill write-rust-tests -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/RediSearch/RediSearch --path .skills/write-rust-tests
```

### Windsurf (Devin Desktop)

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

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add RediSearch/RediSearch --skill write-rust-tests -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/RediSearch/RediSearch/tree/HEAD/.skills/write-rust-tests/SKILL.md

## When to use it
- write tests for a Rust crate or file
- cover public APIs and edge cases
- exercise error branches
- inspect uncovered lines with `check-rust-coverage`
- remove tests that duplicate existing paths

## Example prompts
- Use `write-rust-tests` to add tests for `src/redisearch_rs/numeric_range_tree`.
- Apply `write-rust-tests` to `src/redisearch_rs/query.rs` and cover its error cases and edge conditions.
- Run `write-rust-tests` on `src/redisearch_rs` without adding tests for branches already covered.

## Similar
- [rust-write-tests](https://affpapa.org/en/nevibecode/skills/rust-write-tests.md) — skill · 257 installs
- [rust-unit-tests](https://affpapa.org/en/nevibecode/skills/rust-unit-tests.md) — skill · ★ 720 repo stars
- [rust-tests](https://affpapa.org/en/nevibecode/rules/rust-tests.md) — rule · ★ 1627 repo stars
- [devkit.java.write-unit-tests](https://affpapa.org/en/nevibecode/commands/devkitjavawrite-unit-tests.md) — command · ★ 372 repo stars
- [rust-best-practices](https://affpapa.org/en/nevibecode/skills/rust-best-practices.md) — skill · 23400 installs
- [rust-mcp-server-generator](https://affpapa.org/en/nevibecode/skills/rust-mcp-server-generator.md) — skill · 9181 installs

From the same set: [redisearch/redisearch](https://affpapa.org/en/nevibecode/by/redisearch/redisearch.md) — 4 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
