crate-audit

Audit Rust crates for dead code, unused features, duplication, and architectural debt with evidence-backed findings.

Updated May 30, 2026
One-click install
npx skills add https://github.com/chloebrett/snitchos --skill crate-audit-chloebrett
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: crate-audit
Source: https://github.com/chloebrett/snitchos/tree/main/.claude/skills/crate-audit
Command: npx skills add https://github.com/chloebrett/snitchos --skill crate-audit-chloebrett

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Rust crates accumulate bloat over time: dead code, unused Cargo features, speculative abstractions, copy-pasted logic, and stale docs. This Skill produces an evidence-first audit report that separates safe deletions from judgement calls, so you know exactly what to remove, demote, or refactor without breaking consumers. ## Core Features & Use Cases - Evidence-backed findings: Every claim is backed by grep output, compiler signals, or the cargo xtask audit tool — no vibes-based dead-code declarations. - Multi-dimensional analysis: Covers dead code, unused features and dependencies, speculative YAGNI code, collapsible repetition, architectural debt, API surface issues, and test/doc debt. - Prioritized report: Produces a severity-ranked table split into obvious wins, judgement calls, and abstraction opportunities, with effort and risk estimates. - Use Case: Ask for an audit of a kernel module before a release; receive a report showing three pub items demotable to pub(crate), one unused dependency, and a newtype opportunity that eliminates a class of type-confusion bugs. ## Quick Start Ask the assistant to run crate-audit on a specific crate or module in your workspace and produce a prioritized findings report.

Frequently Asked Questions about crate-audit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find dead code in a Rust crate?

Run cargo xtask audit on the crate to list public symbols with zero external callers, then demote candidates to pub(crate) and rebuild with clippy so the compiler confirms what is genuinely unreachable. Cross-check consumer crates and design docs before declaring anything dead.

How do I detect unused Cargo dependencies and features?

Use cargo machete to find dependencies declared in Cargo.toml but never used in code. For features, compare the [features] table against cfg(feature) gates in source and check which features other crates actually enable.

Does the audit delete or refactor code automatically?

No. The audit only reports findings with evidence and recommendations. Deletions, demotions, or refactors happen only after you explicitly pick items, and each change is verified with tests and clippy.

Why does grep-based dead code detection give false positives?

Grep misses re-export aliases, types used positionally in public signatures, and items required by lints like clippy::len_without_is_empty. The privatization sweep — demoting to pub(crate) and rebuilding — converts these blind spots into hard compiler errors.

When should duplicated Rust code not be merged?

Duplication serving different contracts, such as a text exporter versus a protobuf exporter, is honest divergence and should stay separate. The audit flags justified duplication and explains why it may be intentional rather than collapsing it.