
Cargo Machete
- 66 installs
- 49 repo stars
- Updated August 4, 2026
- laurigates/claude-plugins
Helps with ai & agent building tasks.
About
cargo-machete is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted development.
- cargo-machete
- AI & Agent Building
- AI-coding skill
Cargo Machete by the numbers
- 66 all-time installs (skills.sh)
- +1 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Ranked #6,006 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/laurigates/claude-plugins --skill cargo-macheteAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 66 |
|---|---|
| repo stars | ★ 49 |
| Last updated | August 4, 2026 |
| Repository | laurigates/claude-plugins ↗ |
What it does
Helps with ai & agent building tasks.
Files
cargo-machete - Unused Dependency Detection
Detect and remove unused dependencies in Rust projects using cargo-machete.
When to Use This Skill
| Use this skill when... | Use X instead when... |
|---|---|
| Auditing for unused dependencies | Checking for outdated deps -- use cargo outdated |
| Cleaning up Cargo.toml | Auditing security vulnerabilities -- use cargo audit |
| Optimizing build times by removing bloat | Checking license compliance -- use cargo deny |
| Verifying deps in CI | Need nightly-accurate analysis -- use cargo +nightly udeps |
Context
- Cargo.toml: !
find . -maxdepth 1 -name \'Cargo.toml\' - Workspace: !
grep -q '\[workspace\]' Cargo.toml - cargo-machete installed: !
cargo machete --version - Machete config: !
find . -maxdepth 1 -name \'.cargo-machete.toml\' - Workspace members: !
grep -A 20 '^\[workspace\]' Cargo.toml
Execution
Execute this unused dependency analysis:
Step 1: Verify installation
Check if cargo-machete is installed (see Context above). If not installed, install it:
cargo install cargo-macheteStep 2: Run dependency analysis
Run cargo-machete with metadata for detailed output:
# Single crate
cargo machete --with-metadata
# Workspace (if Context shows workspace)
cargo machete --workspace --with-metadataStep 3: Evaluate results
Review the output and classify each finding:
| Finding | Action |
|---|---|
| Genuinely unused dependency | Remove with --fix or manually |
| Proc-macro dependency (e.g., serde derive) | Add machete:ignore comment |
| Build.rs-only dependency | Move to [build-dependencies] |
| Re-exported dependency | Add machete:ignore comment with explanation |
Step 4: Apply fixes
For confirmed unused dependencies, auto-remove them:
cargo machete --fixFor false positives, add ignore annotations in Cargo.toml:
serde = "1.0" # machete:ignore - used via derive macroOr create .cargo-machete.toml for project-wide ignores:
[ignore]
dependencies = ["serde", "log"]Step 5: Verify build
After removing dependencies, confirm everything still compiles:
cargo check --all-targets
cargo test --no-runFalse Positive Handling
| Scenario | Solution |
|---|---|
| Proc-macro deps (e.g., serde derive) | machete:ignore comment |
| Build.rs-only deps | Move to [build-dependencies] |
| Re-exported deps | machete:ignore comment with explanation |
| Example/bench-only deps | Verify in [dev-dependencies] |
Comparison with cargo-udeps
| Feature | cargo-machete | cargo-udeps |
|---|---|---|
| Accuracy | Good | Excellent |
| Speed | Very fast | Slower |
| Rust version | Stable | Requires nightly |
| False positives | Some | Fewer |
Use cargo-machete for fast CI checks. Use cargo-udeps for thorough audits:
cargo +nightly udeps --workspace --all-featuresAgentic Optimizations
| Context | Command |
|---|---|
| Quick check | cargo machete |
| Detailed check | cargo machete --with-metadata |
| Workspace check | cargo machete --workspace --with-metadata |
| Auto-fix | cargo machete --fix |
| Verify after fix | cargo check --all-targets |
| Accurate check (nightly) | cargo +nightly udeps --workspace |
Quick Reference
| Flag | Description |
|---|---|
--with-metadata | Show detailed output with versions and locations |
--fix | Auto-remove unused dependencies from Cargo.toml |
--workspace | Check all workspace members |
-p <crate> | Check specific workspace member |
--exclude <crate> | Exclude specific workspace member |
Troubleshooting
| Problem | Solution |
|---|---|
| Proc macro flagged as unused | Add machete:ignore comment in Cargo.toml |
| Build.rs dep flagged | Move to [build-dependencies] |
| Re-exported dep flagged | Add machete:ignore with explanation |
| Need more accuracy | Use cargo +nightly udeps |
For CI integration patterns, configuration file examples, pre-commit setup, and Makefile integration, see REFERENCE.md.
cargo-machete Reference
Detailed configuration, CI integration, and workflow patterns for cargo-machete.
Installation
# Install cargo-machete
cargo install cargo-machete
# Verify installation
cargo machete --versionOutput Examples
Basic Output
$ cargo machete
Found unused dependencies in Cargo.toml:
serde_json (unused)
log (unused in lib, used in build.rs)
tokio (unused features: macros)With Metadata
$ cargo machete --with-metadata
Project: my_app (bin)
Unused dependencies:
- serde_json (0.1.0)
Declared in: Cargo.toml [dependencies]
Not used in: src/main.rs
Partially used:
- tokio (1.35.0)
Unused features: macros, fs
Used features: runtime, netConfiguration File
Create .cargo-machete.toml in project root:
# .cargo-machete.toml
# Global ignores
[ignore]
dependencies = [
"serde", # Used via derive macro
"log", # Used in macro expansion
]
# Per-crate ignores
[ignore.my_lib]
dependencies = ["lazy_static"]
[ignore.my_bin]
dependencies = ["clap"]
# Workspace-wide settings
[workspace]
# Don't analyze these crates
exclude = ["internal_tools", "examples"]Inline Cargo.toml Ignores
[dependencies]
serde = "1.0" # machete:ignore - used via re-export
log = "0.4" # machete:ignore - used in macro expansionWorkspace Configuration
# Check all workspace members
cargo machete --workspace
# Check specific workspace members
cargo machete -p crate1 -p crate2
# Exclude specific members
cargo machete --workspace --exclude integration_testsCI Integration
GitHub Actions with cargo-machete
name: Dependency Check
on: [push, pull_request]
jobs:
unused-deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install cargo-machete
uses: taiki-e/install-action@v2
with:
tool: cargo-machete
- name: Check for unused dependencies
run: cargo machete --with-metadataOfficial GitHub Action
name: Dependency Check
on: [push, pull_request]
jobs:
unused-deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check unused dependencies
uses: bnjbvr/cargo-machete@mainGitHub Actions with cargo-udeps (Nightly)
name: Dependency Check
on: [push, pull_request]
jobs:
unused-deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
- name: Install cargo-udeps
uses: taiki-e/install-action@v2
with:
tool: cargo-udeps
- name: Check for unused dependencies
run: cargo +nightly udeps --workspace --all-featurescargo-udeps Installation and Usage
# Install nightly and cargo-udeps
rustup toolchain install nightly
cargo +nightly install cargo-udeps
# Run analysis (requires nightly)
cargo +nightly udeps
# With specific features
cargo +nightly udeps --all-features
# For workspace
cargo +nightly udeps --workspacePre-commit Integration
# .pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: cargo-machete
name: Check for unused dependencies
entry: cargo machete
language: system
pass_filenames: false
files: Cargo.toml$Makefile Integration
# Makefile
.PHONY: deps-check deps-clean
deps-check:
@echo "Checking for unused dependencies..."
@cargo machete --with-metadata
deps-clean:
@echo "Removing unused dependencies..."
@cargo machete --fix
@echo "Running cargo check..."
@cargo check --all-targetsCI Script
#!/usr/bin/env bash
# scripts/check-deps.sh
set -euo pipefail
echo "Running cargo-machete..."
if ! cargo machete --with-metadata; then
echo "Unused dependencies detected!"
echo "Run 'cargo machete --fix' to remove them."
exit 1
fi
echo "No unused dependencies found."Combined Dependency Audit
# Full dependency audit
cargo machete # Check unused
cargo outdated # Check outdated
cargo audit # Check security
cargo deny check licenses # Check licenses