Token导航 LogoToken导航TokenDH.com
研究检索执行命令github未标认证来源可访问许可证需确认审计通过

dead-code-sweep死代码扫描

Agent Skill

dead-code-sweep 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

190

周安装

8

GitHub Stars

35

下载量

67
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:dead-code-sweep(死代码扫描)
来源仓库:https://github.com/petekp/claude-code-setup
仓库路径:skills/dead-code-sweep
安装命令:
npx skills add https://github.com/petekp/claude-code-setup --skill dead-code-sweep
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/petekp/claude-code-setup --skill dead-code-sweep

简介

用于查找、检索和筛选相关信息。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

  • 适合根据关键词或任务场景快速定位候选结果。
  • 可结合来源仓库和原始 README 核验具体用法。
  • 安装前建议确认权限范围和维护状态。
  • dead-code-sweep 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Dead Code Sweep

Systematic identification and removal of dead code, redundant implementations, and orphaned artifacts in codebases — particularly those maintained by coding agents with limited context windows.

Why Agent-Maintained Codebases Accumulate Cruft

Coding agents operate within narrow context windows. When refactoring, they often:

  • Re-implement functionality without finding and removing the original
  • Leave compatibility shims for interfaces that no longer exist
  • Abandon helper functions after inlining their logic
  • Create new files without deleting the ones they replace
  • Duplicate type definitions across module boundaries
  • Leave imports for symbols they stopped using mid-refactor

This cruft compounds. Each orphaned artifact misleads the next agent (or human), who wastes context budget reading code that does nothing.

Workflow

Phase 1: Scope and Inventory

Determine the analysis boundary.

If the user provides a scope (directory, file pattern, module), constrain all analysis to that scope.

If no scope is provided, analyze the full codebase. Start by reading the project structure:

  1. Identify the primary language(s) and framework(s)
  2. Map entry points (main files, route definitions, exported modules, test runners)
  3. Note the build system and dependency configuration
  4. Check for monorepo structure — analyze each package as a unit

Produce a brief inventory:

Language(s): TypeScript, Python
Entry points: src/index.ts, src/cli.ts
Build: esbuild via package.json scripts
Packages: 1 (single package)
Estimated LOC: ~4,200

Phase 2: Detection

Launch parallel sub-agents to scan for different categories of dead code. Read references/cruft-patterns.md for the full catalog of detection patterns.

Organize detection into these parallel tracks:

TrackWhat It Finds
Orphaned filesFiles not imported, required, or referenced by any other file
Unused exportsExported symbols (functions, classes, types, constants) never imported elsewhere
Redundant implementationsMultiple functions/classes doing the same thing under different names
Stale compatibility codeShims, adapters, wrappers, and re-exports that bridge interfaces that no longer differ
Dead branchesConditional paths that can never execute (always-true/false guards, unreachable returns)
Orphaned testsTest files testing functions or modules that no longer exist
Orphaned dependenciesPackages in dependency manifests not imported anywhere in source

For each track, the sub-agent should:

  1. Read references/cruft-patterns.md for detection strategies specific to that track
  2. Search the codebase using Grep and Glob
  3. Verify each candidate by tracing references — a symbol is only dead if zero live code paths reach it 3b. Search CI scripts and shell test fixtures for path references to the candidate: rg <filename> -- scripts/ tests/.github/. Files consumed as ratchet-check arguments or Bats test fixtures are NOT dead even if zero source files import them.
  4. Record findings with file path, line range, and evidence

Verification is critical. Common false positives to watch for:

  • Symbols used via dynamic dispatch, reflection, or string-based lookups
  • Framework-magic exports (e.g., Next.js page components, pytest fixtures, Rails conventions)
  • Public API surface intended for external consumers
  • Conditional imports behind feature flags or environment checks
  • Decorator-registered or plugin-registered handlers
  • CLI entry points referenced in package.json bin fields
  • CSS class names referenced in templates or JSX as dynamic strings
  • CI scripts and shell test fixtures that reference files by path — e.g., check_file_contains "name" "path/to/file" in scripts/ci/, or cat "$PROJECT_ROOT/path/to/file" in tests/**/*.bats. These are string arguments, not imports, so import-tracing tools miss them entirely.

When uncertain, mark as "needs review" rather than "confirmed dead."

Phase 3: Report

Consolidate all findings into a structured report at .claude/dead-code-report.md.

Organize findings by confidence level, then by category:

# Dead Code Sweep Report

**Scope:** [full codebase | specific path]
**Date:** [date]
**Estimated removable lines:** [count]

## Confirmed Dead (high confidence)

### Orphaned Files
- `src/utils/old-parser.ts` — Not imported anywhere. Superseded by `src/parser/index.ts`.
- ...

### Unused Exports
- `formatDate()` in `src/helpers.ts:42-58` — Exported but zero imports across codebase.
- ...

[...other categories...]

## Needs Review (uncertain)

### Possibly Dynamic
- `handleLegacyEvent()` in `src/events.ts:91` — No static imports, but may be registered dynamically.
- ...

For each finding, include:

  • File path and line range
  • What it is (function, class, file, type, constant, dependency)
  • Why it appears dead (no imports, no references, superseded by X)
  • Confidence (confirmed / needs review)

Phase 4: Cleanup with Approval

Present the report summary to the user and ask for approval before removing anything.

Use AskUserQuestion to present findings by category:

Found 12 confirmed dead items and 3 needing review.

Confirmed dead by category:
- 3 orphaned files (~280 lines)
- 5 unused exports (~120 lines)
- 2 redundant implementations (~90 lines)
- 2 orphaned dependencies

Which categories should I clean up?

Options: Remove all confirmed / Select categories / Review each item / Skip cleanup

For each approved category:

  1. Remove the dead code
  2. Clean up any imports that referenced the removed code
  3. Remove empty files left after cleanup
  4. Remove orphaned dependencies from the manifest
  5. Run the project's lint/typecheck/build commands to verify nothing broke

If any removal causes a build or type error, immediately revert that specific removal and move the item to "needs review."

After cleanup, update the report with what was removed and what was kept.

Detection Principles

Trace from entry points, not from suspects

Start from known entry points and trace what's reachable, rather than starting from a suspect symbol and trying to prove it's used. The reachability approach has fewer false negatives.

Respect the module boundary

A symbol exported from a package's public API may be consumed by external code not visible in this repository. When analyzing libraries or packages with external consumers, only flag internal (non-public-API) dead code as "confirmed." Flag public API dead code as "needs review."

Look for clusters, not just individuals

Agent-generated cruft tends to cluster. When one dead function is found, examine its neighbors — the agent likely abandoned the entire section during a refactor. A dead file often has sibling dead files created in the same commit.

Use git history as a signal

When available, check when suspect code was last meaningfully modified. Code untouched across several refactor commits is more likely dead. Use git log --follow to trace renames and detect superseded files.

Check CI and test infrastructure, not just source code

Files may have zero source-code references but be consumed by CI scripts (scripts/ci/, .github/workflows/), shell test fixtures (tests/**/*.bats), or verification tooling (.verifier/). These references appear as string arguments to shell functions — invisible to import tracing. Always run rg <filename> -- scripts/ tests/.github/ before classifying a file as orphaned.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.44%
按下载量换算24

Claude

32.03%
按下载量换算21

Cursor

17.6%
按下载量换算12

Gemini CLI

8.68%
按下载量换算6

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/petekp/claude-code-setup --skill dead-code-sweep 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills