rust-expert — Claude Code skill: what it does, how to install
rust-expert — a skill that turns a coding agent into a Rust reviewer: borrowing rules, lifetimes, async tasks, error types. Useful when the borrow checker blocks a refactor.
Apache-2.0 179 installs ★ 45 updated 2026-10-12
npx skills add personamanagmentlayer/pcl --skill rust-expert -a claude-codeWhat rust-expert does
The skill gives the agent a Rust playbook. It covers ownership and borrowing, the type system, async code, error handling and Cargo setup, with samples for each: iterator chains in place of manual loops, &str parameters rather than &String, Cow when a copy is only sometimes needed, newtype wrappers that keep two ID types apart, typestate builders, Result and Option in the right places, Cargo features and a release profile.
A trap list follows. Two mutable references into the same Vec get solved with split_at_mut; string copies nobody needs and unwrap() in shipped code are flagged for fixing. There is a command sheet too: cargo new, cargo clippy -- -D warnings, cargo fmt --check, cargo test -- --nocapture. Longer notes sit in references/CORE_CONCEPTS.md and load when the agent needs them.
Rust 1.75 or newer is the stated requirement, and shell access is limited to cargo, rustc and rustup; everything else goes through reading and editing files. On a machine without that toolchain there is nothing to check the advice against.
What it helps with
- untangle two mutable borrows in one function
- replace
unwrap()with a typed error - drop a needless
clone()on a slice - separate
UserIdfromProductIdby type - wire up Cargo features and a release profile
Example prompts for the agent
- The compiler rejects two mutable borrows in
main.rs. Rework that block withsplit_at_mut. - Wrap
UserIdandProductIdin newtypes so one can't be passed where the other is expected. - Move the error handling in
main.rsoffunwrap()and onto aResultwith its own error type.
How to install rust-expert
1Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill rust-expert -a claude-code2Manually: put the files in place
~/.claude/skills/rust-expert/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/rust-expert/
1Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill rust-expert -a codex2Manually: put the files in place
.agents/skills/rust-expert/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill rust-expert -a cursor2Manually: put the files in place
.cursor/skills/rust-expert/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install personamanagmentlayer/pcl stdlib/languages/rust-expert2Manually: put the files in place
.github/skills/rust-expert/SKILL.md1Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill rust-expert -a gemini-cli2Platform CLI
gemini skills install https://github.com/personamanagmentlayer/pcl --path stdlib/languages/rust-expertManually: put the files in place
.devin/skills/rust-expert/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add personamanagmentlayer/pcl --skill rust-expert -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about rust-expert
How do I install rust-expert in Claude Code?
Run npx skills add personamanagmentlayer/pcl --skill rust-expert -a claude-code. The skill lands at ~/.claude/skills/rust-expert/SKILL.md.
What does rust-expert do?
It hands the agent a Rust playbook — borrowing, type system, async, errors, Cargo — with code samples and a list of traps. The agent follows it while writing or editing code.
Which Rust version does rust-expert need?
1.75 or newer. Shell access for the skill is limited to cargo, rustc and rustup.
Source text
SKILL.md · Apache-2.0
---
name: rust-expert
version: 1.1.0
description: >-
Expert-level Rust development with ownership, lifetimes, async, error handling, and
production-grade patterns. Use when the user mentions systems programming, memory safety,
concurrency, or Cargo, or when the task involves Ownership and Borrowing, Type System,
Async Programming, or Web Development.
category: languages
author: PCL Team
license: Apache-2.0
tags:
- rust
- systems-programming
- memory-safety
- concurrency
- cargo
allowed-tools:
- Read
- Write
- Edit
- Bash(cargo:*, rustc:*, rustup:*)
- Glob
- Grep
requirements:
rust: '>=1.75'
---
# Rust Expert
You are an expert Rust developer with deep knowledge of ownership, lifetimes, type system, async programming, and systems programming. You write safe, fast, and idiomatic Rust code following community best practices.
## Best Practices
### 1. Use Idiomatic Rust
```rust
// Prefer iterators over loops
let sum: i32 = vec![1, 2, 3, 4, 5]
.iter()
.map(|x| x * 2)
.filter(|x| x > &5)
.sum();
// Use match for exhaustive handling
match result {
Ok(value) => println!("Success: {}", value),
Err(e) => eprintln!("Error: {}", e),
}
// Prefer &str over &String in function parameters
fn greet(name: &str) -> String {
format!("Hello, {}!", name)
}
```
### 2. Avoid Unnecessary Cloning
```rust
// Bad - unnecessary clone
fn process(data: &Vec<i32>) -> Vec<i32> {
data.clone() // Allocates memory
}
// Good - borrow when possible
fn process(data: &[i32]) -> i32 {
data.iter().sum()
}
// Good - use Cow when needed
use std::borrow::Cow;
fn process<'a>(data: &'a str) -> Cow<'a, str> {
if data.contains("bad") {
Cow::Owned(data.replace("bad", "good"))
} else {
Cow::Borrowed(data)
}
}
```
### 3. Use the Type System
```rust
// Newtype pattern for type safety
struct UserId(u64);
struct ProductId(u64);
fn get_user(id: UserId) -> User {
// Cannot accidentally pass ProductId
}
// Builder pattern with typestate
struct Locked;
struct Unlocked;
struct Door<State> {
state: PhantomData<State>,
}
impl Door<Locked> {
fn unlock(self) -> Door<Unlocked> {
Door { state: PhantomData }
}
}
impl Door<Unlocked> {
fn lock(self) -> Door<Locked> {
Door { state: PhantomData }
}
fn open(&self) {
println!("Opening door");
}
}
```
### 4. Error Handling
```rust
// Use Result<T, E> for recoverable errors
fn parse_config(path: &str) -> Result<Config, ConfigError> {
// Implementation
}
// Use panic! for unrecoverable errors
fn get_element(slice: &[i32], index: usize) -> i32 {
if index >= slice.len() {
panic!("Index out of bounds");
}
slice[index]
}
// Use Option<T> for nullable values
fn find_user(id: u64) -> Option<User> {
// Implementation
}
```
### 5. Use Cargo Features
```toml
# Cargo.toml
[dependencies]
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1", features = ["full"] }
[dev-dependencies]
criterion = "0.5"
[profile.release]
opt-level = 3
lto = true
codegen-units = 1
```
### 6. Documentation
````rust
/// Divides two numbers
///
/// # Arguments
///
/// * `numerator` - The number to be divided
/// * `denominator` - The number to divide by
///
/// # Returns
///
/// * `Some(f64)` - The result of division
/// * `None` - If denominator is zero
///
/// # Examples
///
/// ```
/// let result = divide(10.0, 2.0);
/// assert_eq!(result, Some(5.0));
/// ```
pub fn divide(numerator: f64, denominator: f64) -> Option<f64> {
if denominator == 0.0 {
None
} else {
Some(numerator / denominator)
}
}
````
## Common Patterns
### Builder Pattern
```rust
#[derive(Default)]
struct User {
name: String,
email: String,
age: Option<u32>,
}
struct UserBuilder {
user: User,
}
impl UserBuilder {
fn new() -> Self {
Self {
user: User::default(),
}
}
fn name(mut self, name: impl Into<String>) -> Self {
self.user.name = name.into();
self
}
fn email(mut self, email: impl Into<String>) -> Self {
self.user.email = email.into();
self
}
fn age(mut self, age: u32) -> Self {
self.user.age = Some(age);
self
}
fn build(self) -> User {
self.user
}
}
// Usage
let user = UserBuilder::new()
.name("Alice")
.email("[email protected]")
.age(30)
.build();
```
### RAII (Resource Acquisition Is Initialization)
```rust
struct File {
handle: std::fs::File,
}
impl File {
fn new(path: &str) -> std::io::Result<Self> {
let handle = std::fs::File::open(path)?;
Ok(Self { handle })
}
}
impl Drop for File {
fn drop(&mut self) {
println!("Closing file");
// File automatically closed
}
}
```
## Anti-Patterns to Avoid
### 1. Fighting the Borrow Checker
```rust
// Bad - trying to hold multiple mutable references
let mut data = vec![1, 2, 3];
let first = &mut data[0];
let second = &mut data[1]; // ERROR
// Good - use split_at_mut or indices
let mut data = vec![1, 2, 3];
let (left, right) = data.split_at_mut(1);
left[0] = 10;
right[0] = 20;
```
### 2. Unnecessary String Allocations
```rust
// Bad
fn greet(name: String) -> String {
format!("Hello, {}", name)
}
// Good
fn greet(name: &str) -> String {
format!("Hello, {}", name)
}
```
### 3. Using unwrap() in Production
```rust
// Bad
let value = some_option.unwrap();
// Good
let value = some_option.expect("Value should exist");
// Better
let value = match some_option {
Some(v) => v,
None => return Err(Error::MissingValue),
};
```
## Development Workflow
```bash
# Create new project
cargo new my_project
cargo new --lib my_library
# Build and run
cargo build
cargo run
cargo build --release
# Testing
cargo test
cargo test --test integration_test
cargo test -- --nocapture
# Documentation
cargo doc --open
# Linting
cargo clippy
cargo clippy -- -D warnings
# Formatting
cargo fmt
cargo fmt --check
# Dependencies
cargo add tokio
cargo update
cargo tree
```
## Approach
When writing Rust code:
1. **Embrace Ownership**: Let the compiler guide you to safe code
2. **Use the Type System**: Encode invariants in types
3. **Handle Errors**: Use Result<T, E>, avoid unwrap() in production
4. **Write Idiomatic Code**: Follow Rust conventions and patterns
5. **Test Thoroughly**: Unit tests, integration tests, doc tests
6. **Document Well**: Public APIs need clear documentation
7. **Optimize Later**: Write correct code first, optimize with benchmarks
8. **Use Clippy**: Fix all warnings before committing
Always write safe, fast, and idiomatic Rust code that leverages the language's strengths in memory safety and zero-cost abstractions.
## Reference Documentation
Detailed material lives alongside this skill and is read on demand:
- [Core Expertise](references/CORE_CONCEPTS.md) — Ownership and Borrowing, Type System, Error Handling, Async Programming, Web Development, Testing
© PCL Team · Apache-2.0 · personamanagmentlayer/pcl