/rust:rustfrom rust
Writes, reviews and debugs Rust: ownership and lifetimes, Result and error types, traits and modules, Cargo workspaces and features, async and tokio tasks, unsafe, measured performance. Use for *.rs or Cargo.toml work, borrow-checker fights, error-type design, clippy failures or unsafe review.
Ships in rust. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Not for generic test strategy (unit-testing).
Preserve observable behavior, error behavior, feature combinations, cancellation boundaries, and safety invariants unless the request changes them.
Cargo.toml and the workspace root. Note members, features, profiles, [lints], rust-version (MSRV), rust-toolchain.toml, and whether Cargo.lock is committed.search_graph for symbols, trace_path for callers and callees, get_code_snippet for source). Otherwise use the LSP tool (rust-analyzer) or Grep for references, implementations, and inferred types.resolve-library-id, then query-docs) or docs.rs for that exact version. Don't use features newer than the MSRV.edition in Cargo.toml. Edition 2024 (Rust 1.85+) warns on unsafe_op_in_unsafe_fn, so unsafe calls inside an unsafe fn need their own unsafe {} block. It also requires unsafe extern blocks and makes std::env::set_var/remove_var unsafe. Let chains (if let ... && ...) work only on 2024 (stable since 1.88). Migrate with cargo fix --edition, then change the field.pub(crate) for crate-internal sharing.Send/Sync bounds, object safety, and feature gating on purpose. Don't make downstream crates implement a public trait unless that extension point is the contract.Cow, or deciding where #[must_use] belongs.&T/&str/&[T] when the callee only reads. Take owned values when it stores, consumes, or moves them across threads or tasks..clone(), 'static, Box::leak, Rc<RefCell<_>>, or Arc<Mutex<_>> just to silence the borrow checker. First restructure control flow or shorten the borrow. If shared ownership is truly needed, say why.Result for expected failures. Reserve panic!, unwrap, and expect for programmer invariants and tests, and write expect("why this can't fail") when you do use them.thiserror) with variants callers can act on and a source() chain.anyhow/eyre, adding .context("doing X") at the layer that knows the operation.?. Never discard an error (let _ = fallible()) or stringify away its source chain.JoinHandle or use a JoinSet), capacity or backpressure, and shutdown..await.std::sync::Mutex guard across .await. Avoid holding a tokio::sync::Mutex across one unless the wait is demonstrably safe. Prefer copying data out, narrowing the critical section, or message passing.spawn_blocking or the runtime's equivalent. Propagate task panics and errors instead of detaching them.unsafe, name the safe alternative and why it can't meet the contract or a measured constraint.// SAFETY: comment on every block naming the invariants that make it sound. These can include validity, initialization, bounds, alignment, aliasing, drop, layout, and Send/Sync.cargo +nightly miri test on the affected tests when the toolchain has Miri, and report when it doesn't.cargo bench, or a profiler (perf, cargo flamegraph, samply). Always build in --release.unsafe.#[cfg(test)] mod tests and public-API tests in tests/.cargo test --features <f>. Don't build an automatic feature matrix.Use the repo's documented commands (Makefile, justfile, cargo xtask, CI) when present. Otherwise run from the relevant package or workspace root.
cargo fmt --check
cargo check --all-targets
cargo clippy --all-targets -- -D warnings # add --all-features if the repo's CI does
cargo test # -p <crate> to narrow; --doc when doctests are contract
Triage failures as a code defect, test expectation, feature/config issue, toolchain problem, or missing prerequisite. Don't #[allow] a lint or disable a feature just to get green output. When a lint must be silenced, prefer #[expect(lint, reason = "...")] (stable since 1.81): it warns with unfulfilled_lint_expectations once the lint stops firing, so the suppression doesn't go stale.
| Situation | Default | Escalate when |
|---|---|---|
| Borrow conflict | Clarify ownership; shorten the borrow or restructure | Independent ownership or measured constraints justify a clone or shared ownership |
| Public error | Typed, source-preserving enum | A boundary intentionally maps internals to a user, wire, or domain error |
| New abstraction | Concrete type or function | Multiple current impls or a consumer-owned seam need a trait |
| Shared mutable state | Ownership transfer or narrow sync | Lock ordering, contention, and .await interactions are explicit |
unsafe | Reject for safe Rust | A required capability can't be met safely and invariants are locally enforced |
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub adminhead/claude-plugins --plugin rust