一键导入
dead-code-cleanup
Identify and safely remove dead code, deprecated code, and unused exports from codebase. Use when you need to clean up unused or obsolete code.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Identify and safely remove dead code, deprecated code, and unused exports from codebase. Use when you need to clean up unused or obsolete code.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Transform verbose natural language requests into structured bilingual documentation (Korean for review + English for AI prompts). Use when you need to clarify and structure a complex request before implementation.
Review current git changes or latest commit using code-reviewer and architect-reviewer agents. Use after completing code changes to get comprehensive quality feedback.
Review comments and suggest cleanup (identify unnecessary comments, recommend improvements). Use to aggressively clean up comment debt in code.
Generate business rule documentation from domain knowledge and requirements. Use when you need to document complex business logic or domain rules.
Implement UI E2E tests sequentially using Playwright MCP, stop on bug discovery. Use after e2e-ui-research to implement the planned test scenarios.
Fix bugs from e2e-ui-execute bug reports with Playwright MCP verification. Use after discovering bugs during E2E test execution.
| name | dead-code-cleanup |
| description | Identify and safely remove dead code, deprecated code, and unused exports from codebase. Use when you need to clean up unused or obsolete code. |
| allowed-tools | Glob, Grep, Read, Edit, Bash(npm:*), Bash(pnpm:*), Bash(yarn:*), Bash(go:*), Bash(git status:*), Bash(tsc:*), Task |
| disable-model-invocation | true |
Systematically identify and remove unused code while maintaining project integrity.
Target Code:
Critical Constraint: Project must build and pass all tests after cleanup.
$ARGUMENTS
Interpretation:
| Input | Action |
|---|---|
| Empty | Analyze entire codebase |
Path (e.g., src/legacy/) | Analyze specified directory |
--dry-run | Report only, no deletions |
--auto | Delete HIGH confidence items without confirmation |
| Category | Detection Method | Examples |
|---|---|---|
| Public API | package.json exports, index.ts re-exports | Library entry points |
| Planned Features | TODO/FIXME with ticket/issue | // TODO(#123): implement |
| Framework Conventions | Path-based (pages/, app/, api/) | Next.js routes, NestJS modules |
| Test Infrastructure | Imported by *.test.*, *.spec.* | Fixtures, mocks, test utils |
| Dynamic Imports | import(), require() patterns | Lazy loading, code splitting |
| Build Dependencies | Referenced in package.json scripts | Build tools, CLI scripts |
| External Contracts | GraphQL types, API schemas | Schema definitions |
Exported but unused internally:
Deprecated with timeline:
1.1 Detect Project Type
# Framework detection
[ -f "next.config.js" ] && echo "Next.js"
[ -f "tsconfig.json" ] && echo "TypeScript"
[ -f "go.mod" ] && echo "Go"
1.2 Identify Package Scope
# Public library vs private app
grep '"private": false' package.json && echo "PUBLIC_LIBRARY"
1.3 Map Public API Surface
package.json exports fieldindex.ts re-exports2.1 Unused Exports
For each export statement:
2.2 Deprecated Code
grep -rn "@deprecated" --include="*.ts" --include="*.go"
grep -rn "DEPRECATED" --include="*.ts" --include="*.go"
2.3 Orphaned Files
Files not imported anywhere:
For each candidate:
Confidence Classification:
| Level | Criteria | Action |
|---|---|---|
| HIGH | No references, not preserved, clear dead code | Auto-delete (with --auto) |
| MEDIUM | No direct refs, but string/comment mentions | Ask confirmation |
| LOW | Exported publicly, ambiguous usage | Report only |
4.1 Pre-Deletion
# Warn if uncommitted changes
git status --porcelain | grep -q . && echo "⚠️ Uncommitted changes exist"
4.2 Incremental Deletion
4.3 Post-Deletion Verification
# Must pass after each batch
{build_command} # npm run build / go build ./...
{test_command} # npm test / go test ./...
{lint_command} # npm run lint / golangci-lint run
4.4 Rollback on Failure
git checkout -- {failed_files}
# Dead Code Cleanup Report
**Generated**: {timestamp}
**Scope**: {analyzed_paths}
---
## Summary
| Category | Count | Lines |
| --------------- | ------- | ----------- |
| Unused Exports | {n} | {lines} |
| Deprecated Code | {n} | {lines} |
| Orphaned Files | {n} | {lines} |
| **TOTAL** | **{n}** | **{lines}** |
---
## DELETED (HIGH Confidence)
### {file_path}:{line}
- **Type**: {function/class/variable}
- **Reason**: No references found
- **Verification**: Build ✓ Tests ✓
---
## SKIPPED - Needs Review
### {file_path}:{line}
- **Type**: {function/class/variable}
- **Reason**: {why detected as dead}
- **Skip Reason**: {why preserved}
- **Action**: {recommended next step}
---
## PRESERVED (Matched Rules)
### {file_path}:{line}
- **Rule**: {which preservation rule}
- **Detail**: {specifics}
---
## Verification Results
- Build: {PASS/FAIL}
- Tests: {PASS/FAIL} ({passed}/{total})
- Lint: {PASS/FAIL}
# Report only (no deletions)
/dead-code-cleanup --dry-run
# Analyze specific directory
/dead-code-cleanup src/legacy/
# Auto-delete HIGH confidence items
/dead-code-cleanup --auto
# Default: interactive mode
/dead-code-cleanup