Claude Cursor Skill

writing-rust

Imported from alexei-led/cc-thingz/dist/pi/skills/writing-rust.

LLM Mart · 0 points · 0 views 0 listing impressions 0 install-command copies
Virus-scanned Reviewed automatically before listing.

Full trust report

Download alexei-led-cc-thingz-dist_pi_skills_writing-rust-ce56bb4.zip · 3 KB
Part of alexei-led/cc-thingz — 91 skills

Install

skills CLI npx skills add https://github.com/alexei-led/cc-thingz/tree/master/dist/pi/skills/writing-rust
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install alexei-led-cc-thingz@llmmart
Git git clone https://github.com/alexei-led/cc-thingz.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole alexei-led/cc-thingz collection as a plugin from our marketplace. Git is the plain clone.

Skill manifest

Rust Development

Covers crates, workspaces, and Rust CLIs. Check Cargo.toml, rust-toolchain.toml, and CI before using newer syntax or APIs. Project conventions win over these defaults.

Version and Features

  • Stay within package.rust-version (MSRV) and the pinned toolchain unless the task is an upgrade.
  • Use Edition 2024 syntax only when the crate sets edition = "2024".
  • Keep features additive. Do not assume --all-features compiles when the crate documents mutually exclusive features.

Defaults

  • Stdlib and existing crates first. thiserror for library error enums and anyhow for application glue only when the crate already uses them or boilerplate justifies it.
  • Newtypes for IDs, tokens, and validated values; enums for states. Private first, then pub(crate), then pub.
  • Implement From, TryFrom, AsRef, FromStr, and Display before ad hoc conversion methods.
  • Parsing and validation return Result with a typed error. unwrap/expect in production code only with a named local invariant.
  • When the borrow checker objects, fix the data flow before reaching for clone(). Use lifetimes in APIs only for real zero-copy needs.
  • Async only where the runtime or I/O boundary requires it. Never hold a blocking mutex guard across .await. Bound channels, queues, and retries.
  • Keep secrets out of Debug output, logs, errors, and snapshots.
  • unsafe: small blocks behind a safe API, a // SAFETY: comment stating the invariant, and focused tests or configured Miri.

Checks

Use the project's configured Cargo commands first. While editing, run focused checks (cargo check -p <crate>, cargo test -p <crate> <name>); before finishing, run the full gates:

cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test --all-targets   # or cargo nextest run, when the project uses nextest
cargo test --doc           # --all-targets and nextest both skip doctests

Test behavior through the public API with valid, invalid, and boundary cases, not private helpers. Never run cargo clean as a routine fix; it throws away the incremental cache.

References

  • testing.md: read when adding or reshaping tests, or when the test loop is slow.
  • linting.md: read when changing rustfmt, Clippy, or workspace/feature check flags.

Done when the relevant build/test/lint checks pass on what you changed, or you name each check that did not run and why.

