AgentSkillsCN

clean-deadcode

通过测试验证,安全识别并移除冗余代码。当用户提及“死代码”“未使用的代码”“清理未使用的代码”“移除死代码”,或提出查找并移除未使用的导出项、函数、文件或依赖项时,即可触发此技能。

SKILL.md
--- frontmatter
name: clean-deadcode
description: Safely identify and remove dead code with test verification. Trigger when user says "dead code", "unused code", "clean up unused", "remove dead code", or requests finding/removing unused exports, functions, files, or dependencies.

Clean Deadcode

Workflow

  1. Determine the dead code analysis tool to use:

    • Check project config files (AGENTS.md, CLAUDE.md, README, Makefile, etc.) for tooling conventions
    • If not found, ask the user which tool to use
  2. Run the tool and collect results.

  3. Categorize findings by severity:

    • SAFE: Unused utilities, helpers, test files
    • CAUTION: API routes, components (may have external consumers)
    • DANGER: Config files, main entry points (never delete)
  4. Generate a report at .reports/dead-code-analysis.md with all findings and their categories.

  5. Delete SAFE items only. For each deletion:

    • Apply the change
    • Run the test suite
    • Roll back if tests fail
  6. Summarize cleaned items and any CAUTION items for user review.

Hard Rule

Never delete code without running tests after each change.