一键导入
deps-audit
Audit dependencies for vulnerabilities, staleness, unused packages, and license risks — produce a health report with actionable fixes
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Audit dependencies for vulnerabilities, staleness, unused packages, and license risks — produce a health report with actionable fixes
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Adopt extracted helpers — find dead symbols from forge, wire them into consumers, replace duplicated inline patterns, and gate on dead-symbol delta (Titan Paradigm Phase 4.5)
Adopt extracted helpers — find dead symbols from forge, wire them into consumers, replace duplicated inline patterns, and gate on dead-symbol delta (Titan Paradigm Phase 4.5)
Validate staged changes — codegraph checks + project lint/build/test, auto-rollback on failure, pass/fail commit gate (Titan Paradigm Phase 4)
Audit codebase files against the 4-pillar quality manifesto using RECON work batches, with batch processing and context budget management (Titan Paradigm Phase 2)
Map a codebase's dependency graph, identify hotspots, name logical domains, propose work batches, and produce a ranked priority queue for autonomous cleanup (Titan Paradigm Phase 1)
Local repo maintenance — clean stale worktrees, remove dirt files, sync with main, update codegraph, prune branches, and verify repo health
| name | deps-audit |
| description | Audit dependencies for vulnerabilities, staleness, unused packages, and license risks — produce a health report with actionable fixes |
| argument-hint | [--fix] (optional — auto-fix safe updates) |
| allowed-tools | Bash, Read, Write, Edit, Glob, Grep, Agent |
Audit the project's dependency tree for security vulnerabilities, outdated packages, unused dependencies, and license compliance. Produce a structured report and optionally auto-fix safe updates.
$ARGUMENTS may contain --fix to auto-apply safe updates (patch/minor only)package.json and package-lock.json)node --version — must be >= 20npm --version to capture toolchain info$ARGUMENTS — set AUTO_FIX=true if --fix is presentAUTO_FIX is set: Save the original manifests now, before any npm commands run, so pre-existing unstaged changes are preserved:
git stash push -m "deps-audit-backup" -- package.json package-lock.json
STASH_REF=$(git stash list --format='%gd %s' | grep 'deps-audit-backup' | head -1 | awk '{print $1}')
STASH_REF is non-empty if and only if a stash entry was actually created. Do not use $? — modern git (2.16+) returns 0 even when nothing was stashed.
Use [ -n "$STASH_REF" ] (stash created) / [ -z "$STASH_REF" ] (nothing stashed) for all branching. Use $STASH_REF (not stash@{0}) in all later stash drop/pop commands to avoid targeting the wrong entry.Run npm audit --json and parse the output:
critical, high, moderate, low, infocritical or high vulnerability:
npm audit fix --dry-run --json)If AUTO_FIX is set: Run npm audit fix (non-breaking fixes only). Record what changed. Do NOT run npm audit fix --force — breaking changes require manual review.
Run npm outdated --json and categorize:
dependencies + devDependencies)For each outdated package, record:
Classify each outdated dep:
| Category | Definition |
|---|---|
| Fresh | On latest or within 1 patch |
| Aging | 1+ minor versions behind |
| Stale | 1+ major versions behind |
| Abandoned | No release in 12+ months (check npm registry publish date) |
For any package classified as Abandoned, check if there's a maintained fork or alternative.
If AUTO_FIX is set: Run npm update to apply semver-compatible updates. Record what changed.
Detect dependencies declared in package.json but never imported:
dependencies and devDependencies from package.jsonsrc/, tests/, scripts/, mcp/, graph/, ast-analysis/, cli.js, index.js:
require('<pkg>') or require('<pkg>/...')import ... from '<pkg>' or import '<pkg>'import('<pkg>') (dynamic imports)@anthropic-ai/tokenizer — peer dependency of @anthropic-ai/sdk; the SDK may require it at runtime without an explicit import in our code (verify against package.json before removing)tree-sitter-* and web-tree-sitter — loaded dynamically via WASM@biomejs/biome — used as CLI tool onlycommit-and-tag-version — used as npm script@optave/codegraph-* — platform-specific optional binariesvitest — test runner, invoked via CLIoptionalDependenciesnpm uninstall <pkg>Important: Some deps are used transitively or via CLI — don't blindly remove. Flag as "likely unused" and let the user decide.
Check licenses for all direct dependencies:
dependencies, read its node_modules/<pkg>/package.json → license fieldCheck for duplicate versions of the same package in the dependency tree:
npm ls --all --json and look for packages that appear multiple times with different versionsnpm dedupeWrite a report to generated/deps-audit/DEPS_AUDIT_<date>.md with this structure:
# Dependency Audit Report — <date>
## Summary
| Metric | Value |
|--------|-------|
| Total dependencies (direct) | N |
| Total dependencies (transitive) | N |
| Security vulnerabilities | N critical, N high, N moderate, N low |
| Outdated packages | N stale, N aging, N fresh |
| Unused dependencies | N |
| License risks | N |
| Duplicates | N |
| **Health score** | **X/100** |
## Health Score Calculation
- Start at 100
- -20 per critical vuln, -10 per high vuln, -3 per moderate vuln
- -5 per stale (major behind) dep, -2 per aging dep
- -5 per unused dep
- -10 per copyleft license risk
- Floor at 0
## Security Vulnerabilities
<!-- Detail each critical/high vuln with remediation -->
## Outdated Packages
<!-- Table: package, current, latest, category, notes -->
## Unused Dependencies
<!-- List with evidence (no imports found) -->
## License Flags
<!-- Only non-permissive licenses -->
## Duplicates
<!-- Only significant ones -->
## Recommended Actions
<!-- Prioritized list: fix vulns > remove unused > update stale > dedupe -->
--fix)If AUTO_FIX was set:
Summarize all changes made:
npm test to verify nothing brokeSTASH_REF is non-empty: pop and merge the saved state (git stash pop $STASH_REF) — this restores any pre-existing uncommitted changes alongside the npm fix results. Note: the step 2 test run validated the npm changes alone; step 3b below is the authoritative test of the final merged state.
npm install to re-sync node_modules/ with the merged manifest.
b. Re-run npm test to confirm the merged state is consistent (this is the authoritative check — step 2 only validated the npm changes in isolation).
c. If tests still pass: confirm the project is consistent.
d. If tests now fail: warn the user — the pre-existing manifest changes conflict with the audit fixes.
Recovery options:
git checkout -- package.json package-lock.json && npm cipackage.json/package-lock.json to remove the pre-existing delta, then npm cigit checkout HEAD -- package.json package-lock.json && npm ci to revert manifests to their clean state, then manually re-apply only your pre-existing changespackage.json/package-lock.json: warn the user, leave conflict markers for manual resolution, and instruct: "After you resolve the conflicts, run npm install to re-sync node_modules/ with the resolved lock file before committing."STASH_REF is empty: no action needed — the npm changes are good and no stash entry exists to clean upSTASH_REF is non-empty:
git checkout HEAD -- package.json package-lock.jsongit stash pop $STASH_REFnode_modules/ to match the reverted lock file: npm ciSTASH_REF is empty:
git checkout -- package.json package-lock.jsonnode_modules/ to match the reverted lock file: npm cinpm audit fix --force — breaking changes need human review--fix causes test failures, first reset manifests to HEAD (git checkout HEAD -- package.json package-lock.json), then re-apply pre-existing changes (git stash pop $STASH_REF if STASH_REF is non-empty, or no-op if nothing was stashed), then run npm ci to resync node_modules/, and report the failureoptionalDependencies separately — they're expected to fail on some platformsgenerated/deps-audit/ — create the directory if it doesn't exist