analysis-orchestrator
Orchestrate a full codebase analysis using all static analysis tools (knip, dependency-cruiser, jscpd) and synthesize findings.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Orchestrate a full codebase analysis using all static analysis tools (knip, dependency-cruiser, jscpd) and synthesize findings.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Find copy-pasted code blocks and similar patterns using jscpd. Use when asked to find duplicate code, identify refactoring targets, or check if a utility should be extracted because it appears in multiple places.
Find unused files, exports, types, and package dependencies using knip. Use when asked to find dead code, unused exports, or files that can be deleted.
Find copy-pasted code blocks and similar patterns using jscpd. Use when asked to find duplicate code, identify refactoring targets, or check if a utility should be extracted because it appears in multiple places.
Orchestrate a full codebase analysis using all static analysis tools (knip, dependency-cruiser, jscpd) and synthesize findings.
Find unused files, exports, types, and package dependencies using knip. Use when asked to find dead code, unused exports, or files that can be deleted.
| name | analysis-orchestrator |
| description | Orchestrate a full codebase analysis using all static analysis tools (knip, dependency-cruiser, jscpd) and synthesize findings. |
| compatibility | Requires pnpm. Works with TypeScript/JavaScript projects including Next.js, React, Node.js. |
| metadata | {"author":"codebase-analysis-agent","version":"1.0"} |
Coordinate all static analysis tools and synthesize their output into a unified picture of codebase health.
# Run everything
pnpm analyze:all
# Or individually per tool
pnpm analyze:deps:validate
pnpm analyze:dead
pnpm analyze:dupes
pnpm analyze:deps:validate
Expected clean output:
✔ no dependency violations found
If violations appear, investigate before proceeding.
pnpm analyze:dead
knip exits code 1 when findings exist — this is expected, not a failure.
pnpm analyze:dupes
HTML reports are written to /tmp/jscpd-report/html/. Open them for detailed side-by-side diff views.
After running all tools, look for cross-tool patterns:
Pattern A: Bypassed utility
knip: "helperFn" — unused export
jscpd: helperFn clones inline code elsewhere
→ A utility exists, nobody imports it, and the logic was written inline elsewhere.
Pattern B: Missing route or export
knip: "getItemById" — unused export
(no matching route/handler)
→ A service function was written but never wired up.
Pattern C: Orphaned feature
knip: multiple unused exports in same file cluster
jscpd: no clones (unique implementations)
→ A complete subsystem with no callers.
Use a findings document (e.g., docs/ANALYSIS_FINDINGS.md). When updating it:
| Signal | Meaning | Action |
|---|---|---|
| knip unused + jscpd duplicate | Bypassed utility | Wire the caller to use the utility |
| knip unused + no route | Missing route | Add the route, don't delete the service |
| knip multiple unused + no clones | Orphaned subsystem | Document as future feature |
app/page.tsx, app/layout.tsx, app/route.tscomponents/**/*.tsxhooks/**/*.ts, hooks/**/*.tsxapp/actions.ts, lib/actions.tsapp/ are entry points via routing, not importspages/_app.tsx, pages/_document.tsxpages/api/**/*.tscomponents/**/*.tsxsrc/index.tssrc/components/**/*.tsxsrc/hooks/**/*.ts, src/hooks/**/*.tsxsrc/lib/**/*.tssrc/index.ts, src/main.tshandlers/ → actions/ → services/components/ui/ in jscpd (auto-generated boilerplate)cn() utilitylib/utils.ts uses template strings for class names - knip won't trace these### P[N] — [Short description]
**File**: `path/to/file.ts:line`
**Status**: [A | B | B (bypassed) | C]
[What the symbol/function does]
[What the tool output showed]
[Why this matters]
**Action needed**: [Specific recommended fix]
Before marking anything as new, check existing findings:
**Codebase Analysis — [project name]**
**Run date**: 2026-03-29
**Architecture**: ✔ No violations
**Dead code summary**:
- N unused files, N unused exports, N unused dependencies
**New findings since last run**: [symbols not previously documented]
**Previously documented findings still open**:
- P1: [description]
- P2: [description]
**Cross-tool signals**:
- [Any bypassed utility patterns]
**Recommendation**: [highest priority action]
See docs/ANALYSIS_FINDINGS.md for full details.
See individual skill docs for:
.jscpd.json — Duplicate code detection configknip.json — Dead code analysis config.dependency-cruiser.cjs — Architecture validation configFor Next.js App Router projects, use these recommended settings:
{
"format": ["typescript", "tsx"],
"output": "/tmp/jscpd-app",
"ignore": [
"**/__tests__/**",
"**/*.test.tsx",
"**/node_modules/**",
"app/**/page.tsx",
"app/**/layout.tsx",
"components/ui/**"
]
}
{
"entry": ["app/page.tsx", "app/layout.tsx", "app/route.ts"],
"project": ["app/**/*.ts", "app/**/*.tsx", "components/**/*.ts", "components/**/*.tsx", "lib/**/*.ts"],
"ignore": ["components/ui/**", "app/**/page.tsx", "app/**/layout.tsx", "app/**/not-found.tsx", "app/**/error.tsx", "**/__tests__/**"],
"ignoreDependencies": ["clsx", "tailwind-merge", "class-variance-authority"],
"ignoreExportsUsedInFile": true
}
module.exports = {
forbidden: [
{
name: "no-circular",
severity: "error",
from: {},
to: { circular: true }
}
],
options: {
doNotFollow: { path: "node_modules" },
tsConfig: { fileName: "tsconfig.json" }
}
};