๐ฆ cargo-autodd
A Cargo subcommand that automatically manages dependencies in your Rust projects.
๐ Overview
cargo-autodd simplifies Rust dependency management by automatically adding required crates to your Cargo.toml based on use statements and extern crate declarations in your code.

โจ Features
- ๐ Scans Rust source files for imports
- ๐ค Automatically detects required dependencies
- โฌ๏ธ Updates Cargo.toml with the latest stable versions
- ๐๏ธ Removes unused dependencies
- ๐ ๏ธ Leverages rust-analyzer for better code analysis (when available)
- ๐งน 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
๐ฅ Installation
โ๏ธ Requirements
- ๐ฆ Rust 1.56.0 or later
- ๐ฆ Cargo
- ๐ง rust-analyzer (optional, but recommended)
๐ Usage
Automatic Dependency Management
# Analyze and update dependencies in the current project
# Run with debug mode for detailed analysis
# or
Update Dependencies
# Check and update all dependencies to their latest versions
Generate Reports
# Generate a detailed dependency usage report
Security Check
# Check for known security vulnerabilities
Monorepo Usage
# Run in the root of your workspace to analyze all crates
# Run in a specific crate directory within the workspace
When 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
Debug Mode
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
๐ How It Works
- ๐ Analyzes your Rust source files
- ๐ Detects import statements and external crate declarations
- โก Updates Cargo.toml with required dependencies
- โ
Verifies changes with
cargo check - ๐ Checks for security vulnerabilities using the RustSec Advisory Database
- ๐ Generates detailed reports about dependency usage
๐ข Monorepo Support
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" } [] = "../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.
๐ฅ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ค Author
nwiizo (@nwiizo)