| name | dependency-audit |
| description | Dependency audit and cleanup workflow for maintaining healthy project dependencies. Use for regular maintenance, security updates, and removing unused packages. |
| user-invocable | false |
| disable-model-invocation | true |
| progressive_disclosure | {"entry_point":["summary","when_to_use","quick_audit_process"],"sections":["audit_commands","priority_matrix","common_replacements","update_strategy","cleanup_workflow","security_scanning","open_source_safety"],"references":["open-source-safety.md"]} |
Dependency Audit Skill
Summary
Systematic workflow for auditing, updating, and cleaning up project dependencies. Covers security vulnerability scanning, outdated package detection, unused dependency removal, and migration from deprecated libraries.
When to Use
- Weekly/monthly dependency maintenance
- After security advisories (CVE announcements)
- Before major releases
- When bundle size increases unexpectedly
- During code reviews for dependency changes
- Onboarding to legacy projects
Quick Audit Process
1. Check Outdated Packages
npm outdated
pnpm outdated
yarn outdated
pip list --outdated
poetry show --outdated
2. Security Vulnerability Scan
npm audit
npm audit fix
npm audit fix --force
pnpm audit
pnpm audit --fix
yarn audit
yarn audit --fix
pip-audit
safety check
3. Find Unused Dependencies
npx depcheck
pip-autoremove --list
Audit Commands
JavaScript/TypeScript/Node.js
npm
npm outdated
npm update
npm install package@latest
npm audit
npm audit fix
npm list
npm list --depth=0
npm ls package-name
npm dedupe
pnpm
pnpm outdated
pnpm update
pnpm update package@latest
pnpm audit
pnpm dedupe
pnpm list
yarn
yarn outdated
yarn upgrade-interactive
yarn upgrade
yarn audit
yarn why package-name
Python
pip
pip list --outdated
pip install --upgrade package-name
pip-audit
pip freeze > requirements.txt
pip show package-name
poetry
poetry show --outdated
poetry update
poetry update package-name
poetry audit
poetry show --tree
pipenv
pipenv check
pipenv update
pipenv update package-name
pipenv graph
Priority Matrix
| Priority | Type | Action | Timeline | Example |
|---|
| P0 | Critical CVE (actively exploited) | Patch immediately | Same day | Auth bypass, RCE |
| P1 | High CVE or major framework update | Plan migration | 1-2 weeks | Next.js, React major version |
| P2 | Deprecated with active usage | Find replacement | 2-4 weeks | moment.js → date-fns |
| P3 | Minor/patch updates | Batch update | Monthly | Non-breaking updates |
| P4 | Unused dependencies | Remove | Next cleanup PR | Dead imports |
Priority Decision Tree
Is there a CVE?
├─ Yes → Is it critical/high severity?
│ ├─ Yes → P0 (patch immediately)
│ └─ No → P1 (plan update)
└─ No → Is package deprecated?
├─ Yes → Is it actively used?
│ ├─ Yes → P2 (find replacement)
│ └─ No → P4 (remove)
└─ No → Is it outdated?
├─ Major version → P1 (plan migration)
├─ Minor/patch → P3 (batch update)
└─ Unused → P4 (remove)
Common Replacements
Date/Time Libraries
JavaScript/TypeScript
import moment from 'moment';
const formatted = moment().format('YYYY-MM-DD');
const diff = moment(date1).diff(moment(date2), 'days');
import { format, differenceInDays } from 'date-fns';
const formatted = format(new Date(), 'yyyy-MM-dd');
const diff = differenceInDays(date1, date2);
const formatted = new Intl.DateTimeFormat('en-US').format(new Date());
const relative = new Intl.RelativeTimeFormat('en').format(-1, 'day');
Python
import arrow
now = arrow.now().format('YYYY-MM-DD')
from datetime import datetime
now = datetime.now().strftime('%Y-%m-%d')
import pendulum
now = pendulum.now('America/New_York')
Utility Libraries
JavaScript/TypeScript
import _ from 'lodash';
const value = _.get(obj, 'path.to.value');
const unique = _.uniq(array);
import get from 'lodash/get';
import uniq from 'lodash/uniq';
const value = obj?.path?.to?.value;
const unique = [...new Set(array)];
const keys = Object.keys(obj);
const flat = array.flat();
const grouped = Object.groupBy(arr, fn);
HTTP Clients
JavaScript/TypeScript
import axios from 'axios';
const { data } = await axios.get('/api/users');
const response = await fetch('/api/users');
const data = await response.json();
import ky from 'ky';
const data = await ky.get('/api/users').json();
Python
import requests
response = requests.get('https://api.example.com')
import httpx
async with httpx.AsyncClient() as client:
response = await client.get('https://api.example.com')
from urllib.request import urlopen
response = urlopen('https://api.example.com')
Testing Libraries
JavaScript/TypeScript
Validation Libraries
JavaScript/TypeScript
import * as yup from 'yup';
import Joi from 'joi';
import { z } from 'zod';
import { z } from 'zod';
const schema = z.object({
email: z.string().email(),
age: z.number().min(0)
});
Update Strategy
Batch Related Updates
pnpm update eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
pnpm update vitest @vitest/ui @vitest/coverage-v8
pnpm update next react react-dom @types/react @types/react-dom
Test After Updates
Comprehensive Testing Checklist
pnpm tsc --noEmit
pnpm lint
pnpm test
pnpm build
pnpm dev
pnpm test:e2e
Incremental Update Strategy
For Major Version Updates
git checkout -b chore/update-nextjs-15
pnpm install
pnpm test && pnpm build
git add .
git commit -m "chore: upgrade Next.js to v15"
Cleanup Workflow
Step 1: Identify Unused Dependencies
npx depcheck
Example Output:
Unused dependencies
* lodash
* moment
* old-library
Unused devDependencies
* @types/old-package
* unused-test-lib
Step 2: Verify Not Used
rg "from 'lodash'" --type ts
rg "import.*lodash" --type ts
rg "require\('lodash'\)" --type js
Step 3: Remove Package
pnpm remove lodash
Step 4: Update Lock File
rm package-lock.json
npm install
rm pnpm-lock.yaml
pnpm install
rm yarn.lock
yarn install
Step 5: Test
pnpm test
pnpm build
Cleanup PR Template
## Dependency Cleanup
### Security Updates (P0/P1)
- [ ] `next`: 14.0.4 → 14.2.3 (CVE-2024-XXXX)
- [ ] `jose`: 4.15.4 → 4.15.5 (CVE-2024-YYYY)
### Removed (Unused)
- [ ] `lodash` - replaced with native JS methods
- [ ] `moment` - replaced with date-fns
- [ ] `@types/old-package` - package no longer used
### Updated (Maintenance)
- [ ] `eslint`: 8.57.0 → 9.0.0
- [ ] `typescript`: 5.3.3 → 5.4.2
### Migration Notes
**lodash → Native**:
- `_.get()` → optional chaining `obj?.prop?.value`
- `_.uniq()` → `[...new Set(array)]`
**moment → date-fns**:
- `moment().format('YYYY-MM-DD')` → `format(new Date(), 'yyyy-MM-dd')`
### Testing
- [ ] All tests pass (`pnpm test`)
- [ ] Build succeeds (`pnpm build`)
- [ ] No runtime errors in dev (`pnpm dev`)
- [ ] E2E tests pass (if applicable)
### Bundle Size Impact
- Before: 2.4 MB
- After: 1.8 MB
- **Savings: 600 KB (25% reduction)**
Security Scanning
Automated Security Checks
GitHub Actions
name: Security Audit
on:
schedule:
- cron: '0 0 * * 1'
pull_request:
push:
branches: [main]
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Run security audit
run: npm audit --audit-level=high
- name: Check for outdated packages
run: npm outdated
Snyk Integration
name: Snyk Security
on: [push, pull_request]
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/node@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
Manual Security Commands
npm audit
npm audit --audit-level=high
npm audit --json > audit-report.json
snyk test
snyk monitor
snyk wizard
npx socket-npm audit
CVE Response Process
-
Notification: Receive security advisory (GitHub, npm, Snyk)
-
Assess Impact:
npm ls vulnerable-package
rg "vulnerableFunction" --type ts
-
Patch:
npm install vulnerable-package@4.15.5
npm update parent-package
-
Verify Fix:
npm audit
-
Test & Deploy:
pnpm test && pnpm build
git commit -m "fix: patch CVE-2024-XXXX in vulnerable-package"
Open Source Safety
Vulnerability scanning answers "is it vulnerable?" — but third-party risk has three
independent dimensions. Gate on the worst of them, not just CVEs:
- License risk — IP/legal exposure by license type:
- HIGH: strong copyleft (
GPL-2.0/3.0, AGPL-3.0, LGPL-2.1/3.0) — risk of
disclosing your whole application's source. Block in distributed/commercial products.
- MEDIUM: weak copyleft (
MPL-2.0, EPL-1.0) — only modifications to the
component's files must be disclosed. OK if used unmodified.
- LOW: permissive (
MIT, Apache-2.0, BSD) — attribution only.
- UNKNOWN (
NOASSERTION): treat as HIGH until the license is identified.
- CVE weighting — weight by severity (critical ≫ high ≫ medium ≫ low), not raw
counts; this refines the P0–P4 priority matrix above.
- Obsolescence — score the version gap to latest; a dependency a major version (or
more) behind, or with an unmaintained upstream, is elevated risk.
npx license-checker --failOn "GPL-3.0;AGPL-3.0;LGPL-3.0"
pip-licenses --fail-on "GPL-3.0;AGPL-3.0"
Add to the monthly checklist: no new HIGH-tier or UNKNOWN licenses; critical/high CVEs
blocked, medium/low tracked with owner + expiry; nothing more than one major behind
without a migration plan.
See references/open-source-safety.md for the full
framework — tier tables, the CVE weighting model, obsolescence scoring, and the
transitive-dependency ("friends of your friends") trust model.
Derived from CAST Highlight's Open Source Safety methodology
(https://doc.casthighlight.com/); license tiers align with
https://choosealicense.com/appendix/.
Summary
Monthly Maintenance Checklist
## Dependency Maintenance - [YYYY-MM]
### Security
- [ ] Run `npm audit` and address high/critical issues
- [ ] Review GitHub security advisories
- [ ] Check Snyk dashboard (if integrated)
### Updates
- [ ] Check `npm outdated` for major updates
- [ ] Update patch versions: `npm update`
- [ ] Plan migration for deprecated packages
### Cleanup
- [ ] Run `npx depcheck` to find unused deps
- [ ] Remove packages with zero imports
- [ ] Deduplicate: `npm dedupe`
### Testing
- [ ] Run full test suite
- [ ] Check build succeeds
- [ ] Verify dev server works
- [ ] Test in production-like environment
### Documentation
- [ ] Update CHANGELOG.md
- [ ] Document breaking changes
- [ ] Update .env.example if needed
Best Practices
- Automate: Set up GitHub Actions for weekly audits
- Batch Updates: Group related dependency updates
- Test Thoroughly: Never skip tests after updates
- Document: Keep CHANGELOG.md updated
- Measure Impact: Track bundle size changes
- Stay Informed: Subscribe to security advisories
- Use Lock Files: Commit package-lock.json/pnpm-lock.yaml
- Gradual Migration: Don't update everything at once