NPM Package Scanner
Use this skill when you need to inspect the npm packages used by a repository and identify security, maintenance, and dependency risks.
Goal
Produce a practical package-risk review for the current repository:
- - what dependencies are installed
- which ones are direct vs transitive
- which ones look stale, risky, or unnecessary
- whether there are known audit issues
- whether version ranges are too loose or outdated
Scope
Focus on:
- - INLINECODE0
- lockfiles such as
package-lock.json, bun.lock, pnpm-lock.yaml, or INLINECODE4 - workspace package manifests
- scripts that introduce package/tooling risk
- duplicated or overlapping dependencies
Use the reference notes in references/checklist.md and references/commands.md when useful.
Workflow
- 1. Find package manifests and lockfiles.
- Read the root
package.json and any workspace manifests. - List direct dependencies and devDependencies.
- Check for:
- very old package versions
- abandoned or suspicious packages
- duplicate packages solving the same problem
- unnecessary runtime dependencies
- risky postinstall/build hooks
- overly broad semver ranges
- 5. Run available package-manager audit commands if appropriate.
- Summarize findings by severity.
- Recommend concrete next steps.
Commands
Prefer fast repo inspection first:
CODEBLOCK0
Inspect manifests:
CODEBLOCK1
If using Bun:
CODEBLOCK2
If using npm:
CODEBLOCK3
If using pnpm:
CODEBLOCK4
If using yarn:
CODEBLOCK5
Output format
Return:
- 1. High-risk findings
- Medium-risk findings
- Low-risk cleanup items
- Packages worth upgrading soon
- Packages that may be removable
- Exact commands to verify or fix
Review rules
- - Prioritize real risk over noise.
- Distinguish direct dependencies from transitive ones.
- Do not recommend upgrades blindly; mention likely blast radius.
- If audit output is noisy, extract only actionable items.
- If no serious issues are found, say so explicitly.
Constraints
- - Do not modify dependency versions unless explicitly asked.
- Do not remove packages unless explicitly asked.
- Do not assume a package is abandoned without evidence from the repo context or audit/tool output.
NPM 包扫描器
当需要检查仓库使用的 npm 包并识别安全、维护和依赖风险时,使用此技能。
目标
为当前仓库生成一份实用的包风险评估报告:
- - 安装了哪些依赖
- 哪些是直接依赖,哪些是传递依赖
- 哪些依赖看起来过时、存在风险或不必要
- 是否存在已知的审计问题
- 版本范围是否过于宽松或过时
范围
重点关注:
- - package.json
- 锁定文件,如 package-lock.json、bun.lock、pnpm-lock.yaml 或 yarn.lock
- 工作区包清单
- 引入包/工具风险的脚本
- 重复或重叠的依赖
必要时可参考 references/checklist.md 和 references/commands.md 中的参考说明。
工作流程
- 1. 查找包清单和锁定文件。
- 读取根目录下的 package.json 以及任何工作区清单。
- 列出直接依赖和开发依赖。
- 检查以下内容:
- 非常旧的包版本
- 已废弃或可疑的包
- 解决同一问题的重复包
- 不必要的运行时依赖
- 存在风险的 postinstall/build 钩子
- 过于宽泛的 semver 范围
- 5. 如果合适,运行可用的包管理器审计命令。
- 按严重程度总结发现的问题。
- 推荐具体的后续步骤。
命令
优先进行快速的仓库检查:
bash
rg --files | rg (^|/)(package\.json|package-lock\.json|bun\.lock|pnpm-lock\.yaml|yarn\.lock)$
检查清单:
bash
cat package.json
如果使用 Bun:
bash
bun pm ls
bun audit
如果使用 npm:
bash
npm ls --depth=0
npm audit
如果使用 pnpm:
bash
pnpm ls --depth=0
pnpm audit
如果使用 yarn:
bash
yarn list --depth=0
yarn audit
输出格式
返回:
- 1. 高风险发现
- 中风险发现
- 低风险清理项
- 建议尽快升级的包
- 可能可以移除的包
- 用于验证或修复的具体命令
审查规则
- - 优先关注真实风险,而非无关信息。
- 区分直接依赖和传递依赖。
- 不要盲目推荐升级;需提及可能的影响范围。
- 如果审计输出信息过多,只提取可操作项。
- 如果未发现严重问题,需明确说明。
约束条件
- - 除非明确要求,否则不要修改依赖版本。
- 除非明确要求,否则不要移除包。
- 除非有来自仓库上下文或审计/工具输出的证据,否则不要假定某个包已废弃。