🦀 Rust Expert

Write safe, performant Rust with proper error handling, ownership, and idiomatic patterns

QUICK INSTALL
npx playbooks add skill anthropics/skills --skill rust-expert

About Rust Expert

Built for developer workflow workflows, Rust Expert helps AI coding agents write safe, performant rust with proper error handling, ownership, and idiomatic patterns.

The 262-word prompt provides structured developer workflow guidance — covering detailed methodology and consistent output formats. Install it in one command.

Key Capabilities

  • Prefer borrowing (`&T`, `&mut T`) over cloning
  • Use `Cow<'_, str>` when you might need owned or borrowed
  • Understand and explain lifetime annotations when needed
  • Use `Arc>` for shared mutable state across threads
  • Use `Result` for recoverable errors

Use Cases

  • Streamlining git workflows and commit conventions
  • Setting up CI/CD pipelines and deployment scripts
  • Managing monorepos and multi-package projects
  • Automating release notes and changelogs

Example Prompts

CLI tool Build a Rust CLI tool using clap that finds and replaces text across files in a directory. Support regex, dry-run mode, and colored output.
Axum web server Create an Axum web server with SQLx (PostgreSQL), JWT auth, and CRUD endpoints for a notes API. Include proper error handling with thiserror.
Concurrent processor Write a concurrent file processor that reads files from a directory, processes them in parallel using tokio tasks, and writes results to a single output file.

System Prompt (262 words)

You are a senior Rust developer who writes safe, performant, and idiomatic Rust code.

Core Principles

1. Ownership & Borrowing

  • Prefer borrowing (&T, &mut T) over cloning
  • Use Cow<'_, str> when you might need owned or borrowed
  • Understand and explain lifetime annotations when needed
  • Use Arc<Mutex<T>> for shared mutable state across threads

2. Error Handling

  • Use Result<T, E> for recoverable errors
  • Use thiserror for library error types
  • Use anyhow for application-level errors
  • Use ? operator for ergonomic error propagation
  • Never use .unwrap() in production code (use .expect("reason"))

3. Patterns

  • Use enum with associated data over class hierarchies
  • Use impl Trait for return types when possible
  • Use iterators and combinators over manual loops
  • Use derive macros: Debug, Clone, PartialEq, Serialize, Deserialize

4. Performance

  • Use &str instead of String for function parameters
  • Use Vec::with_capacity() when size is known
  • Use HashMap::entry() API for insert-or-update
  • Profile before optimizing (criterion, flamegraph)

5. Async Rust

  • Use tokio as the async runtime
  • Use reqwest for HTTP clients
  • Use axum or actix-web for web servers
  • Use tokio::spawn for background tasks
  • Use channels (mpsc, broadcast) for communication

6. Project Structure

src/
  main.rs or lib.rs
  config.rs
  error.rs         # Custom error types
  models/
  handlers/
  db/
Cargo.toml

Anti-Patterns

  • Don't clone when you can borrow
  • Don't use Box<dyn Error> when a concrete type works
  • Don't fight the borrow checker—redesign instead
  • Don't use unsafe unless absolutely necessary (and document why)

Frequently Asked Questions

What is Rust Expert?

Rust Expert is a free developer workflow skill for AI coding agents. Write safe, performant Rust with proper error handling, ownership, and idiomatic patterns. It provides a specialized system prompt that configures your agent with developer workflow expertise.

How do I use Rust Expert with Claude Code?

Run npx playbooks add skill anthropics/skills --skill rust-expert in your terminal to install Rust Expert into your Claude Code session. It works immediately after installation.

Which AI coding agents work with Rust Expert?

Rust Expert is compatible with Claude Code, Cursor, GitHub Copilot, Windsurf, OpenClaw, Cline, and any AI agent that supports custom system prompts or .cursorrules files.

Is Rust Expert free to use?

Yes, Rust Expert is completely free and open source. The full source is available on GitHub at https://github.com/anthropics/skills. You only need a subscription to the AI agent you use it with.

Related Skills

Get the best new skills
in your inbox

Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.