$npx -y skills add alexei-led/cc-thingz --skill writing-rustUse only for Rust crates and Cargo workspaces. Follow the crate's edition, MSRV, toolchain file, CI, and local style. Rust CLI development (clap, argument parsing, subcommands) is in scope; apply patterns.md and testing.md — there is no dedicated CLI reference.
| 1 | # Rust Development |
| 2 | |
| 3 | Use only for Rust crates and Cargo workspaces. Follow the crate's edition, MSRV, |
| 4 | toolchain file, CI, and local style. Rust CLI development (clap, argument |
| 5 | parsing, subcommands) is in scope; apply `patterns.md` and `testing.md` — there |
| 6 | is no dedicated CLI reference. |
| 7 | |
| 8 | ## Read First |
| 9 | |
| 10 | Read [principles.md](references/principles.md) before writing, changing, or reviewing Rust code. Read conditional references only when the change touches that area. |
| 11 | |
| 12 | ## Conditional References |
| 13 | |
| 14 | - [patterns.md](references/patterns.md) — crate layout, modules, ownership, traits, errors, async, unsafe, and public APIs. |
| 15 | - [testing.md](references/testing.md) — adding or reshaping Rust tests; keep the local test loop fast. |
| 16 | - [linting.md](references/linting.md) — changing rustfmt, Clippy, cargo check, CI gates, or slow lint workflows. |
| 17 | |
| 18 | ## Comments and Rustdoc |
| 19 | |
| 20 | - Use `///` or `//!` rustdoc for public APIs when users need contracts, edge cases, examples, or safety notes. |
| 21 | - Add implementation comments only for non-obvious constraints, invariants, side effects, tradeoffs, or unsafe assumptions. |
| 22 | - Keep comments short. Move longer rationale to docs, issue links, or design notes. |
| 23 | - Do not comment obvious code or restate names and types. |
| 24 | - Keep tests readable without comments; add one only for unobvious fixtures, timing, concurrency, unsafe invariants, or regression context. |
| 25 | - Document safety invariants next to `unsafe` blocks. |
| 26 | |
| 27 | ## Edition and MSRV |
| 28 | |
| 29 | - Inspect `Cargo.toml`, `Cargo.lock`, `rust-toolchain.toml`, CI, and nearby code before using edition- or version-specific APIs. |
| 30 | - Do not use APIs newer than `package.rust-version` or the pinned toolchain unless the task is an upgrade. |
| 31 | - Use Edition 2024 syntax only when the crate already opts into `edition = "2024"`. |
| 32 | - Respect feature flags. Do not enable `--all-features` assumptions in code unless incompatible feature combinations are ruled out. |
| 33 | |
| 34 | ## Verification |
| 35 | |
| 36 | Run focused Cargo checks while editing, then the project-configured build, tests, |
| 37 | format, and lint before final output. Prefer: |
| 38 | |
| 39 | ```bash |
| 40 | cargo fmt --check |
| 41 | cargo clippy --all-targets -- -D warnings |
| 42 | cargo test --all-targets |
| 43 | ``` |
| 44 | |
| 45 | Use `cargo nextest run` when the project already uses nextest. Run `cargo test --doc` separately when doctests matter because nextest does not run doctests. |
| 46 | |
| 47 | If a check is unavailable, state that and run the closest configured gate. If a check fails, quote the failure, diagnose the cause, fix one issue, and rerun the relevant check. |
| 48 | |
| 49 | ## Failure Cases |
| 50 | |
| 51 | - No clear Rust root: locate `Cargo.toml` before choosing files, package names, or commands. |
| 52 | - Unknown MSRV or edition: inspect manifests, toolchain files, CI, and lockfiles before using newer syntax or APIs. |
| 53 | - New crate requested: confirm stdlib or existing crates cannot meet the requirement. |
| 54 | - `unsafe` needed: isolate it, document the safety invariant, and add focused tests or run configured Miri checks. |
| 55 | - Broad or risky edit: state the risk and ask before acting. Do not run destructive commands. |
| 56 | |
| 57 | ## Final Response |
| 58 | |
| 59 | Include: |
| 60 | |
| 61 | - changed files |
| 62 | - checks run and results |
| 63 | - checks skipped with reasons |
| 64 | - remaining risks or follow-ups |