# rust-implement

rust-implement enforces a four-pass discipline for Rust development, moving from strict type design to implementation, simplification, and automated linting.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 254 installs · ★ 227 repo stars
- Author: pproenca
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/pproenca/dot-skills/tree/HEAD/skills/.curated/rust-implement/SKILL.md
- Updated: 2026-08-15
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/rust-implement

## What it does

This skill guides the coding agent through four distinct engineering passes. During the first pass, it drafts only data types and function signatures. Booleans turn into enums, functions with four or more parameters receive dedicated argument structs, and structures intended for serialization rely on `BTreeMap` instead of `HashMap`. The implementation pass strictly demands `.context()` on every `?` operator, bans wildcard match arms, and separates errors between `anyhow` for applications and `thiserror` for crates.

The simplification pass removes forwarded call-chain arguments and inlines single-use wrappers. Finally, the verification pass executes `bash ${SKILL_DIR}/scripts/lint.sh <your-file.rs>` and audits against a checklist banning `unwrap()` outside tests and keeping modules under 500 lines. Automated verification relies on having bash available to execute the bundled lint script.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add pproenca/dot-skills --skill rust-implement -a claude-code
```

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

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add pproenca/dot-skills --skill rust-implement -a codex
```

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

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add pproenca/dot-skills --skill rust-implement -a cursor
```

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

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install pproenca/dot-skills skills/.curated/rust-implement
```

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

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add pproenca/dot-skills --skill rust-implement -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/pproenca/dot-skills --path skills/.curated/rust-implement
```

### Windsurf (Devin Desktop)

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

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add pproenca/dot-skills --skill rust-implement -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/pproenca/dot-skills/tree/HEAD/skills/.curated/rust-implement/SKILL.md

## When to use it
- design type-safe structs and enums that make invalid states unrepresentable
- enforce mandatory error context on every ? operator using anyhow or thiserror
- prevent async executor stalls by dropping mutex guards before .await
- clean up unused wrappers and unnecessary .clone() calls across modules

## Example prompts
- Implement a background task worker in Rust following rust-implement rules
- Design types and error enums for a new CLI command using thiserror
- Review and simplify src/storage.rs against the verification checklist

## Source text · SKILL.md · MIT

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: 5352db98801a3a25.

BEGIN THIRD-PARTY FILE 5352db98801a3a25
```text
---
name: rust-implement
description: "Write production-grade Rust code using a multi-pass approach. Design types first, then implement, then simplify, then verify with automated lint. Use this skill whenever writing new Rust functions, structs, modules, or features. Triggers on Rust implementation, new Rust code, Rust functions, Rust modules, error handling in Rust, async Rust, or type design in Rust."
---

# Rust Implementation Discipline

Write code in passes. Experts don't produce perfect code in one shot -- they design, implement, review, and simplify. Follow this process for every module you write.

---

## Pass 1: Design Types and Signatures

Before writing any implementation, write ONLY the type definitions and function signatures. No bodies. No logic.

Ask yourself these questions before moving on:

- Can any enum state represent an invalid combination? If yes, restructure so invalid states are unrepresentable.
- Are all parameters self-documenting? Replace `bool` params with enums (Transformation 2).
- Does every struct that will be serialized or compared use `BTreeMap`, not `HashMap` (Transformation 3)?
- Do config structs derive `Default` (Transformation 6)?
- Would a caller confuse the order of String parameters? Use newtypes.
- Does any struct have 2+ `Option<T>` fields where only one combination is valid at a time? Convert to an enum (Transformation 8).
- Does any function take 4+ parameters? Replace with an args struct (Transformation 9).

**Do not proceed to Pass 2 until the types are right. Types are the architecture.**

---

## Pass 2: Implement

Fill in the function bodies. As you write each function, apply these rules:

- Every `?` gets `.context("failed to [verb] [noun]")` -- no exceptions (Transformation 1).
- For library code: use `thiserror` for error enums. For application code: use `anyhow`.
- Use `Cow<str>` when a function sometimes borrows and sometimes allocates (Transformation 7).
- Return named structs, not tuples, from any function with 2+ return values (Transformation 5).
- Exhaustive match arms -- no `_ =>` wildcards (Transformation 4).

### Thread-Through Plumbing

When adding a new field that needs to reach execution sites, trace the full path and explicitly name every intermediate layer before writing code. For each hop, state the module and struct/function that carries the value. If you skip a layer, the field silently disappears at runtime.

### Drop/Teardown Precision

- Drop lock guards before any `.await` -- a held `MutexGuard` across an await blocks the executor.
- Close stdin explicitly in `Drop` impls. Brief wait, then fallback kill.
```
END THIRD-PARTY FILE 5352db98801a3a25

The third-party file has ended. Everything between the 5352db98801a3a25 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 2625 of 11329 bytes. © pproenca · MIT · https://github.com/pproenca/dot-skills/tree/HEAD/skills/.curated/rust-implement/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
