Essential Cargo Tools for Rust Productivity 2026
Essential cargo tools 2026: cargo-watch, cargo-audit, cargo-expand, cargo-flamegraph, cargo-nextest, cargo-deny, cargo-machete, and workspace management best practices.
Cargoβs plugin ecosystem transforms Rust development. Beyond the built-in build, test, and run, a suite of community tools handles auto-reload, profiling, faster testing, security audits, and workspace management. Hereβs every tool worth installing in 2026.
Installing the Full Toolkit
# Install all essential tools at once
cargo install cargo-watch cargo-audit cargo-expand cargo-nextest \
cargo-deny cargo-machete cargo-outdated cargo-edit \
flamegraph wasm-pack
Or use cargo-binstall for pre-compiled binaries (much faster):
cargo install cargo-binstall
cargo binstall cargo-watch cargo-nextest cargo-deny cargo-machete
cargo-watch: Auto-Rerun on Change
cargo-watch watches your source files and re-runs cargo commands when they change. This is the Rust equivalent of nodemon or air.
cargo install cargo-watch
# Basic usage
cargo watch -x run # re-run binary on change
cargo watch -x test # re-run tests
cargo watch -x check # fastest: just type-check, no binary
cargo watch -x "clippy -- -D warnings" # continuous linting
# Multiple commands in sequence
cargo watch -x check -x test -x run
# Watch only specific paths
cargo watch --watch src/ -x test
# Ignore files
cargo watch --ignore "*.md" -x check
# Clear terminal between runs
cargo watch -c -x run
# Run a shell command after cargo command
cargo watch -x build -s "echo Build complete!"
Recommended workflow:
# Terminal 1: continuous type-checking (fast feedback)
cargo watch -c -x check
# Terminal 2: run tests on save
cargo watch -c -x "nextest run"
# Terminal 3: server with auto-reload
cargo watch -c -x "run --bin server"
cargo-audit: Security Vulnerability Scanning
cargo-audit checks your Cargo.lock against the RustSec Advisory Database.
cargo install cargo-audit
cargo audit # scan for vulnerabilities
cargo audit fix # upgrade vulnerable packages
cargo audit fix --dry-run # preview what would change
Example output:
Crate: openssl
Version: 0.10.55
Title: Memory corruption in X.509 certificate verification
Date: 2023-11-01
ID: RUSTSEC-2023-0071
URL: https://rustsec.org/advisories/RUSTSEC-2023-0071
Severity: 9.8 (critical)
Solution: Upgrade to >= 0.10.60
error: 1 vulnerability found!
CI integration:
# .github/workflows/security.yml
- name: Security audit
run: cargo audit --deny warnings
audit.toml Configuration
# audit.toml β suppress known false positives
[advisories]
ignore = [
"RUSTSEC-2020-0168", # unmaintained crate, no fix available
]
[output]
deny = ["vulnerability", "unsound"]
warn = ["unmaintained", "yanked"]
cargo-expand: Debug Macro Expansions
Rust macros can be opaque. cargo-expand prints the fully expanded code, showing exactly what derive macros and procedural macros generate.
cargo install cargo-expand
# Requires nightly for some features:
rustup toolchain install nightly
cargo expand # expand entire crate
cargo expand --lib # expand lib.rs
cargo expand models::user # expand specific module
cargo expand --test integration # expand test module
Example:
// Your code:
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct ApiKey {
pub id: uuid::Uuid,
pub key_hash: String,
pub created_at: chrono::DateTime<chrono::Utc>,
}
cargo expand models::api_key
# Outputs the full generated impl Debug, impl Clone,
# impl Serialize, impl Deserialize β hundreds of lines
This is invaluable when a derive macro isnβt doing what you expect or when debugging custom derive implementations.
cargo-flamegraph: CPU Profiling
Generate flame graphs directly from your Rust project without complex perf setup.
cargo install flamegraph
# Linux: sudo apt install linux-perf (or linux-tools-generic)
# macOS: instruments is used automatically
cargo flamegraph --bin my_app # generates flamegraph.svg
cargo flamegraph --example my_example
cargo flamegraph --test my_test -- test_fn # profile a specific test
cargo flamegraph -- --arg1 --arg2 # pass args to your binary
Cargo.toml for better flamegraphs:
[profile.release]
debug = true # include debug info in release build
The SVG output is interactive β hover for exact timings, click to zoom into call stacks. Look for the widest boxes; those are your hot paths.
cargo-nextest: Faster Test Runner
cargo-nextest is a next-generation test runner for Rust that is 2-3Γ faster than cargo test and has better output formatting.
cargo install cargo-nextest
cargo nextest run # run all tests
cargo nextest run --test-threads 8 # explicit parallelism
cargo nextest run my_module # filter by name
cargo nextest run --no-capture # show stdout
cargo nextest run --profile ci # use CI profile settings
Speed comparison (100-test suite):
| Runner | Time | Parallelism |
|---|---|---|
| cargo test | 45s | Per-binary |
| cargo nextest | 18s | Per-test |
nextest runs each test as a separate process, enabling better isolation and true parallelism.
.config/nextest.toml
[profile.default]
retries = 0
test-threads = "num-cpus"
status-level = "fail"
[profile.ci]
retries = 2 # retry flaky tests in CI
fail-fast = false # run all tests even after failures
test-threads = 4
[profile.default.junit]
path = "target/nextest/default/junit.xml"
# GitHub Actions
- name: Run tests
run: cargo nextest run --profile ci
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: test-results
path: target/nextest/default/junit.xml
cargo-deny: License and Dependency Policy
cargo-deny enforces rules about allowed licenses, banned crates, duplicate versions, and known vulnerabilities.
cargo install cargo-deny
cargo deny init # generate deny.toml
cargo deny check # check all policies
cargo deny check licenses
cargo deny check bans
cargo deny check advisories
deny.toml Configuration
[licenses]
allow = [
"MIT",
"Apache-2.0",
"Apache-2.0 WITH LLVM-exception",
"ISC",
"BSD-2-Clause",
"BSD-3-Clause",
"Unicode-DFS-2016",
]
deny = ["GPL-2.0", "GPL-3.0", "AGPL-3.0"]
[bans]
multiple-versions = "warn"
wildcards = "deny" # no wildcard versions in Cargo.toml
deny = [
{ name = "openssl", reason = "use rustls instead" },
]
skip = [
{ name = "bitflags", version = "1" }, # common duplicate
]
[advisories]
db-path = "~/.cargo/advisory-db"
db-urls = ["https://github.com/rustsec/advisory-db"]
vulnerability = "deny"
unmaintained = "warn"
yanked = "deny"
cargo-machete: Remove Unused Dependencies
cargo install cargo-machete
cargo machete # list potentially unused deps
cargo machete --fix # remove them from Cargo.toml
After months of development, Cargo.toml accumulates dependencies you no longer use. cargo-machete identifies them. Always review before removing β sometimes crates are needed transitively or through feature flags.
Workspace Management Best Practices
For multi-crate projects, Cargo workspaces share a single Cargo.lock and build cache.
# Root Cargo.toml
[workspace]
members = [
"api",
"core",
"cli",
"worker",
]
resolver = "2"
# Workspace-level dependencies (shared versions)
[workspace.dependencies]
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
anyhow = "1"
thiserror = "2"
sqlx = { version = "0.8", features = ["postgres", "runtime-tokio-native-tls"] }
tracing = "0.1"
# Shared workspace metadata
[workspace.package]
version = "0.1.0"
edition = "2021"
authors = ["Your Name <[email protected]>"]
license = "MIT"
# api/Cargo.toml β inherit from workspace
[package]
name = "api"
version.workspace = true
edition.workspace = true
[dependencies]
tokio.workspace = true # inherits version + features from workspace
serde.workspace = true
anyhow.workspace = true
axum = "0.8" # api-specific dep, not in workspace
Workspace commands:
cargo build --workspace # build all crates
cargo test --workspace # test all crates
cargo clippy --workspace # lint all crates
cargo nextest run --workspace # test all with nextest
Tool Reference Card
| Tool | Command | Use Case |
|---|---|---|
| cargo-watch | cargo watch -x check | Live feedback loop |
| cargo-audit | cargo audit | Security scanning |
| cargo-expand | cargo expand my_module | Debug macros |
| flamegraph | cargo flamegraph | CPU profiling |
| cargo-nextest | cargo nextest run | Faster tests |
| cargo-deny | cargo deny check | License/dep policy |
| cargo-machete | cargo machete | Remove unused deps |
| cargo-outdated | cargo outdated | Find stale deps |
| cargo-edit | cargo add/remove/upgrade | Manage deps from CLI |
With these tools, Rust development becomes faster and more reliable. The combination of cargo-watch for feedback, cargo-nextest for fast tests, and cargo-deny for governance covers the full development lifecycle.
50 CLI Commands That Save Hours Every Week
The exact Git shortcuts, file search tricks, Docker commands, and productivity hacks that senior developers use daily. Compiled from 5+ years of shipping production code.
- Git mastery (10 cmds)
- File & search wizardry
- Docker & DevOps tricks
- Process & network tools
- Productivity boosters
- macOS & Linux install guide
No spam. 1 email/week max. Unsubscribe anytime.
Found this guide useful? Check out our free developer tools.
Affiliate disclosure: Some links below are affiliate links β we may earn a small commission at no extra cost to you. Learn more.
Recommended Tools & Resources
DigitalOcean
$200 credit for new users. Simple, affordable cloud hosting for developers.
GitHub Student Pack
Free access to 100+ developer tools. Perfect for students and new devs.
Vercel
Deploy frontend apps instantly. Free tier is generous for side projects.
DevPlaybook Products
Boilerplates, scripts & AI toolkits to 10x your dev workflow.