Cheatsheet: Cargo (Rust)
Last updated 2026-09-25
Basic Commands
Create a new Rust project
Build a project
Build an optimized release binary
Run a project
Clean up build artifacts
Check project for errors without building
Dependency Management
Add a new dependency
Add a dependency pinned to a version
Add a dependency with specific feature flags
Add a dependency for dev/test builds only
Update all dependencies
List outdated dependencies
Remove a dependency
Testing & Documentation
Run all tests
Run only tests whose name matches a substring
Run tests without capturing stdout/println! output
Run tests sequentially instead of in parallel
Run benchmarks
Generate documentation
Open generated documentation
Formatting, Linting & Workspaces
Format code with rustfmt
Check formatting without writing changes
Lint with Clippy
Fail Clippy on any warning (useful in CI)
Build/test only one crate in a workspace
Print the resolved dependency tree
Publishing & Versioning
Publish a crate to crates.io
Check a crate before publishing
Bump version number
Cargo Deny (Dependency Auditing)
Install cargo-deny
Run cargo-deny check for security, licenses, and more
Check for security advisories
Check for outdated dependencies
Check for banned or incompatible licenses
Generate cargo-deny config file