| name | deps-audit |
| description | Use when auditing, updating, or securing project dependencies. Covers multi-language dependency detection, security vulnerability scanning, outdated package identification, unused dependency detection, and update strategies for npm, pip, cargo, and go. |
Dependency Audit and Management
Quick Reference
| Task | Approach |
|---|
| Security scan | Run language-specific audit command |
| Find outdated | Check against latest versions |
| Find unused | Analyze imports vs declared dependencies |
| Update safely | Minor/patch first, test, then major |
| Lock files | Always commit lock files |
Package Manager Detection
| File | Package Manager | Audit Command |
|---|
pnpm-lock.yaml | pnpm | pnpm audit |
package-lock.json | npm | npm audit |
yarn.lock | yarn | yarn audit |
bun.lockb | bun | bun audit (if available) |
requirements.txt | pip | pip-audit |
pyproject.toml (with uv) | uv | uv pip audit |
poetry.lock | poetry | poetry audit (via plugin) |
Cargo.lock | cargo | cargo audit |
go.sum | go | govulncheck ./... |
Security Vulnerability Scanning
Node.js
pnpm audit
npm audit
pnpm audit --fix
npm audit fix
npm audit fix --dry-run
npm audit fix --force
Python
pip install pip-audit
pip-audit -r requirements.txt
pip-audit
pip-audit --format json
pip-audit --fix -r requirements.txt
Rust
cargo install cargo-audit
cargo audit
cargo audit fix
Go
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
Outdated Package Detection
Node.js
pnpm outdated
npm outdated
pnpm update --interactive --latest
Python
pip list --outdated
pip-compile --upgrade requirements.in
Rust
cargo install cargo-outdated
cargo outdated
Go
go list -m -u all
go get -u ./...
go mod tidy
Unused Dependency Detection
Node.js
npx depcheck
Python
Manually check: search codebase for each package name in imports.
grep -r "import package_name" src/
grep -r "from package_name" src/
Update Strategy
Safe Update Order
- Patch updates first (1.2.3 -> 1.2.4): Bug fixes, safe to batch
- Minor updates (1.2.3 -> 1.3.0): New features, backward-compatible
- Major updates (1.2.3 -> 2.0.0): Breaking changes, update one at a time
For Each Major Update
- Read the changelog/migration guide
- Update the single package
- Run the full test suite
- Fix any breaking changes
- Commit before moving to the next
Automated Updates
Use Renovate or Dependabot for automated PRs:
Renovate (recommended):
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"],
"schedule": ["on the first day of the month"],
"groupName": "all dependencies",
"groupSlug": "all"
}
Dependabot:
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: monthly
groups:
all-dependencies:
patterns: ["*"]
Lock File Management
| Lock File | Must Commit? | Why |
|---|
package-lock.json | Yes | Ensures reproducible builds |
pnpm-lock.yaml | Yes | Same |
yarn.lock | Yes | Same |
Cargo.lock (binary) | Yes | Reproducible builds for binaries |
Cargo.lock (library) | Debatable | Libraries usually don't commit |
go.sum | Yes | Integrity verification |
poetry.lock | Yes | Reproducible environments |
requirements.txt (pinned) | Yes | Acts as lock file |
Common Issues
| Problem | Solution |
|---|
| Conflicting peer dependencies | Check compatibility matrix, may need --legacy-peer-deps |
| "ERESOLVE unable to resolve" | Peer dependency conflict - check versions |
| Vulnerability in transitive dep | Use overrides (npm) or resolutions (yarn) to force version |
| Lock file conflicts after merge | Delete lock file, reinstall, commit new lock |
pip-audit finds no fix available | Pin to latest patched version or find alternative package |
| Cargo feature conflicts | Check feature flags in Cargo.toml |
Transitive Dependency Overrides
When a vulnerability exists in a transitive (indirect) dependency:
npm/pnpm (package.json)
{
"overrides": {
"vulnerable-package": ">=2.0.1"
}
}
Yarn (package.json)
{
"resolutions": {
"vulnerable-package": ">=2.0.1"
}
}
Anti-Patterns
| Don't | Do Instead |
|---|
| Ignore audit warnings | Triage and fix or document exceptions |
Use * or latest for versions | Pin to specific semver ranges |
| Skip lock files in commits | Always commit lock files |
| Update everything at once | Update in safe order (patch -> minor -> major) |
| Suppress audit exit codes in CI | Fix vulnerabilities or add documented exceptions |
Install from master branch | Use published releases with version numbers |