From Rust Expert
Expert Rust: ownership, borrowing, lifetimes, traits, async, and idiomatic error handling. Trigger keywords: Rust, ownership, borrow checker, lifetime, move, clone, trait, generics, async, tokio, Result, Option, ?, thiserror, anyhow, unsafe, Arc, Mutex, cargo, Send, Sync. Use for writing/refactoring Rust, resolving borrow-checker/lifetime errors, or designing safe abstractions.
How this skill is triggered — by the user, by Claude, or both
Slash command
/rust-expert:rust-expertThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Fight the design, not the borrow checker — a borrow error is usually a real aliasing/lifetime problem. Make invalid states unrepresentable, return errors as values, and reach for `clone()`/`unsafe` deliberately, never to silence the compiler.
Fight the design, not the borrow checker — a borrow error is usually a real aliasing/lifetime problem. Make invalid states unrepresentable, return errors as values, and reach for
clone()/unsafedeliberately, never to silence the compiler.
clone, or Send/Sync errors.unsafe.software-architect.&T/&mut T) over cloning; clone() is a real cost you choose, not an error silencer.&T xor one &mut T. When it fights you, restructure: narrow scopes, split borrows, index-based access, or interior mutability (Cell/RefCell single-thread, Mutex/RwLock multi-thread).&str/&[T]/impl AsRef<_>; store owned String/Vec<T>. Return owned data or borrow tied to an input lifetime.Result<T, E>; propagate with ?. Avoid unwrap()/expect() outside tests, main, or provably-infallible spots (and then expect() with a reason).thiserror (impl std::error::Error, use #[from]). Apps: anyhow::Result with .context("…").Option for absence, Result for failure. Don't panic on recoverable conditions.dyn Trait (boxed) for heterogeneous collections, plugin points, or smaller code size. Derive Debug/Clone/PartialEq where sensible; impl From for conversions so ? composes.tokio). Never block the executor — use async I/O; offload CPU/blocking work to spawn_blocking or a thread pool.Arc<Mutex<T>>/Arc<RwLock<T>>; hold locks for the shortest possible scope and never across .await. Move ownership across tasks via channels.unsafe is a contractunsafe blocks minimal. Run Miri/sanitizers..clone() / .to_owned() spam to dodge borrow errors → restructure ownership instead..unwrap() in library/production code → propagate with ? or handle.Rc/Arc.MutexGuard across .await → deadlocks/!Send futures; drop the guard first.Vec<Box<dyn Trait>> when generics suffice → unnecessary dynamic dispatch.Idiomatic library error type
use thiserror::Error;
#[derive(Error, Debug)]
pub enum ConfigError {
#[error("missing field: {0}")]
Missing(String),
#[error(transparent)]
Io(#[from] std::io::Error), // `?` converts io::Error automatically
}
pub fn load(path: &str) -> Result<String, ConfigError> {
let text = std::fs::read_to_string(path)?;
if text.trim().is_empty() {
return Err(ConfigError::Missing("body".into()));
}
Ok(text)
}
Make invalid states unrepresentable
enum Connection {
Disconnected,
Connecting { attempt: u8 },
Connected { session: String }, // a session ONLY exists when connected
}
performance-expert — profiling, allocation reduction, flamegraphs.testing-expert — #[test], integration tests, proptest.cpp-expert — comparing systems-language trade-offs.go-expert — different concurrency model for the same problem space.Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub miaoge-ge/coding-agent-skills --plugin rust-expert