rust-standards
Use when writing, reviewing, testing, formatting, or configuring any Rust code (.rs files, Cargo.toml) in a touchstone repo — rustup-pinned toolchain, rustfmt, clippy -D warnings, cargo test/nextest, thiserror/anyhow, tokio. Invoke before adding deps, touching unsafe, editing tests, or changing release/build settings. Not for cross-cutting supply-chain (security-standards) or pipeline (ci-cd-standards) concerns.
- License 许可
- MIT
- 最近更新
- 2026-08-26
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- rust-standards
- license
- MIT
- metadata
- { "author": "touchstone", "version": "0.2.0" }
- description
- Use when writing, reviewing, testing, formatting, or configuring any Rust code (.rs files, Cargo.toml) in a touchstone repo — rustup-pinned toolchain, rustfmt, clippy -D warnings, cargo test/nextest, thiserror/anyhow, tokio. Invoke before adding deps, touching unsafe, editing tests, or changing release/build settings. Not for cross-cutting supply-chain (security-standards) or pipeline (ci-cd-standards) concerns.
03 SKILL.md 正文
Rust Standards
Full standard: standards/languages/rust.md in the touchstone repo. This skill inlines the
load-bearing rules so it stays useful even when installed standalone in ~/.claude/skills/:
Always
- Pin the toolchain in
rust-toolchain.toml(exact stable channel + rustfmt/clippy); edition 2024; declare MSRV viarust-version. - Format with rustfmt (
cargo fmt --all -- --check); lint with clippy-D warnings— configure levels in the[lints]table, not just the CI flag. - Test with
cargo nextest run+cargo test --doc(nextest skips doctests); property tests via proptest, snapshots via insta. - Commit
Cargo.lock(libs too); CI builds--locked. Gate deps withcargo deny check+cargo audit.
Don't get burned
- Errors:
thiserrorfor libraries (typed,#[non_exhaustive]),anyhowonly at the app/mainboundary. Nounwrap()/expect()on library happy paths; propagate with?+ context. - Unsafe:
unsafe_code = "forbid"by default; downgrade to"deny"only in the crate that needs it, every block gets a// SAFETY:comment, and runcargo miri test. - Async (tokio): never block the executor (offload CPU/blocking I/O via
spawn_blocking, neverthread::sleepor sync I/O inasync fn); bound external awaits withtokio::time::timeout; own everyJoinHandle; don't hold astd::sync::Mutexacross.await. - Workspace: share versions via
[workspace.dependencies]; splitlibfrombin;default-features = falseand add features back explicitly. - Release profile:
strip,lto,codegen-units = 1,panic = "abort"(binaries only) — neverpanic=aborton a published lib. - Perf: never optimize without a criterion benchmark + a samply/flamegraph profile; kill needless
.clone(). - Changing deterministic output ⇒ re-accept the
instasnapshot + explain.
Done
cargo fmt --all -- --check clean · cargo clippy --all-targets --all-features -- -D warnings clean · cargo test --all-features + cargo nextest run green (incl. doctests) · cargo build --locked passes, Cargo.lock committed, MSRV tested · cargo deny check + cargo audit clean. See standards/languages/rust.md.
04 同仓库更多 Skills
ok-standards
Use when writing shell, per standards/languages/shell.md.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.
demo-standards
Use when editing demo code in a touchstone fixture repo, a deliberately ordinary description that is long enough to clear the forty character minimum.