Claude
Skill
rust-idioms
Everyday Rust engineering for Skill Doctor — errors, ownership, clippy, APIs, iterators. Use when writing or reviewing Rust that is not specifically about perf, unsafe, or YARA.
Virus-scanned
Reviewed automatically before listing.
Download
kalarislabs-skill-doctor-skills_rust-idioms-72aa35f.zip · 0 KB
Install
skills CLI
npx skills add https://github.com/KalarisLabs/Skill-Doctor/tree/main/skills/rust-idioms
Claude Code
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install kalarislabs-skill-doctor@llmmart
Git
git clone https://github.com/KalarisLabs/Skill-Doctor.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole kalarislabs/skill-doctor collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
Rust idioms
Errors
- Libraries:
thiserrorenums. Nounwrap/expecton recoverable paths. - Binary:
anyhowatmainonly. Map to exit codes in one place. - Do not
panicin L1 because a skill file is malformed. Malformed input is a finding or a skipped file with coverage reduced.
Ownership
- Hot path: borrow (
&[u8],&str,&Path). Own only when storing in aFinding. - Do not
clone()to satisfy the borrow checker if a lifetime orArcwould do. Clippyclone_on_copy/ needless clones must stay clean. PathBufwalks: collect sortedVec<PathBuf>once, then iterate. Do notread_dirtwice.
APIs
- Public core API is small:
scan_bundle(&[u8] | &Path) -> Result<Report>. - Rule IDs and SD class IDs are
&'static stror newtypes, not free-formStringinvented at runtime. - Prefer
enum Severity { Low, Medium, High, Critical }over strings.
Clippy / fmt
cargo fmt --allis not optional.clippy --all-targets -- -D warningsis the style guide. Do not fight clippy with#[allow]unless the allow cites an invariant.unsafeis not an idiom. Loadunsafe-sandboxinstead.
Concurrency
- L1 fan-out:
rayon. Notokioin core. - MCP / optional L4:
tokio. - Shared state:
std::sync/arc_swap/OnceLock. Do not add a new runtime.
Files (skill-doctor)
-
SKILL.md 1.5 KB
--- name: rust-idioms description: Everyday Rust engineering for Skill Doctor — errors, ownership, clippy, APIs, iterators. Use when writing or reviewing Rust that is not specifically about perf, unsafe, or YARA. --- # Rust idioms ## Errors - Libraries: `thiserror` enums. No `unwrap` / `expect` on recoverable paths. - Binary: `anyhow` at `main` only. Map to exit codes in one place. - Do not `panic` in L1 because a skill file is malformed. Malformed input is a finding or a skipped file with coverage reduced. ## Ownership - Hot path: borrow (`&[u8]`, `&str`, `&Path`). Own only when storing in a `Finding`. - Do not `clone()` to satisfy the borrow checker if a lifetime or `Arc` would do. Clippy `clone_on_copy` / needless clones must stay clean. - `PathBuf` walks: collect sorted `Vec<PathBuf>` once, then iterate. Do not `read_dir` twice. ## APIs - Public core API is small: `scan_bundle(&[u8] | &Path) -> Result<Report>`. - Rule IDs and SD class IDs are `&'static str` or newtypes, not free-form `String` invented at runtime. - Prefer `enum Severity { Low, Medium, High, Critical }` over strings. ## Clippy / fmt - `cargo fmt --all` is not optional. - `clippy --all-targets -- -D warnings` is the style guide. Do not fight clippy with `#[allow]` unless the allow cites an invariant. - `unsafe` is not an idiom. Load `unsafe-sandbox` instead. ## Concurrency - L1 fan-out: `rayon`. No `tokio` in core. - MCP / optional L4: `tokio`. - Shared state: `std::sync` / `arc_swap` / `OnceLock`. Do not add a new runtime.
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.