Rust development

From laurigates/claude-plugins · View interactive version

Rust development is an AI agent skill from the GitHub repository laurigates/claude-plugins. Rust development — cargo, clippy, rustfmt, async, Tokio, Serde, memory safety. Use when mentioning Rust, cargo, ownership, lifetimes, fearless concurrency, or async programming.

How to use this skill

Skill file

Rust Development

Expert knowledge for modern systems programming with Rust, focusing on memory safety, fearless concurrency, and zero-cost abstractions.

When to Use This Skill

| Use this skill when... | Use sibling skill instead when... |

|---|---|

| Writing Rust code, ownership, lifetimes, async/await | Configuring lint rules in detail -- use clippy-advanced |

| Choosing crates from the ecosystem (Tokio, Serde) | Detecting unused dependencies -- use cargo-machete |

| Designing module structure or trait hierarchies | Running tests with parallel isolation -- use cargo-nextest |

| Learning idiomatic Rust patterns and edition features | Generating coverage reports -- use cargo-llvm-cov |

Core Expertise

Modern Rust Ecosystem

Language Features

Key Capabilities

Ownership & Memory Safety

Async Programming & Concurrency

Error Handling & Type Safety

Performance Optimization

Testing & Quality Assurance

Essential Commands

# Project setup
cargo new my-project      # Binary crate
cargo new my-lib --lib    # Library crate
cargo init                # Initialize in existing directory
# From a template repo instead of an empty crate — see the cargo-generate skill
cargo generate --git <template-url> --name my-project

# Development workflow
cargo build                      # Debug build
cargo build --release           # Optimized build
cargo run                       # Build and run
cargo run --release             # Run optimized
cargo test                      # Run all tests
cargo test --lib               # Library tests only
cargo bench                     # Run benchmarks

# Code quality
cargo clippy                    # Lint code
cargo clippy -- -W clippy::pedantic  # Stricter lints
cargo fmt                       # Format code
cargo fmt --check              # Check formatting
cargo fix                       # Auto-fix warnings

# Dependencies
cargo add serde --features derive  # Add dependency
cargo update                       # Update deps
cargo audit                        # Security audit
cargo deny check                   # License/advisory check

# Advanced tools
cargo expand                    # Macro expansion
cargo flamegraph               # Profile with flame graph
cargo doc --open               # Generate and open docs
cargo miri test                # Check for UB

# Cross-compilation
rustup target add wasm32-unknown-unknown
cargo build --target wasm32-unknown-unknown

Best Practices

Idiomatic Rust Patterns

// Use iterators over manual loops
let sum: i32 = numbers.iter().filter(|x| **x > 0).sum();

// Prefer combinators for Option/Result
let value = config.get("key")
    .and_then(|v| v.parse().ok())
    .unwrap_or_default();

// Use pattern matching effectively
match result {
    Ok(value) if value > 0 => process(value),
    Ok(_) => handle_zero(),
    Err(e) => return Err(e.into()),
}

// Let-else for early returns
let Some(config) = load_config() else {
    return Err(ConfigError::NotFound);
};

Project Structure

my-project/
├── Cargo.toml
├── src/
│   ├── lib.rs        # Library root
│   ├── main.rs       # Binary entry point
│   ├── error.rs      # Error types
│   └── modules/
│       └── mod.rs
├── tests/            # Integration tests
├── benches/          # Benchmarks
└── examples/         # Example programs

Error Handling

use thiserror::Error;

#[derive(Error, Debug)]
pub enum AppError {
    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),

    #[error("parse error: {message}")]
    Parse { message: String },

    #[error("not found: {0}")]
    NotFound(String),
}

pub type Result<T> = std::result::Result<T, AppError>;

Common Crates

| Crate | Purpose |

|-------|---------|

| serde | Serialization/deserialization |

| tokio | Async runtime |

| reqwest | HTTP client |

| sqlx | Async SQL |

| clap | CLI argument parsing |

| tracing | Logging/diagnostics |

| anyhow | Application errors |

| thiserror | Library errors |

CI toolchain: pin the compiler in a root rust-toolchain.toml that Renovate bumps, so a new release's lints arrive as a PR; see clippy-advanced § Pin the toolchain.

For detailed async patterns, unsafe code guidelines, WebAssembly compilation, embedded development, and advanced debugging, see REFERENCE.md.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.