Files (cc-thingz)
  • references
    • linting.md 971 B
      # Rust Linting
      
      Use the project's commands first. Edit loop, scoped to one package:
      
      ```bash
      cargo check -p crate_name --all-targets
      cargo clippy -p crate_name --all-targets -- -D warnings
      cargo fmt --check
      ```
      
      - In a single-file edit hook, `rustfmt --edition <edition> path.rs` is fine; the final check is `cargo fmt --check` so Cargo applies crate settings.
      - Fix Clippy warnings instead of adding `#[allow(...)]`. A needed allow stays narrow and states the invariant or false positive.
      - Run `cargo clippy --fix --allow-dirty --allow-staged` only on a scoped package, after reviewing what it may change.
      - Read `[workspace]`, `default-members`, features, and CI flags before choosing `--workspace`, `--all-targets`, or `--all-features`. Do not change default features to pass a check.
      - Do not lower lint levels, remove `deny`, or add broad allows to get green.
      - Install missing components (`rustup component add rustfmt clippy`) only when the user asked for setup.
      
    • testing.md 1.3 KB
      # Rust Testing
      
      ## Layout
      
      - Unit tests in `#[cfg(test)] mod tests` next to the code; public-API and CLI tests in `tests/*.rs`; fixtures in `tests/fixtures/` or `testdata/`.
      - Public doc examples are doctests; keep them compiling.
      - Stdlib assertions (`assert!`, `assert_eq!`, `matches!`) by default. Compare structured values, not formatted strings.
      - Add `mockall`, `assert_cmd`, `tempfile`, `insta`, `proptest`, or `wiremock` only when the project already uses them or the benefit is concrete. Normalize volatile values before snapshotting.
      
      ## Fast Loop
      
      ```bash
      cargo test -p crate_name test_name
      cargo test --manifest-path path/to/Cargo.toml test_name
      cargo nextest run -p crate_name        # only when the project uses nextest
      cargo test --doc                        # --all-targets and nextest skip doctests
      ```
      
      - Keep full-workspace runs, coverage (`cargo llvm-cov`, tarpaulin), Miri, and benchmarks off the hot path unless they are the task.
      - Use `-- --nocapture` only while debugging output.
      
      ## Async and Concurrency
      
      - Use the runtime's test macro (`#[tokio::test]`) only when the code under test is async.
      - Replace sleeps with channels, barriers, paused or fake clocks, or timeout-bounded awaits.
      - Use `loom`, Miri, or sanitizers when configured, or when `unsafe` or lock-free code warrants them.
      
  • SKILL.md 3.1 KB
    ---
    {"description":"Idiomatic Rust development. Use when writing Rust code, Cargo crates/workspaces, Rust tests, or rustfmt/clippy/cargo workflows. Emphasizes ownership, Result errors, small APIs, stdlib-first dependencies, fast cargo feedback, and behavior tests. NOT for Go, Python, TypeScript, shell scripts, or infra-only work.","name":"writing-rust"}
    ---
    <!-- Pi platform guidance -->
    <!-- Use installed Pi tool names exactly, including extension toolsets such as Task*, Monitor*, and Loop*. -->
    <!-- When available, track work with Task* (`todo` is the fallback), run long or background commands with MonitorCreate, and schedule follow-up with LoopCreate instead of sleep/poll loops. -->
    
    
    # Rust Development
    
    Covers crates, workspaces, and Rust CLIs. Check `Cargo.toml`, `rust-toolchain.toml`, and CI before using newer syntax or APIs. Project conventions win over these defaults.
    
    ## Version and Features
    
    - Stay within `package.rust-version` (MSRV) and the pinned toolchain unless the task is an upgrade.
    - Use Edition 2024 syntax only when the crate sets `edition = "2024"`.
    - Keep features additive. Do not assume `--all-features` compiles when the crate documents mutually exclusive features.
    
    ## Defaults
    
    - Stdlib and existing crates first. `thiserror` for library error enums and `anyhow` for application glue only when the crate already uses them or boilerplate justifies it.
    - Newtypes for IDs, tokens, and validated values; enums for states. Private first, then `pub(crate)`, then `pub`.
    - Implement `From`, `TryFrom`, `AsRef`, `FromStr`, and `Display` before ad hoc conversion methods.
    - Parsing and validation return `Result` with a typed error. `unwrap`/`expect` in production code only with a named local invariant.
    - When the borrow checker objects, fix the data flow before reaching for `clone()`. Use lifetimes in APIs only for real zero-copy needs.
    - Async only where the runtime or I/O boundary requires it. Never hold a blocking mutex guard across `.await`. Bound channels, queues, and retries.
    - Keep secrets out of `Debug` output, logs, errors, and snapshots.
    - `unsafe`: small blocks behind a safe API, a `// SAFETY:` comment stating the invariant, and focused tests or configured Miri.
    
    ## Checks
    
    Use the project's configured Cargo commands first. While editing, run focused checks (`cargo check -p <crate>`, `cargo test -p <crate> <name>`); before finishing, run the full gates:
    
    ```bash
    cargo fmt --check
    cargo clippy --all-targets -- -D warnings
    cargo test --all-targets   # or cargo nextest run, when the project uses nextest
    cargo test --doc           # --all-targets and nextest both skip doctests
    ```
    
    Test behavior through the public API with valid, invalid, and boundary cases, not private helpers. Never run `cargo clean` as a routine fix; it throws away the incremental cache.
    
    ## References
    
    - [testing.md](references/testing.md): read when adding or reshaping tests, or when the test loop is slow.
    - [linting.md](references/linting.md): read when changing rustfmt, Clippy, or workspace/feature check flags.
    
    Done when the relevant build/test/lint checks pass on what you changed, or you name each check that did not run and why.
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.

Related