Skip to main content
This skill provides expert-level Rust knowledge for building high-performance, memory-safe systems with Rust 1.75+ features, advanced async programming, and modern ecosystem practices.

What This Skill Provides

The Rust Pro skill equips agents with deep expertise in modern Rust development, focusing on advanced language features, async programming, and production-ready systems.

Core Knowledge Areas

Modern Language Features

Rust 1.75+ features, const generics, GATs, advanced lifetime annotations

Ownership & Memory

Ownership rules, smart pointers, RAII patterns, zero-cost abstractions

Async Programming

Tokio runtime, async/await patterns, stream processing, concurrency

Type System Mastery

Advanced traits, GATs, phantom types, type-level programming

Performance

Zero-cost abstractions, SIMD, lock-free programming, profiling

Web Development

axum, warp, actix-web, hyper, HTTP/2-3 support, WebSocket

When This Skill Is Loaded

Agents load this skill when:
  • Building Rust services, libraries, or systems tooling
  • Solving ownership, lifetime, or async design issues
  • Optimizing performance with memory safety guarantees
  • Implementing high-performance backend services
  • Working with Tokio ecosystem (axum, tower, hyper)
  • Creating memory-safe systems or embedded software
  • Interfacing with C libraries via FFI
Use this skill PROACTIVELY for Rust development, performance optimization, or systems programming tasks.

Use Cases

High-Performance Web Services

Building modern async web services with:
  • axum - Ergonomic, modular web framework built on tower
  • tower - Middleware and service abstractions
  • hyper - HTTP/2 and HTTP/3 support
  • tokio - Async runtime for I/O operations

Modern Web Stack

axum + tower + tokio provides ergonomic, composable, high-performance web services with type-safe routing and middleware.

Async Programming with Tokio

Mastering async patterns:
  • Advanced async/await patterns
  • Stream processing and async iterators
  • Channel patterns (mpsc, broadcast, watch)
  • Select patterns and concurrent task management
  • Backpressure handling and flow control

Memory Management Excellence

Smart Pointers

  • Box for heap allocation
  • Rc/Arc for reference counting
  • RefCell/Mutex for interior mutability
  • Weak references

Zero-Cost Abstractions

  • Memory layout optimization
  • Phantom types and ZSTs
  • Custom allocators
  • RAII patterns

Systems Programming

  • Low-level I/O - Memory mapping, direct hardware access
  • Lock-free programming - Atomic operations, concurrent data structures
  • FFI - Safe abstractions over C libraries
  • Embedded - Cross-compilation, no_std environments

Type System Features

Advanced Type System:
  • Generic Associated Types (GATs) - Higher-kinded type patterns
  • Const Generics - Type-level numeric parameters
  • Phantom Types - Zero-runtime-cost type safety
  • Trait Bounds - Precise capability constraints
  • Associated Types - Type-level function outputs

Key Principles

Ownership & Borrowing Mastery

Core Ownership Rules

  1. Each value has exactly one owner
  2. When the owner goes out of scope, value is dropped
  3. Borrowing rules: multiple immutable OR one mutable
  4. Lifetimes ensure references are always valid

Async Best Practices

Tokio Patterns:
  • Use async/await for I/O-bound operations
  • Select! for concurrent waiting
  • Channels for message passing
  • Streams for async iteration
  • Spawn tasks for parallelism
Avoid:
  • Blocking operations in async contexts
  • Too many small tasks (overhead)
  • Forgetting to await futures
  • Holding locks across await points

Performance Mindset

Zero-Cost Abstractions:Rust abstractions compile down to the same assembly as hand-written C code. Use high-level abstractions without runtime cost.When optimizing:
  1. Profile first (perf, flamegraph, criterion)
  2. Optimize hot paths only
  3. Use SIMD for data parallelism
  4. Consider cache-friendly data structures
  5. Leverage compile-time computation

Error Handling Excellence

Error Types

  • thiserror - Derive error types
  • anyhow - Application errors
  • Custom error types for libraries
  • Result and Option combinators

Best Practices

  • Fail fast with ?
  • Context preservation
  • Typed errors for libraries
  • Anyhow for applications
  • Panic for unrecoverable errors

API Patterns

API design principles for Rust web services

Node.js Best Practices

Complementary backend runtime patterns

Python Patterns

Alternative backend development approaches

Which Agents Use This Skill

Backend Specialist

