Agent Skillsqdhenry/Claude-Command-Suite › remove-dead-code

remove-dead-code

GitHub

用于安全识别并清理 TypeScript/JavaScript 项目中的死代码。通过多智能体并行分析与交叉验证,确保在自动备份分支的前提下,仅删除经确认的无用导出、孤立文件或依赖,防止误删。

.claude/skills/remove-dead-code/SKILL.md qdhenry/Claude-Command-Suite

触发场景

清理未使用的导出或导入 检测孤儿文件 移除不可达函数 分析死代码报告

安装

npx skills add qdhenry/Claude-Command-Suite --skill remove-dead-code -g -y
更多选项

非标准路径

npx skills add https://github.com/qdhenry/Claude-Command-Suite/tree/main/.claude/skills/remove-dead-code -g -y

不安装直接使用

npx skills use qdhenry/Claude-Command-Suite@remove-dead-code

指定 Agent (Claude Code)

npx skills add qdhenry/Claude-Command-Suite --skill remove-dead-code -a claude-code -g -y

安装 repo 全部 skill

npx skills add qdhenry/Claude-Command-Suite --all -g -y

预览 repo 内 skill

npx skills add qdhenry/Claude-Command-Suite --list

SKILL.md

Frontmatter
{
    "name": "remove-dead-code",
    "description": "Safely identifies and removes dead code in TypeScript\/JavaScript projects using multi-agent analysis with automatic backup branches. Use when cleaning up unused exports, orphaned files, dead imports, unreachable functions, or unused dependencies."
}

<essential_principles>

Safety-first dead code removal. Every removal is protected by an automatic backup branch. Multi-agent analysis reduces false positives. No code is deleted without cross-validation.

1. Backup Before Everything

Before any modification, create a timestamped backup branch from the current HEAD. This is non-negotiable. The branch name format is backup/dead-code-removal/{timestamp}.

2. Parallel Scout + Validator Pattern

Multiple scout agents analyze different aspects of dead code in parallel. A validator agent then cross-checks all findings against the full codebase before anything is flagged for removal. Only code confirmed dead by both scouts AND validator gets removed.

3. Conservative by Default

When in doubt, keep the code. False negatives (missing some dead code) are acceptable. False positives (removing live code) are not. Dynamic imports, reflection, test utilities, and public API surface are always treated as potentially live.

4. Never Remove Without Reporting First

The scan workflow produces a report. The user reviews the report. Only then does the remove workflow execute against confirmed items.

</essential_principles>

What would you like to do?
  1. Scan - Analyze codebase for dead code (read-only, produces report)
  2. Remove - Remove confirmed dead code (requires prior scan report)
  3. Validate - Verify removal didn't break anything (post-removal checks)

Wait for response before proceeding.

| Response | Workflow | |----------|----------| | 1, "scan", "analyze", "find", "detect", "report" | `workflows/scan-dead-code.md` | | 2, "remove", "delete", "clean", "prune" | `workflows/remove-dead-code.md` | | 3, "validate", "verify", "check", "test" | `workflows/validate-removal.md` | | Unclear | Ask: "Would you like to scan first (recommended) or do you already have a scan report?" |

Default flow: Scan → Review report → Remove → Validate

After reading the workflow, follow it exactly.

<safety_rules>

  • NEVER remove code without creating a backup branch first
  • NEVER remove code that appears in test files as a test subject (test helpers ARE candidates)
  • NEVER remove re-exported types that could be part of a public API
  • NEVER remove files matching patterns: *.config.*, *.setup.*, *.d.ts, entry points
  • ALWAYS preserve code referenced by dynamic imports (import() expressions)
  • ALWAYS preserve code that might be used via string-based lookups or reflection
  • ALWAYS check package.json exports, main, types, and bin fields before removing
  • ALWAYS check framework conventions (Next.js pages/routes, Convex functions, etc.) </safety_rules>

<reference_index> All domain knowledge in references/:

Detection: detection-patterns.md - What to scan for and how to identify dead code Agents: agent-coordination.md - How multi-agent parallel analysis works </reference_index>

<workflows_index>

Workflow Purpose
scan-dead-code.md Multi-agent analysis producing a dead code report
remove-dead-code.md Safe removal with backup branch and atomic commits
validate-removal.md Post-removal build, test, and type-check verification
</workflows_index>

<success_criteria> Dead code removal is successful when:

  • Backup branch exists with pre-removal state
  • All flagged items were cross-validated by multiple agents
  • Build passes after removal (tsc --noEmit, npm run build)
  • All tests pass after removal
  • No new TypeScript errors introduced
  • Removal summary report generated with what was removed and why </success_criteria>

版本历史

  • e89b2f0 当前 2026-08-20 06:58

同 Skill 集合

.claude/skills/audit-env-variables/SKILL.md
.claude/skills/bigcommerce-api/SKILL.md
.claude/skills/elevenlabs-transcribe/SKILL.md
.claude/skills/extract-video-frames/SKILL.md
.claude/skills/file-watcher/SKILL.md
.claude/skills/setup-agent-tail/SKILL.md
.claude/skills/setup-portless/SKILL.md
.claude/skills/webmcp/SKILL.md

元信息

文件数
0
版本
e89b2f0
Hash
64630667
收录时间
2026-08-20 06:58

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-09 18:21
浙ICP备14020137号-1 $访客地图$