Loading...
Loading...
Managing third-party dependencies — version pinning, security auditing, license compliance, update workflows, lockfile management, supply chain security. Activate on "npm audit", "dependabot", "renovate", "pin versions", "dependency update", "supply chain", "license compliance", "lockfile", "security advisory", "typosquatting", "SBOM". NOT for internal monorepo package management (use monorepo-management) or publishing your own packages to npm/PyPI.
npx skill4agent add erichowens/some_claude_skills dependency-managementnpm auditpip auditmonorepo-managementflowchart TD
Start[Want to add a dependency?] --> Size{How much code does it replace?}
Size -->|< 20 lines| Write[Write it yourself]
Size -->|20-200 lines| Q2{Trivial to implement correctly?}
Size -->|> 200 lines| Q3{Check the package}
Q2 -->|Yes, pure logic| Write
Q2 -->|No, edge cases / locale / timezone| Q3
Q3 --> Audit{Run audit checks}
Audit --> Downloads{Weekly downloads?}
Downloads -->|< 10k| HighRisk[High risk: low adoption]
Downloads -->|10k-100k| MedRisk[Medium: check actively]
Downloads -->|> 100k| Maintained{Actively maintained?}
Maintained -->|Last commit > 2 years| Fork[Consider fork or alternative]
Maintained -->|Recent commits| License{License compatible?}
License -->|GPL in proprietary| Reject[REJECT: license issue]
License -->|MIT / Apache 2.0| Security{npm audit / Socket.dev scan?}
Security -->|CVEs unfixed| Reject
Security -->|Clean| Transitive{Transitive dep count?}
Transitive -->|> 50 new deps| Reconsider[Reconsider: high blast radius]
Transitive -->|< 50 new deps| Accept[Add with pinned version]
HighRisk --> Fork
MedRisk --> Maintained^1.2.3 = >= 1.2.3, < 2.0.0 (minor + patch updates allowed)
~1.2.3 = >= 1.2.3, < 1.3.0 (patch updates only)
1.2.3 = exactly 1.2.3 (locked)
* = any version (never use)| Strategy | Where | Reasoning |
|---|---|---|
Exact pinning ( | Production apps | Reproducible builds; lockfile provides flexibility |
Tilde ( | Libraries you publish | Patch safety; minor versions may break consumers |
Caret ( | Dev tooling only | Acceptable churn for formatters, linters |
| Lockfile as truth | All production | |
Never | Anywhere | Catastrophic: installs whatever is latest at build time |
^npm installnpm cipackage.json^npm ciflowchart TD
Update[How to handle updates?] --> Auto{Use automation?}
Auto -->|Yes| Tool{Which tool?}
Auto -->|No, manual| Manual[Monthly audit: npm outdated / pip list --outdated]
Tool -->|GitHub repo| Dependabot[GitHub Dependabot]
Tool -->|Any platform| Renovate[Renovate Bot — more powerful]
Dependabot --> DConfig[Configure .github/dependabot.yml]
Renovate --> RConfig[Configure renovate.json]
DConfig --> DGroup{Group updates?}
RConfig --> RGroup{Group updates?}
DGroup -->|Yes| DGrouped[Group patch updates together]
DGroup -->|No| DPR[One PR per dependency]
RGroup -->|Yes| RGrouped[Group by type: devDeps patch / prod minor]
RGroup -->|No| RPR[One PR per dependency]
RGrouped --> AutoMerge{Automerge safe?}
DGrouped --> AutoMerge
AutoMerge -->|Dev deps + patch only| EnableAM[Enable automerge with test gate]
AutoMerge -->|Prod deps, major versions| RequireReview[Require human review]# 1. npm audit (built-in, free, fast — checks known CVEs)
npm audit
npm audit --audit-level=high # Only high+ severity
npm audit fix # Auto-fix where possible
npm audit fix --force # ⚠️ May break API — review first
# 2. pip audit (Python equivalent)
pip install pip-audit
pip-audit
pip-audit --fix # Write fixed requirements.txt
# 3. Socket.dev (supply chain analysis beyond CVEs)
npx socket check # Checks for malicious behavior, typosquatting
# 4. Snyk (deeper analysis, CI integration)
npx snyk test
npx snyk monitor # Continuous monitoring
# 5. SBOM generation (for compliance)
npx @cyclonedx/cyclonedx-npm --output-format json > sbom.json
# Python: pip install cyclonedx-bom && cyclonedx-py -pnpm ls <package>npm audit --productionnpm ls <vulnerable-pkg>lodash1odashexpressexpresreactReact@org/packageorg-package# Socket.dev catches most of these
npx socket check
# Manual: verify before install
npm view <package-name> # Check metadata: author, description, repo URL
npm view <package-name> repository # Verify GitHub repo matches official source@org/package# npm: Use .npmrc scoped registry config
@your-org:registry=https://your-private-registry.example.com
# Or set resolutions/overrides to lock the source
# package.json:
{
"overrides": {
"@your-org/internal-package": "npm:@your-org/internal-package@^1.0.0"
}
}# Never commit node_modules — commit only the lockfile
# Verify lockfile integrity after pulls
npm ci # Fails if lockfile doesn't match package.json
# NEVER use npm install in CI
# Python: use pip-compile for deterministic locks
pip install pip-tools
pip-compile requirements.in # Generates pinned requirements.txt
pip-sync requirements.txt # Install exactly this| Your Project | MIT dep | Apache 2.0 dep | LGPL dep | GPL dep |
|---|---|---|---|---|
| Proprietary | OK | OK (attribution) | OK (dynamic link) | REJECT |
| MIT/Apache | OK | OK | OK | Complicated |
| GPL | OK | OK | OK | OK |
# Scan all licenses in your dependency tree
npx license-checker --production --onlyAllow "MIT;Apache-2.0;BSD-2-Clause;BSD-3-Clause;ISC;0BSD"
npx license-checker --production --failOn "GPL;AGPL"
# Python
pip install pip-licenses
pip-licenses --format=markdown --order=licensenpm install is-oddn % 2 !== 0npx cost-of-modulespolyfill.io// package.json — npm overrides (npm 8.3+)
{
"overrides": {
"semver": ">=7.5.2", // Force minimum version across all deps
"lodash": "4.17.21", // Force exact version
"vulnerable-pkg": {
"sub-dependency": "^2.0.0" // Scoped: only for this parent
}
}
}// package.json — yarn/pnpm resolutions
{
"resolutions": {
"semver": ">=7.5.2"
}
}# Check what peer deps a package needs
npm info <package> peerDependencies
# npm 7+ auto-installs peer deps (may surprise you with version conflicts)
# Opt out: npm install --legacy-peer-deps (last resort)
# Check for peer dep conflicts
npm install 2>&1 | grep "peer dep"
npm ls 2>&1 | grep "WARN" | grep "peer"references/update-strategies.mdreferences/security-auditing.md