The Backend Specialist loads this skill for Rust-based backend development, high-performance services, and systems programming tasks.
The Backend Specialist uses this skill alongside api-patterns for designing Rust APIs and other backend skills as needed.

Modern Web Frameworks

Why axum?

  • Built on tower (composable middleware)
  • Type-safe routing with extractors
  • Ergonomic error handling
  • Excellent async support with tokio
  • Growing ecosystem

Framework Comparison

FrameworkBest ForComplexity
axumModern APIs, microservicesLow-Medium
actix-webHigh performance, matureMedium
warpFilter-based routingMedium-High
rocketDeveloper experienceMedium

Testing & Quality

Testing Strategy

Unit Tests

Built-in #[test] attribute, tests in same file or tests/ module

Integration Tests

Separate tests/ directory, test public API as external crate

Property-Based

proptest, quickcheck for generative testing

Benchmarking

criterion.rs

Statistical benchmarking with:
  • Precise measurements
  • Statistical analysis
  • Regression detection
  • HTML report generation

Quality Tools

  • Clippy - Lints and suggestions
  • rustfmt - Code formatting
  • cargo-audit - Security audits
  • cargo-deny - Dependency policy enforcement
  • tarpaulin - Code coverage

Unsafe Code & FFI

Safe Abstractions

Unsafe Code Principles:
  1. Minimize unsafe blocks
  2. Document safety invariants clearly
  3. Provide safe public API over unsafe internals
  4. Audit regularly
  5. Use #[deny(unsafe_code)] when possible
FFI Best Practices:
  • Use bindgen for C bindings
  • Wrap in safe Rust API
  • Document safety requirements
  • Test thoroughly

Database Integration

Async Database Access

DriverDatabaseFeatures
sqlxPostgreSQL, MySQL, SQLiteCompile-time checked queries
tokio-postgresPostgreSQLPure Rust, async
dieselPostgreSQL, MySQL, SQLiteORM, sync
sea-ormPostgreSQL, MySQL, SQLiteAsync ORM
sqlx is recommended for async Rust services - it provides compile-time query verification with query! macro.

Serialization

serde - The Standard

Universal serialization framework:
  • JSON, YAML, TOML, MessagePack
  • Derive macros for easy implementation
  • Zero-copy deserialization
  • Custom serialization logic
  • Type-safe at compile time

Concurrency Patterns

Message Passing

mpsc

Multiple producers, single consumer channel

broadcast

Multiple producers, multiple consumers

watch

Single producer, multiple consumers (latest value)

Shared State

  • Mutex - Mutual exclusion lock
  • RwLock - Read-write lock (multiple readers, one writer)
  • Arc - Atomic reference counting for shared ownership
  • Atomic types - Lock-free primitives

Response Approach

1

Analyze Requirements

Understand Rust-specific safety and performance needs
2

Design Type-Safe APIs

Leverage type system for compile-time correctness
3

Implement Efficiently

Use zero-cost abstractions and appropriate algorithms
4

Include Testing

Unit, integration, and property-based tests
5

Consider Async

For I/O-bound operations and concurrency
6

Document Safety

Explain any unsafe code blocks and invariants
7

Optimize Carefully

Profile before optimizing, maintain safety

Anti-Patterns to Avoid

Don’t:
  • Fight the borrow checker (redesign instead)
  • Use clone() everywhere to satisfy compiler
  • Write unsafe code without careful review
  • Block async runtime with sync operations
  • Use unwrap() in production code
  • Ignore Clippy warnings without reason
  • Micro-optimize before profiling
Do:
  • Embrace ownership and borrowing
  • Use Arc and Rc appropriately
  • Provide safe abstractions over unsafe code
  • Use async for I/O, threads for CPU-bound work
  • Handle errors with Result and Option
  • Configure Clippy for your project
  • Profile to find real bottlenecks

Behavioral Traits

Expert Rust Developer Mindset:
  • Leverages type system for compile-time correctness
  • Prioritizes memory safety without sacrificing performance
  • Uses zero-cost abstractions and avoids runtime overhead
  • Implements explicit error handling with Result types
  • Writes comprehensive tests including property-based
  • Follows Rust idioms and community conventions
  • Documents unsafe code blocks with safety invariants
  • Optimizes for both correctness AND performance
  • Embraces functional programming patterns
  • Stays current with Rust evolution

Remember: Rust provides memory safety and fearless concurrency. Embrace the borrow checker as your ally, not your enemy. The compiler catches bugs at compile time that would be runtime errors in other languages.

Build docs developers (and LLMs) love