A Cargo subcommand that automatically manages dependencies in your Rust projects.
cargo-autodd simplifies Rust dependency management by automatically adding required crates to your Cargo.toml based on use statements, extern crate declarations, and direct references in your code.
- π Scans Rust source files for imports and direct references
- π€ Automatically detects required dependencies
- β¬οΈ Updates Cargo.toml with the latest stable versions (including patch versions)
- ποΈ Removes unused dependencies
- π Generates dependency usage reports
- π Checks for security vulnerabilities
- π’ Supports Cargo workspaces and monorepo structures
- π‘οΈ Handles internal crates with path dependencies correctly
- π Debug mode for detailed analysis
- π Detects direct references without use statements (e.g.,
serde_json::Value) - π Preserves original crate names (handles dashes and underscores correctly)
- π Dry-run mode to preview changes without modifying files
- βοΈ Configuration file support (
.cargo-autodd.toml) - π§ͺ Auto-detects dev-dependencies from
tests/directory
cargo install cargo-autodd- π¦ Rust 1.56.0 or later
- π¦ Cargo
# Show help information
cargo autodd --help
# Analyze and update dependencies in the current project
cargo autodd
# Preview changes without modifying files (dry-run)
cargo autodd --dry-run
# Run with debug mode for detailed analysis
cargo autodd --debug
# or
cargo autodd -d
# Use custom config file
cargo autodd --config /path/to/.cargo-autodd.toml
# or
cargo autodd -c /path/to/.cargo-autodd.toml# Check and update all dependencies to their latest versions
cargo autodd update# Generate a detailed dependency usage report
cargo autodd report# Check for security vulnerabilities
cargo autodd security# Run in the root of your workspace to analyze all crates
cargo autodd
# Run in a specific crate directory within the workspace
cd crates/my-crate
cargo autoddWhen using cargo-autodd in a monorepo:
- Internal crates with
pathdependencies are automatically detected - The tool respects
publish = falsesettings - Dependencies are correctly managed across the workspace
In debug mode, the following detailed information is displayed:
- π Path of detected Rust files
- π Content of each line being processed
- π Detected
usestatements and base crate names - π¦ Details of nested imports
- π§ Detection of
extern cratestatements - π Analysis results of each file
- π Final list of crate references
Preview what changes would be made without actually modifying files:
cargo autodd --dry-runThis shows:
- Dependencies that would be added
- Dependencies that would be removed
- Dev-dependencies detected from
tests/directory
Create a .cargo-autodd.toml file in your project root to customize behavior:
# Crates to exclude from analysis (e.g., internal crates, false positives)
exclude = ["internal_crate", "another_internal"]
# Additional essential dependencies (never removed automatically)
essential = ["custom_essential_lib"]
# Crates to always treat as dev-dependencies
dev_only = ["proptest", "criterion"]
# Skip tests/ directory analysis entirely
skip_tests = false| Option | Type | Description |
|---|---|---|
exclude |
Array | Crates to skip during analysis |
essential |
Array | Additional crates that should never be removed |
dev_only |
Array | Crates to always add as dev-dependencies |
skip_tests |
Boolean | If true, skip analyzing tests/ directory |
- π Analyzes your Rust source files
- π Detects import statements, external crate declarations, and direct references
- π§ͺ Crates used only in
tests/directory are added to[dev-dependencies] - β‘ Updates Cargo.toml with required dependencies
- β
Verifies changes with
cargo check - π Checks for security vulnerabilities
- π Generates detailed reports about dependency usage
cargo-autodd fully supports Cargo workspaces and monorepo structures:
- π Correctly detects and handles internal crates within a workspace
- π‘οΈ Respects
publish = falsesettings for internal crates - π Properly handles path dependencies in both standard and inline table formats:
# Both formats are supported: internal-crate = { path = "../internal-crate" } [dependencies.another-internal-crate] path = "../another-internal-crate"
- π« Avoids searching for internal crates on crates.io
- π§© Works with workspace inheritance for dependency management
This ensures that your internal crates that aren't meant to be published to crates.io are handled correctly, avoiding errors like Crate 'internal_crate' not found on crates.io.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
nwiizo (@nwiizo)
