Skilllibrary cargo-lock-manager
Manage Rust Cargo.lock files, dependency auditing, version pinning, and supply-chain security. Trigger: 'audit Cargo dependencies', 'update Cargo.lock', 'check for vulnerable crates', 'manage Rust dependencies', 'cargo deny', 'cargo audit', 'dependency tree analysis', 'Cargo workspace dependencies'. Do NOT use for writing Rust application code, designing Rust APIs, or general Cargo.toml project configuration unrelated to dependency management.
git clone https://github.com/merceralex397-collab/skilllibrary
T=$(mktemp -d) && git clone --depth=1 https://github.com/merceralex397-collab/skilllibrary "$T" && mkdir -p ~/.claude/skills && cp -r "$T/17-external-reference-seeds/cargo-lock-manager" ~/.claude/skills/merceralex397-collab-skilllibrary-cargo-lock-manager && rm -rf "$T"
17-external-reference-seeds/cargo-lock-manager/SKILL.mdPurpose
Provide a repeatable procedure for managing Rust project dependencies — from Cargo.lock commit discipline and version pinning through security auditing, license compliance, and workspace dependency management. This skill produces auditable, actionable dependency management plans.
When to use this skill
Use this skill when:
- a Cargo.lock file needs to be updated, audited, or its commit policy needs to be decided
has reported vulnerabilities and a triage/remediation plan is neededcargo audit- dependency versions in Cargo.toml need review (pinning strategy, SemVer range selection)
- a Cargo workspace needs shared dependency management or version inheritance
- license compliance must be checked across the dependency tree with
cargo deny - compile times are slow and dependency reduction or feature-flag trimming could help
- a new crate dependency is being evaluated for inclusion
Do not use this skill when
- the task is writing Rust application logic, traits, or type design — that's general Rust development
- the work is about Cargo.toml project metadata (edition, name, authors) unrelated to dependencies
- the task involves a different language's package manager (npm, pip, go mod)
- the user needs help with Rust build targets, cross-compilation, or linker configuration
Operating procedure
Step 1 — Determine Cargo.lock commit policy
The commit policy depends on the crate type:
| Crate type | Commit Cargo.lock? | Reason |
|---|---|---|
| Binary (application, CLI tool, server) | Always | Ensures reproducible builds — every resolves to identical dependency versions. |
| Library (published to crates.io) | No (or optional) | Downstream consumers generate their own lockfile; committing yours adds noise and merge conflicts without reproducibility benefit. |
| Workspace with mixed binary + library | Yes | The workspace lockfile is shared; binary reproducibility takes priority. |
If
.gitignore excludes Cargo.lock for a binary crate, fix it immediately.
Step 2 — Audit for known vulnerabilities
Run the security audit pipeline:
# Install tools if missing cargo install cargo-audit cargo-deny # Check RUSTSEC advisory database cargo audit --json 2>/dev/null | jq '.vulnerabilities.list[] | {id: .advisory.id, crate: .advisory.package, title: .advisory.title, severity: .advisory.cvss}' # Human-readable summary cargo audit
For each reported vulnerability, triage using this priority matrix:
| Severity | Direct dependency? | Action | Timeline |
|---|---|---|---|
| Critical/High | Yes | Update or patch immediately | Same day |
| Critical/High | Transitive | Update parent crate or pin patched version | Within 48 hours |
| Medium | Yes | Schedule update in next dependency maintenance window | Within 1 week |
| Medium | Transitive | Monitor; update if parent crate releases fix | Within 2 weeks |
| Low/Informational | Any | Document and track; update opportunistically | Next maintenance cycle |
If no patched version exists:
- Check if the vulnerability is exploitable in your usage context.
- If exploitable, evaluate alternative crates (
for community reviews).cargo crev - If not exploitable, document the risk acceptance with a
ignore entry and a comment explaining why.cargo audit
Step 3 — License compliance check
# Configure cargo-deny (create deny.toml if absent) cargo deny init # Check license compliance cargo deny check licenses # Check for banned crates, duplicate versions, and advisories in one pass cargo deny check
In
deny.toml, define explicit allow/deny lists:
[licenses] allow = ["MIT", "Apache-2.0", "BSD-2-Clause", "BSD-3-Clause", "ISC", "Zlib"] deny = ["GPL-3.0", "AGPL-3.0"] # Adjust per project licensing requirements confidence-threshold = 0.8
Step 4 — Analyze dependency tree
# Full dependency tree cargo tree # Find why a specific crate is included cargo tree -i <crate_name> --depth 1 # Find duplicate versions of the same crate cargo tree --duplicates # Count total dependencies cargo tree --depth 999 --prefix none | sort -u | wc -l
Use the tree analysis to identify:
- Duplicate crates: different versions of the same crate pulled by different parents → try to unify by updating parents.
- Heavy transitive trees: a single dependency pulling in 50+ transitive deps → evaluate if the functionality justifies the cost.
- Feature-flag bloat: dependencies pulling in features you don't use → disable default features and enable only what's needed.
Step 5 — Version pinning strategy in Cargo.toml
Follow these SemVer range conventions:
| Syntax | Meaning | When to use |
|---|---|---|
(default) | ≥1.2.3, <2.0.0 | Most dependencies — allows compatible updates |
| ≥1.2.3, <1.3.0 | When patch updates are safe but minor versions have broken you before |
| Exactly 1.2.3 | Only for known-fragile crates or when reproducing a specific bug |
| Custom range | When you need features from 1.2+ but 1.5 introduced a breaking change |
Never use
(wildcard) — it accepts any version including breaking changes.*
Step 6 — Perform targeted updates
# Update a single crate (and its dependencies) cargo update -p <crate_name> # Update a single crate to a specific version cargo update -p <crate_name> --precise <version> # Update all dependencies within SemVer-compatible ranges cargo update # Check for outdated dependencies (install cargo-outdated first) cargo outdated --root-deps-only
After every update:
- Run the full test suite:
cargo test --workspace - Run clippy:
cargo clippy --workspace -- -D warnings - Re-run
to confirm no new vulnerabilities were introducedcargo audit - Review the diff to
before committingCargo.lock
Step 7 — Workspace dependency management
For multi-crate workspaces, centralize dependency versions:
# Workspace root Cargo.toml [workspace.dependencies] serde = { version = "1.0", features = ["derive"] } tokio = { version = "1", features = ["full"] } anyhow = "1.0" # Member crate Cargo.toml [dependencies] serde = { workspace = true } tokio = { workspace = true }
Benefits:
- Single source of truth for dependency versions across all workspace members.
in the workspace root updates all members consistently.cargo update- Version inheritance via
eliminates version drift between crates.workspace = true
Step 8 — Reduce compile times through dependency hygiene
# Measure build times per crate cargo build --timings # Identify heaviest compile-time dependencies cargo build --timings 2>&1 | head -20
Optimization strategies:
- Disable default features:
serde = { version = "1.0", default-features = false, features = ["derive"] } - Use
for dev-only deps: put heavy test/bench dependencies incfg
only.[dev-dependencies] - Replace heavy crates: e.g.,
instead ofureq
if you don't need async HTTP;reqwest
instead offastrand
if you don't need cryptographic randomness.rand - Feature-gate optional functionality: use Cargo features to make expensive dependencies opt-in.
Decision rules
- Binary crates always commit Cargo.lock — no exceptions. Reproducible builds are a correctness requirement, not a preference.
- Critical/High vulnerabilities in direct dependencies are blockers — do not merge PRs or ship releases until remediated or explicitly risk-accepted with documentation.
- Wildcard versions are never acceptable —
in Cargo.toml is a reject-on-sight finding.* - Prefer fewer dependencies over more — before adding a new crate, check if the functionality can be implemented in <50 lines of code. If so, vendor it.
- Unified dependency versions over duplicates — if
shows multiple versions of the same crate, make unification a priority to reduce compile time and binary size.cargo tree --duplicates - Feature flags should be minimal — enable only the features you actually use.
should be the starting position for every dependency.default-features = false - Update frequency: security audits weekly (automate in CI), general dependency updates monthly, major version upgrades quarterly with dedicated testing.
Output requirements
Produce a structured deliverable with these sections:
- Dependency Audit Report — list of all vulnerabilities found, severity, affected crate and version, remediation action (update/patch/replace/accept risk), timeline.
- Update Plan — ordered list of dependency updates to perform, expected SemVer impact, test verification steps, rollback procedure if tests fail.
- License Compatibility Matrix — table of all direct dependencies with their licenses, compatibility status (allowed/denied/review needed), and any copyleft concerns.
- Build Time Impact — current build time baseline, identified heavy dependencies, proposed optimizations with estimated time savings.
- Cargo.lock Status — commit policy confirmation, current lockfile freshness, any stale or yanked versions detected.
Anti-patterns
- Wildcard versions (
) in Cargo.toml: accepts any version including breaking changes; defeats the entire purpose of SemVer.* - Ignoring
warnings: known vulnerabilities left unaddressed accumulate risk silently; at minimum, document risk acceptance.cargo audit - Not committing Cargo.lock for binary crates: makes builds non-reproducible; different developers and CI get different dependency versions.
- Yanked dependency ignorance: running
may fail if a depended-upon version was yanked; monitor and update proactively.cargo update - Blanket
without testing: updating all dependencies at once makes it impossible to bisect which update introduced a regression. Update incrementally.cargo update - Feature-flag maximalism: enabling all features of a crate "just in case" bloats compile time and binary size for functionality you never call.
- Vendoring without a policy: copying crate source into the repo without a clear update/audit process creates unmaintained forks that drift from upstream.
- Duplicate crate versions left unchecked: two versions of
orsyn
in the dependency tree doubles compile time for those crates with no benefit.tokio
Related skills
— SolidJS frontend patterns (Rust backend + SolidJS frontend is a common stack)solidjs-patterns
— Tauri desktop apps (Rust backend with Cargo dependency management)tauri-solidjs
— tracking dependency update work items in Linearlinear-address-issue
Failure handling
- If
fails to run (database fetch error), ensure network access and trycargo audit
to update the advisory database manually.cargo audit fetch - If a vulnerability has no patched version and no alternative crate exists, document the risk in a
exception with andeny.toml
entry and a clear comment explaining the business justification.[advisories.ignore] - If
causes test failures, revert to the previous Cargo.lock and update dependencies one at a time to isolate the breaking change.cargo update - If workspace dependency unification is impossible due to conflicting version requirements between member crates, document the conflict and track upstream resolution.