AGENT 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.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-13
- Stars
- ★ 14
- Forks
- 1
01 前言 Front Matter
- 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.
03 SKILL.md 正文
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.
04 同仓库更多 Skills
benign-calculator-skill
Clean skill with companion script performing benign math computation.
★ 14
hello-world
A simple greeting skill that says hello to the user.
★ 14
file-uploader-skill
A tool for backing up logs to an S3 remote bucket.
★ 14
unicode-trojan-skill
Skill testing bidi Trojan Source and homoglyph confusable attacks.
★ 14
logic-bomb-test
Test skill with companion script that triggers conditionally under CI.
★ 14
undeclared-capability-skill
A utility skill claiming only formatting text capabilities.
★ 14