agentskills.codes

Build safe, concurrent, and performant systems with Rust. Use when writing Rust applications, implementing ownership and borrowing patterns, building concurrent code with threads/async, designing trait-based abstractions, or optimizing Rust performance.

Install

mkdir -p .claude/skills/rust-mkspwr12 && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15169" && unzip -o skill.zip -d .claude/skills/rust-mkspwr12 && rm skill.zip

Installs to .claude/skills/rust-mkspwr12

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Build safe, concurrent, and performant systems with Rust. Use when writing Rust applications, implementing ownership and borrowing patterns, building concurrent code with threads/async, designing trait-based abstractions, or optimizing Rust performance.
253 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)

About this skill

Rust Development

Purpose: Best practices for Rust development including ownership, error handling, concurrency, and safety patterns.


When to Use This Skill

  • Building Rust applications and systems
  • Working with ownership, borrowing, and lifetimes
  • Implementing error handling with Result and Option types
  • Writing concurrent code with threads and async
  • Designing trait-based abstractions

Prerequisites

  • Rust 1.75+ installed via rustup
  • Cargo package manager

Table of Contents

  1. Project Structure
  2. Ownership and Borrowing
  3. Error Handling
  4. Traits and Generics
  5. Concurrency
  6. Testing
  7. Performance
  8. Security
  9. Best Practices

Project Structure

Standard Layout

project/
├── src/
│   ├── main.rs              # Binary entry point
│   ├── lib.rs               # Library root
│   ├── config.rs            # Configuration
│   ├── error.rs             # Error types
│   ├── models/
│   │   ├── mod.rs
│   │   └── user.rs
│   └── services/
│       ├── mod.rs
│       └── user_service.rs
├── tests/
│   └── integration_tests.rs
├── benches/
│   └── benchmarks.rs
├── examples/
│   └── basic_usage.rs
├── Cargo.toml
├── Cargo.lock
└── README.md

Cargo.toml

[package]
name = "myapp"
version = "0.1.0"
edition = "2021"
authors = ["Your Name <[email protected]>"]
description = "A brief description"

[dependencies]
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
thiserror = "1"
anyhow = "1"

[dev-dependencies]
tokio-test = "0.4"

[profile.release]
lto = true
opt-level = 3

Best Practices

✅ DO

  • Use clippy for linting: cargo clippy
  • Format with rustfmt: cargo fmt
  • Prefer &str over String for function parameters
  • Use #[derive] for common traits
  • Write documentation with ///
  • Use Result for recoverable errors
  • Leverage the type system for safety

❌ DON'T

  • Use unwrap() in production code
  • Ignore compiler warnings
  • Use unsafe without clear justification
  • Clone unnecessarily
  • Write overly complex lifetimes
  • Panic for expected error conditions

References


Version: 1.0 Last Updated: February 5, 2026

Troubleshooting

IssueSolution
Borrow checker errorsUse .clone() for simple cases, refactor with owned types or Arc<Mutex<T>>
Lifetime annotation confusionStart with owned types, add references only when performance requires it
Async runtime errorsEnsure using #[tokio::main] or equivalent, dont mix sync and async without spawn_blocking

Search skills

Search the agent skills registry