/rewrite-rs-skills:rust-supply-chainfrom rewrite-rs-skills
Audits Rust dependency trees for vulnerabilities, license compliance, banned/duplicate crates, and unmaintained dependencies. Turns cargo audit/deny findings into actionable decisions.
Ships in rewrite-rs-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
An audit that ends in a list of advisory IDs has done the easy half. The hard half is saying, per advisory, whether this repo actually reaches the vulnerable code path and what to do about it.
Four questions: is anything we depend on known-vulnerable, is anything
unmaintained, does every licence in the tree comply with the policy, and is
the tree carrying weight it does not need. Each added crate lengthens
compiles, grows the binary, and widens the set of authors you trust, and that
includes its build.rs and any proc macros, which run arbitrary code on the
build machine. Read Cargo.lock as the authority
on what is actually built — not Cargo.toml, which states ranges — and read
the MSRV from docs/agents/rust.md, because a fix that bumps a dependency
past the MSRV is not a fix. The rule: every finding ends in a decision —
upgrade, replace, vendor, or accept with a written reason and an expiry. An
unactioned advisory list is noise, and noise trains people to ignore the tool.
cargo audit reads the RustSec advisory database and answers exactly one
question: is anything in the tree known-vulnerable. cargo deny answers four
— advisories, bans, licenses, sources — including that same one,
against a policy file; with no deny.toml it runs on built-in defaults that
encode no policy. A repo running cargo deny check does not
need cargo audit separately; a repo that wants only advisory checking and no
policy file is better off with cargo audit alone. Say which the repo should
run and why, rather than adding both. The policy file in full, annotated, is
in DENY.md; it lands in the target repo only on explicit request.
An ID and a severity are the start. The question is whether this repo
reaches the affected code — a parsing vulnerability in a crate used only in a
build script for developer tooling is a different decision from the same
advisory in a network-facing path. The mechanics: cargo tree --invert <crate> shows who pulled it in, which tells you whether the dependency is
direct (you upgrade) or transitive (you upgrade the intermediary, or wait for
it). State plainly that "no upstream fix yet" is a real outcome with real
options — pin, patch via [patch.crates-io], vendor, or replace — and that
recording the choice matters more than which one is picked.
RustSec issues RUSTSEC-* unmaintained notices with no vulnerability
attached. Treat them as a maintenance-planning signal with a horizon, not an
emergency: note the crate, check whether a maintained fork has consensus, and
decide whether to move now or watch it.
cargo tree -d
Cargo lets semver-incompatible versions of a crate coexist (a 0.x and a 1.x,
or two majors) and never two compatible ones, so a duplicate always means a
range somewhere is stuck on an older line. Every duplicate means two
versions compiled in, two licence obligations, and — when the crate has global
state or a public type crossing an API boundary — genuinely confusing type
errors: two Url types that look identical and do not unify. That is also the
price of splitting everything into tiny single-purpose crates; the
composability is real, and so is the version skew. The fix is usually raising a lower bound so
the two ranges unify, not banning the crate. cargo deny check bans is what
keeps a resolved duplicate resolved.
A bare "1.4" means ^1.4: any compatible newer release. "~1.4.2" allows
patch releases only, "=1.4.2" pins one exact version, and "*" accepts
anything. Prefer the bare form ("1" or "1.4.23" as the lower bound the
code truly needs). An exact pin in a library blocks every other crate in the
graph from unifying on a neighbouring version and manufactures the duplicates
above; a wildcard hands control of the build to whoever publishes next.
Exact pins belong in an application's lockfile, not in manifests other crates
depend on.
Commit Cargo.lock for a binary or application — the lockfile is what makes
the build reproducible and the audit meaningful. For a library it is optional,
because consumers resolve their own.
To see why a feature is on, or which dependency turns it on:
cargo tree --edges features --invert <crate>
The axis runs from permissive-only to copyleft-tolerated. deny.toml needs an
explicit allow-list either way, and crates with no licence metadata at all
need a per-crate exception with a reason attached. Do not ship an opinion
about which licences a user may accept — name the axis, let the repo decide,
and record the decision in the policy file.
Some facts the user can act on, stated as information rather than a rule. Depending only on permissively licensed crates keeps a permissive crate freely redistributable; one copyleft dependency changes what downstream users may do with the whole binary. And the licence, like the default feature set, is part of the public contract of a crate: changing either is a breaking change for someone.
When the repo is a crate it publishes, the ecosystem default is the dual
licence MIT OR Apache-2.0: license = "MIT OR Apache-2.0" in the manifest
and both licence texts shipped as files in the repo root, matching the Rust
project. Offer it as the default when the user has no preference; if they have
chosen another licence, keep theirs and make sure the manifest field and the
licence files agree with each other.
The advisory database changes without the code changing, so an audit belongs
on a weekly schedule and on dependency-change pull requests — not in a
pre-commit hook, where it costs network time on every commit. If the repo
wants that wired into CI, run the /setup-rust-ci skill — it writes the
workflow.
cargo deny check # advisories, bans, licenses, sources
cargo audit # if the repo uses it standalone
cargo tree -d
cargo tree --edges features # which dependency enables which feature
cargo update --dry-run # what a routine refresh would move
Report exit codes, not just output: cargo deny check exits non-zero on any
denied finding, and that exit code is what a CI job keys on. If a tool is not
installed, say so and give the install line — never report a clean audit that
did not run.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub rewrite-rs/skills --plugin rewrite-rs-skills28 skills in this plugin
/async-rustWrite correct async Rust — runtime choice, Send and Sync bounds, cancellation safety, blocking work inside async contexts, and shared state across tasks. Use when writing or reviewing async code, when a future is held across an await point, when the user hits a Send bound error on a spawned task, when a runtime stalls or deadlocks, or when the user asks about tokio, select!, or spawn_blocking./idiomatic-rustWrite Rust that reads like Rust — iterator pipelines over index loops, From/Into over ad-hoc converters, derives over hand-written impls, newtypes over bare primitives. Use when writing new Rust, when reviewing Rust that reads like a translation from another language, when reaching for a classic design pattern (strategy, command, visitor) or a try/finally cleanup in Rust, when naming a constructor, accessor, iterator, or error type, or when the user asks how to make Rust code more idiomatic or less repetitive./ownership-not-cloneOther plugins' skills for the same job