ds-rust-review
Skill20 starsChanged 46 days agoMITView on GitHub
Review Rust code for safety metrics, error handling, and idiomatic Rust.
In this repository52 other files it gives its agents.
- ds-dev-skill-benchSkill
- ds-agent-reviewSkill
- ds-architecture-planSkill
- ds-arenaSkill
- ds-blast-radiusSkill
- ds-blueprintSkill
- ds-bug-reviewSkill
- ds-clarity-reviewSkill
- ds-code-quality-reviewSkill
- ds-comment-reviewSkill
- ds-data-modeSkill
- ds-data-reviewSkill
- ds-debugSkill
- ds-deslopSkill
- ds-doc-quality-reviewSkill
- ds-exploreSkill
- ds-git-modeSkill
- ds-go-reviewSkill
- ds-grill-meSkill
- ds-handoffSkill
- ds-howSkill
- ds-humanizeSkill
- ds-interaction-modeSkill
- ds-java-reviewSkill
- ds-notebook-reviewSkill
- ds-onboardingSkill
- ds-osvSkill
- ds-perf-planSkill
- ds-project-checkpointSkill
- ds-project-resumeSkill
- ds-python-reviewSkill
- ds-quality-gateSkill
- ds-reflectSkill
- ds-retroSkill
- ds-roadmapSkill
- ds-security-reviewSkill
- ds-semgrepSkill
- ds-shell-reviewSkill
- dsSkill
- ds-specSkill
- ds-step-modeSkill
- ds-tdd-modeSkill
- ds-test-modeSkill
- ds-test-quality-reviewSkill
- ds-tiger-style-modeSkill
- ds-tldtSkill
- ds-ts-reviewSkill
- ds-ui-modeSkill
- ds-ui-quality-reviewSkill
- ds-verify-thisSkill
- ds-zig-reviewSkill
- ds-zoom-outSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 48
Run these commands, report counts, then do manual review below.
- Very specific: line 68
Use the checklist as a lens, not a scorecard: reason about the actual change, report real violations anchored to file:line, and flag issues …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Applies to: Rust stable, edition 2024. Systems programming, CLI tools, services.
Arguments
Scan the invocation for the --no-tiger, --fix, and --full flags. Treat every other argument as review scope (files or directories); if no scope is given, review the changed files on the current branch.
--no-tigerpresent → skip the Tiger Style section; run the remaining sections only.--no-tigerabsent → run all sections (default).--fix→ after reporting, apply only the violations whose fix is mechanical and unambiguous (a rename to the idiom, a missing error check the review is certain about). Anything that changes logic or rests on an unverified assumption — especially security and correctness findings — stays report-only. After applying, re-run any build/test/lint check already in the loop and revert any fix that breaks it — or that touched more than the intended mechanical edit. End with a summary of what was applied and what was left.--full→ review the entire codebase instead of just the branch's changes. Explicit positional scope still wins;--fullonly replaces the no-scope default.
The whole-crate metric commands below are baseline context. Anchor findings to the code in scope — don't report pre-existing unwrap/panic counts outside the change as if the change introduced them.
Automated Checks (run first if tools are available)
# Safety surface metrics
cargo geiger 2>/dev/null # count unsafe blocks across crate graph
cargo geiger --output-format json # machine-readable
# Lints — must pass clean
cargo clippy -- -D warnings
# Security audit
cargo audit
# Unused dependencies
cargo +nightly udeps --all-targets 2>/dev/null
# Warnings in clean build
cargo clean && cargo build 2>&1 | grep -E "^warning"
# Count unsafe/panic/unwrap manually
grep -rn "unsafe " src/
grep -rn "\.unwrap()" src/
grep -rn "\.expect(" src/
grep -rn "panic!(" src/
grep -rn "todo!()" src/
grep -rn "unimplemented!()" src/Run these commands, report counts, then do manual review below.
Safety Metrics
Report these numbers at the top of the review:
unsafe blocks: <N> (cargo geiger or manual grep)
unwrap() calls: <N>
expect() calls: <N>
panic!() calls: <N>
todo!()/unimpl!(): <N>
clippy warnings: <N>
audit findings: <N>Each non-zero number introduced or touched by the change requires justification. Pre-existing counts outside the scope are context, not findings.
Review Checklist
Use the checklist as a lens, not a scorecard: reason about the actual change, report real violations anchored to file:line, and flag issues even when they aren't listed. Don't manufacture findings to fill a category.
Tiger Style
Skip this section entirely if --no-tiger was passed. Otherwise it is mandatory.
- Non-trivial functions assert preconditions and key invariants with
assert!/debug_assert! - All loops over external input have explicit bounds; no recursion without provable termination
- Functions under 70 lines
- Named constants for limits and sizes — no unexplained magic numbers
- Errors propagated explicitly — never silently dropped with
let _ =or.ok()on a meaningful operation
Unsafe Code
- Every
unsafeblock has a// SAFETY:comment explaining the invariant relied upon - Unsafe is confined to the smallest possible scope
- Each unsafe block has a corresponding test exercising the unsafe path
- No raw pointer arithmetic without bounds assertions
- Edition 2024:
externblocks are declaredunsafe extern, andno_mangle/link_section/export_nameuse the#[unsafe(...)]wrapper
Panic and Unwrap
- No
.unwrap()in library code (crates withoutmain.rs) - Each
.expect("msg")has a descriptive message that identifies WHAT failed and WHY it should not - No
panic!()on recoverable errors (bad input, missing file, network failure) panic!()acceptable only for: violated invariants, programmer errors, OOM in systems context
Error Handling
- Library errors use
thiserrorwith typed enum variants - Binary errors use
anyhowwith.context("operation description") ?operator used consistently — no manualmatch Err(e) => return Err(e.into())- All
Result-returning functions have their error handled at call sites — no implicit.ok()discard on meaningful operations
Ownership and Borrowing
- No unnecessary
.clone()— check if a reference suffices - No
Arc<Mutex<T>>where single-threadedRefCell<T>or owned data works Mutexlock scope is minimal — no lock held across await points- No
Box<dyn Error>in library public API — use typed errors
Async (if applicable)
- No blocking calls inside
async fn(nostd::thread::sleep,std::fs::read) - CPU-bound work in
tokio::task::spawn_blocking - Futures are
Sendwhen used with multi-thread Tokio runtime select!arms handle cancellation correctly
Idiomatic Rust
- Iterator chains preferred over manual loops where clarity is not lost
if let/while letover.unwrap()on Optionsmatches!()macro for pattern matching in boolean context- Field order only matters for
#[repr(C)]/FFI types — don't flag ordering on ordinaryrepr(Rust)structs (the compiler reorders them) #[derive]used where applicable (Debug, Clone, PartialEq)- No custom
Displaythat just re-emits theDebugoutput — ifDisplayadds nothing over{:?}, drop it - Async closures (
async || …, stable since 1.85) instead of|| async { … }where a closure must return a future - Edition 2024:
impl Traitreturn types capture every in-scope generic lifetime — narrow with+ use<...>where the wider capture is unwanted
Performance
Idiom-level checks only — for a ranked, costed optimization plan, use /ds-perf-plan.
- No allocation inside loops where pre-allocation is possible
String::with_capacity(n)/Vec::with_capacity(n)where size is known- No repeated
HashMap::get+HashMap::insert— useentry()API - Large values passed by reference, not moved through multiple stack frames unnecessarily
Security
- No SQL built by string formatting — use parameterized queries / typed query macros (
sqlx,diesel) - No
Command::new/ shell execution with unsanitized user input - No hardcoded credentials or secrets
- Untrusted input validated and bounded before use (lengths, indices, sizes)
- Outbound URLs derived from user input validated or allow-listed (SSRF)
- Deserialization of untrusted data is size-bounded and depth-limited
Testing
- Each
unsafeblock has a dedicated test - Each error variant has a test triggering it
#[should_panic]tests for intentional panics- Fuzzing targets for parsing/deserialization code (
cargo fuzzorbolero)
Dependencies (Cargo.toml)
- No duplicate functionality across deps (two HTTP clients, two JSON libs)
featuresflags used to minimize compiled surface area- Dev-only deps in
[dev-dependencies], not[dependencies] cargo auditclean (no known CVEs)
Output Format
Header (always emit):
unsafe: <N> | unwrap: <N> | expect: <N> | panic: <N> | clippy: <N>Findings:
<file>:<line>: <severity>: <problem>. <fix>.Severity: critical (soundness/CVE), major (reliability/correctness), minor (idiom/style).
Skip findings with no actionable fix. Do not report clippy items already caught by cargo clippy -- -D warnings.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

