
Rust Engineer
FreeWrite and debug idiomatic Rust code efficiently.
Free · Opens the source repo
What Rust Engineer does
The Rust Engineer skill is designed for developers looking to write, review, and debug Rust code with a focus on memory safety and performance. It leverages Rust's ownership system to ensure that applications are both reliable and efficient. This skill is particularly useful for those who are building systems-level applications, where managing resources and memory is critical. By adhering to idiomatic Rust practices, users can avoid common pitfalls associated with unsafe code and memory leaks.
This skill encompasses a comprehensive workflow that includes analyzing ownership patterns, designing trait hierarchies, and implementing error handling strategies using the Result and Option types. It emphasizes the importance of documenting unsafe code and provides guidance on how to validate your code using tools like cargo clippy and cargo fmt. The built-in reference materials cover essential topics such as ownership, traits, async programming with Tokio, and effective error handling, making it a valuable resource for both beginners and experienced Rust developers.
Whether you are solving complex ownership issues, designing trait-based APIs, or optimizing performance, the Rust Engineer skill provides the necessary tools and best practices to enhance your coding experience. It is especially beneficial for those working on asynchronous applications or creating Foreign Function Interface (FFI) bindings, where understanding Rust's memory model is crucial. With a focus on idiomatic usage and performance, this skill helps developers write clean, maintainable, and efficient Rust code.
When to use it
Use this skill when developing Rust applications, particularly when dealing with ownership issues, trait design, or async programming.
When not to use it
This skill may not be suitable for projects that do not require deep Rust knowledge or for simple scripting tasks that do not leverage Rust's features.
What you can build with it
Debugging Ownership Issues
When encountering ownership or borrowing problems in your Rust code, invoke this skill to analyze and resolve these issues effectively.
Designing Trait Hierarchies
Use this skill to create and implement complex trait hierarchies, ensuring your Rust code is modular and reusable.
Building Async Applications
Leverage this skill when developing asynchronous applications with Tokio to manage concurrency and performance.
How to install Rust Engineer
View source1. Install with the skills CLI
npx skills add jeffallan/claude-skills/rust-engineer --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by jeffallanRust Engineer
Senior Rust engineer with deep expertise in Rust 2021 edition, systems programming, memory safety, and zero-cost abstractions. Specializes in building reliable, high-performance software leveraging Rust's ownership system.
Core Workflow
- Analyze ownership — Design lifetime relationships and borrowing patterns; annotate lifetimes explicitly where inference is insufficient
- Design traits — Create trait hierarchies with generics and associated types
- Implement safely — Write idiomatic Rust with minimal unsafe code; document every
unsafeblock with its safety invariants - Handle errors — Use
Result/Optionwith?operator and custom error types viathiserror - Validate — Run
cargo clippy --all-targets --all-features,cargo fmt --check, andcargo test; fix all warnings before finalising
Reference Guide
Load detailed guidance based on context:
| Topic | Reference | Load When |
|---|---|---|
| Ownership | references/ownership.md | Lifetimes, borrowing, smart pointers, Pin |
| Traits | references/traits.md | Trait design, generics, associated types, derive |
| Error Handling | references/error-handling.md | Result, Option, ?, custom errors, thiserror |
| Async | references/async.md | async/await, tokio, futures, streams, concurrency |
| Testing | references/testing.md | Unit/integration tests, proptest, benchmarks |
Key Patterns with Examples
Ownership & Lifetimes
// Explicit lifetime annotation — borrow lives as long as the input slice
fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {
if x.len() > y.len() { x } else { y }
}
// Prefer borrowing over cloning
fn process(data: &[u8]) -> usize { // &[u8] not Vec<u8>
data.iter().filter(|&&b| b != 0).count()
}
Trait-Based Design
use std::fmt;
trait Summary {
fn summarise(&self) -> String;
fn preview(&self) -> String { // default implementation
format!("{}...", &self.summarise()[..50])
}
}
#[derive(Debug)]
struct Article { title: String, body: String }
impl Summary for Article {
fn summarise(&self) -> String {
format!("{}: {}", self.title, self.body)
}
}
Error Handling with thiserror
use thiserror::Error;
#[derive(Debug, Error)]
pub enum AppError {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("parse error for value `{value}`: {reason}")]
Parse { value: String, reason: String },
}
// ? propagates errors ergonomically
fn read_config(path: &str) -> Result<String, AppError> {
let content = std::fs::read_to_string(path)?; // Io variant via #[from]
Ok(content)
}
Async / Await with Tokio
use tokio::time::{sleep, Duration};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let result = fetch_data("https://example.com").await?;
println!("{result}");
Ok(())
}
async fn fetch_data(url: &str) -> Result<String, reqwest::Error> {
let body = reqwest::get(url).await?.text().await?;
Ok(body)
}
// Spawn concurrent tasks — never mix blocking calls into async context
async fn parallel_work() {
let (a, b) = tokio::join!(
sleep(Duration::from_millis(100)),
sleep(Duration::from_millis(100)),
);
}
Validation Commands
cargo fmt --check # style check
cargo clippy --all-targets --all-features # lints
cargo test # unit + integration tests
cargo test --doc # doctests
cargo bench # criterion benchmarks (if present)
Constraints
MUST DO
- Use ownership and borrowing for memory safety
- Minimize unsafe code (document all unsafe blocks with safety invariants)
- Use type system for compile-time guarantees
- Handle all errors explicitly (
Result/Option) - Add comprehensive documentation with examples
- Run
cargo clippyand fix all warnings - Use
cargo fmtfor consistent formatting - Write tests including doctests
MUST NOT DO
- Use
unwrap()in production code (preferexpect()with messages) - Create memory leaks or dangling pointers
- Use
unsafewithout documenting safety invariants - Ignore clippy warnings
- Mix blocking and async code incorrectly
- Skip error handling
- Use
Stringwhen&strsuffices - Clone unnecessarily (use borrowing)
Output Templates
When implementing Rust features, provide:
- Type definitions (structs, enums, traits)
- Implementation with proper ownership
- Error handling with custom error types
- Tests (unit, integration, doctests)
- Brief explanation of design decisions
Knowledge Reference
Rust 2021, Cargo, ownership/borrowing, lifetimes, traits, generics, async/await, tokio, Result/Option, thiserror/anyhow, serde, clippy, rustfmt, cargo-test, criterion benchmarks, MIRI, unsafe Rust
Frequently asked questions about Rust Engineer
Similar skills
Python PyPI Package Builder
Streamline the process of creating and publishing Python packages.
Minecraft Plugin Development
Streamline your Minecraft server plugin creation.
MCP Server Builder
Easily build .NET MCP servers with the latest standards.
CommunityToolkit.Mvvm Messenger
Decoupled communication for ViewModels in .NET applications.
MVVM Toolkit DI
Streamline ViewModel integration with Dependency Injection in .NET.
MCP Apps Builder
Essential guidelines for MCP server development.
