skills/rust-development/SKILL.md
Rust development workflow with quality gates, testing, and iteration patterns. Use when developing Rust code, running tests, or iterating on Rust projects.
npx skillsauth add thrashr888/thrashr888-agent-kit rust-developmentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Development patterns for Rust CLI tools and libraries, based on AllBeads and QDOS workflows.
ALL THREE must pass before commits:
cargo fmt -- --check && cargo clippy -- -D warnings && cargo test
Run frequently during development, not just before commits.
# Fast check (no codegen)
cargo check
# Full build
cargo build
# Release build
cargo build --release
# All tests
cargo test
# Specific test
cargo test test_name
# With output
cargo test -- --nocapture
# Single-threaded (for tests with shared state)
cargo test -- --test-threads=1
# Format code
cargo fmt
# Check formatting without changing
cargo fmt -- --check
# Lint with warnings as errors
cargo clippy -- -D warnings
# Auto-fix clippy suggestions
cargo clippy --fix --allow-dirty
# Debug build
cargo run -- [args]
# Release build
cargo run --release -- [args]
# With specific features
cargo run --features "feature1,feature2" -- [args]
Standard Rust project layout:
project/
├── Cargo.toml # Package manifest
├── Cargo.lock # Dependency lock
├── src/
│ ├── main.rs # Binary entry point
│ ├── lib.rs # Library root (if both bin and lib)
│ └── module/
│ └── mod.rs
├── tests/ # Integration tests
├── benches/ # Benchmarks
└── examples/ # Example binaries
anyhow)use anyhow::{Context, Result};
fn main() -> Result<()> {
let config = load_config()
.context("Failed to load configuration")?;
Ok(())
}
thiserror)use thiserror::Error;
#[derive(Error, Debug)]
pub enum MyError {
#[error("Invalid input: {0}")]
InvalidInput(String),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
}
# Add dependency
cargo add serde --features derive
# Add dev dependency
cargo add --dev tokio-test
# Update dependencies
cargo update
# Check for outdated
cargo outdated # requires cargo-outdated
For multi-crate projects:
# Cargo.toml (workspace root)
[workspace]
members = ["crate1", "crate2"]
resolver = "2"
[workspace.dependencies]
serde = { version = "1.0", features = ["derive"] }
# Build with debug info for profiling
cargo build --release
# Time compilation
cargo build --timings
# Check binary size
cargo bloat --release # requires cargo-bloat
Faster linking times:
# .cargo/config.toml
[target.'cfg(target_os = "linux")']
rustflags = ["-C", "link-arg=-fuse-ld=mold"]
Install: sudo apt install mold or brew install mold
Cache compiler artifacts across builds:
cargo install --locked sccache
export RUSTC_WRAPPER=sccache
# Add to shell profile for persistence
echo 'export RUSTC_WRAPPER=sccache' >> ~/.zshrc
Reduce boilerplate for common derives:
macro_rules! auto_derived {
( $( $item:item )+ ) => {
$(
#[derive(Debug, Clone, PartialEq, Eq)]
$item
)+
};
}
// Usage
auto_derived! {
pub struct User {
id: i64,
name: String,
}
pub struct Config {
host: String,
port: u16,
}
}
Add Serialize, Deserialize to the macro if using serde.
pub struct Config {
host: String,
port: u16,
}
impl Config {
pub fn builder() -> ConfigBuilder {
ConfigBuilder::default()
}
}
#[derive(Default)]
pub struct ConfigBuilder {
host: Option<String>,
port: Option<u16>,
}
impl ConfigBuilder {
pub fn host(mut self, host: impl Into<String>) -> Self {
self.host = Some(host.into());
self
}
pub fn port(mut self, port: u16) -> Self {
self.port = Some(port);
self
}
pub fn build(self) -> Result<Config, &'static str> {
Ok(Config {
host: self.host.ok_or("host required")?,
port: self.port.unwrap_or(8080),
})
}
}
pub struct UserId(pub i64);
pub struct Email(String);
impl Email {
pub fn new(s: impl Into<String>) -> Result<Self, &'static str> {
let s = s.into();
if s.contains('@') {
Ok(Self(s))
} else {
Err("invalid email")
}
}
}
For VS Code with rust-analyzer:
// .vscode/settings.json
{
"rust-analyzer.check.command": "clippy",
"rust-analyzer.cargo.features": "all"
}
DON'T:
.unwrap() in library code (use ? instead)cargo fmt before commitsDO:
Result<T, E> for fallible operations#[must_use] for important return valuesdevelopment
Generate standardized project documentation using the 5-style system. Use when asked to create plans, specs, skills, RFCs, ADRs, or other project documentation. Ensures consistent, high-quality documentation across the codebase.
tools
Release workflow for Rust CLI tools with multi-platform binaries, GitHub Releases, and Homebrew distribution. Use when releasing a new version of a Rust project.
tools
Onboard a new Rust project with standard tooling, CI/CD, and best practices. Use when starting a new Rust project or setting up an existing one with proper infrastructure.
development
Rust coding best practices for idiomatic, efficient, and maintainable code. Use when writing Rust code, reviewing code, or learning Rust patterns.