Skip to content

massimodeluisa/rust-best-practices-skill / skills/rust-best-practices

rust-best-practices

Verified

Write and review production Rust using the official API Guidelines, Style Guide, and this engineering standard: allocation contracts, ownership, Result vs panic, debug_assert, Clippy, tests, rustdoc, unsafe, and Cargo CI. Use when writing, reviewing, or refactoring Rust; choosing borrow vs clone; designing crate APIs; handling errors; bounding heap use; configuring clippy or rustfmt; or when the user runs /rust-best-practices. Do not use for other languages. Triggers: rust, rustc, cargo, clippy, rustfmt, ownership, clone, borrow, Result, unwrap, expect, panic, thiserror, anyhow, heapless, no_std, allocation, debug_assert, type-state, Send, Sync, unsafe, FFI, rustdoc, MSRV, rust-best-practices, rust style, rust guidelines

FileKindSize
SKILL.mdskill md6.0 KB
evals/evals.jsonconfig3.2 KB
references/allocation.mdmarkdown10.2 KB
references/design.mdmarkdown7.9 KB
references/errors.mdmarkdown6.8 KB
references/official.mdmarkdown8.1 KB
references/ownership.mdmarkdown3.9 KB
references/performance.mdmarkdown3.1 KB
references/quality.mdmarkdown10.9 KB
references/review.mdmarkdown4.4 KB
references/unsafe.mdmarkdown3.3 KB

evals/evals.json

View on GitHub
{
  "skill_name": "rust-best-practices",
  "source": "skill review and API scenarios",
  "evals": [
    {
      "id": 1,
      "prompt": "Review this library function: fn parse(input: String) -> Vec<Record>. The crate is a protocol runtime that must stay allocation-free after init.",
      "expected_output": "Flags owned String input and Vec return under an allocation-free profile. Recommends &[u8] (or similar) plus caller-owned output buffer returning Result<usize, typed error>. Documents # Allocation. Cites C-CALLER-CONTROL and does not treat C-NO-OUT as forbidding buffers on this profile. Mentions capacity exhaustion as a typed error.",
      "assertions": [
        "Rejects String and Vec as the runtime parse signature",
        "Proposes caller-owned output buffer or equivalent",
        "Names a typed capacity/output-too-small error",
        "Does not claim the API must return Vec to satisfy C-NO-OUT"
      ]
    },
    {
      "id": 2,
      "prompt": "This library does config.port.unwrap() when reading a config file. Is that OK?",
      "expected_output": "No. Production libraries must not unwrap recoverable failures. Return Result with a typed error. Config I/O is caller-controlled, not a programmer defect.",
      "assertions": [
        "Rejects unwrap on the library path",
        "Recommends Result and a typed error",
        "Does not suggest expect as the production fix"
      ]
    },
    {
      "id": 3,
      "prompt": "pub fn read_byte(input: &[u8], index: usize) -> u8 { debug_assert!(index < input.len()); input[index] } Ship it?",
      "expected_output": "No. debug_assert is not caller validation and disappears in release. Use get plus a typed error in all builds; debug_assert may follow the established invariant. Must not use debug_assert as an unsafe get_unchecked precondition.",
      "assertions": [
        "Flags debug_assert as the only bounds check",
        "Requires a Result (or equivalent) for caller-controlled index",
        "Does not approve the function as written"
      ]
    },
    {
      "id": 4,
      "prompt": "Should this 32-byte Copy struct be passed by value? Give me the byte cutoff from the skill.",
      "expected_output": "Pass small Copy values by value when that is clearer. Do not apply a universal byte cutoff. Measure ABI and target if size is in question. Never invent a 24-byte or 2-3-word rule.",
      "assertions": [
        "Does not state a universal byte threshold as policy",
        "Says to measure ABI/target when unsure",
        "Still allows passing small Copy by value"
      ]
    },
    {
      "id": 5,
      "prompt": "Add a CI baseline for a workspace library crate and point me at the official style and API docs.",
      "expected_output": "cargo fmt --all -- --check; cargo clippy --workspace --all-targets --all-features --locked -- -D warnings; cargo test including doc and release-assertions profile. Links Style Guide and API Guidelines checklist. Prefer expect over allow for Clippy. overflow-checks on release.",
      "assertions": [
        "Includes cargo fmt --check",
        "Includes clippy -D warnings",
        "Links rust-lang.github.io/api-guidelines or the Style Guide",
        "Mentions release-assertions or debug-assertions on an optimized test profile"
      ]
    }
  ]
}
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall