mcpField
R
rust

rust

github.com/xgent-aiDevelopment1137 installsUpdated 1d ago
Repository

About rust

A skill for applying Rust best practices when writing, reviewing, refactoring, testing, or debugging code. It directs work toward project-specific conventions, deliberate API contracts, and verification suited to the change.

Key features

  1. 01Guidance for ownership and error handling
  2. 02Task-specific reference topics
  3. 03Advice for async and unsafe Rust
  4. 04Testing and documentation practices
  5. 05Project-aware verification checks

Use cases

  1. 01Review Rust changes against project conventions
  2. 02Refactor code while preserving behavior
  3. 03Plan tests for errors and boundaries

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/xgent-ai/skills --skill rust

After installing, type/rustin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
api-design.md
async-tokio.md
behavioral-patterns.md
bevy.md
clippy-and-linting.md
coding-idioms.md
crates-and-dependencies.md
documentation.md
error-handling.md
generics-and-dispatch.md
macros.md
performance.md
pointers-and-ownership.md
testing.md
type-state.md
unsafe-and-ffi.md

Details

From the project README

Rust Best Practices

Apply these guidelines when writing, reviewing, refactoring, testing or debugging Rust code.

Working Approach

  • Read the affected code, tests, Cargo.toml, toolchain pin and CI commands first. Respect the project's edition, MSRV, feature combinations and conventions.
  • If the affected crate uses Bevy, read Bevy practices before applying generic borrowing, import or lint advice to system functions.
  • Keep application code direct: concrete types, simple control flow and no speculative traits or builders. Libraries with external callers need deliberate public contracts.
  • Model the domain with Rust's ownership, enums, traits and Result; do not translate inheritance or exception patterns mechanically from another language.
  • During refactoring, preserve public signatures, error variants, output ordering and behavior unless changing them is in scope. Explain necessary contract changes; do not rename getters or replace existing parameters merely to satisfy a style preference.
  • Read-only reviews produce findings, not edits. Stay within the requested change; installing tools, upgrading dependencies or publishing is not implied by this skill.

References by Task

Read the relevant references before making decisions. Each topic owns its detailed rules and examples; follow cross-links only when the task crosses that boundary.

TaskReference
Borrow-checker friction, iterators, imports or function extractionCoding idioms
Clippy warnings, suppressions or workspace lint configurationClippy and linting
Profiling, allocations, cloning or hot pathsPerformance
Fallible operations, library error types or resource cleanupError handling
Regression, property, integration or snapshot tests; controllable I/OTesting
Closure bounds, trait contracts, static dispatch or trait objectsGenerics and dispatch
Compile-time state transitionsType state
Comments, public docs or executable examplesDocumentation
Lifetimes, smart pointers, interior mutability or shared ownershipPointers and ownership
Tokio tasks, channels, cancellation or async shared stateAsync with Tokio
Public types, constructors, standard traits or API evolutionAPI design
Unsafe blocks, raw pointers, native handles or foreign interfacesUnsafe and FFI
Cargo manifests, dependencies, features, MSRV or no_stdCrates and dependencies
Declarative/procedural macros, generated APIs or expansion diagnosticsMacros
Queued actions, configurable algorithms, AST traversal or tree transformationBehavioral patterns
Bevy systems, queries, scheduling, deferred changes or ECS testsBevy

Core Rules

  • Make ownership intentional: borrow to read, move to consume, and share only when the design needs multiple owners. Resolve borrow scopes before adding deep copies.
  • Use types to express domain invariants and keep public contracts deliberate. Prefer concrete code; introduce traits, builders, macros or type states for an actual need.
  • Return Result for fallible operations and Option for normal absence. Never use unwrap()/expect() outside tests. Use thiserror for library errors and anyhow for binaries; preserve causes and add useful context. Do not use panics or catch_unwind as ordinary error handling. Keep Drop non-panicking.
  • Measure performance in release builds before changing ownership, allocation, dispatch or synchronization. Keep loops when they express control flow more clearly.
  • Keep blocking I/O and heavy CPU work off async workers. End synchronous lock guards before .await; choose async synchronization only when the operation requires it. Bound concurrency, handle cancellation and give outbound calls timeouts.
  • Keep unsafe code behind a small sound boundary, document each unsafe operation's invariants, and document caller obligations in # Safety for every unsafe fn.
  • Keep formatting and lint policy compatible with the project and MSRV. Use narrow, justified suppressions; enforce warnings-as-errors through CI rather than blanket #![deny(warnings)] in source.
  • Test observable behavior, including failures and boundaries. Reproduce bugs before fixing them; use unit, integration and doc tests for their respective contracts.
  • Use // for rationale and //////! for API usage and contracts. Link TODOs to issues, document errors/panics/safety where relevant, and enforce library documentation with #![deny(missing_docs)]. Keep fallible doc examples executable with ?.

Verification Before Handoff

Use the project's commands and supported feature/target matrix. For code changes, run format checks, Clippy and relevant tests; include doc tests and cargo doc --no-deps for public API/doc changes. Check new syntax and dependencies against the MSRV. Unsafe, FFI or performance changes also need applicable Miri, platform tests or release benchmarks. Report what actually ran and any limitations; do not claim unrun checks passed.

Comments

Markdown supported