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

dead-code-hunter死亡代码猎人

Agent Skill

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

总安装

171

周安装

7

GitHub Stars

公开资料未说明

下载量

55
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/magic5644/skills --skill dead-code-hunter

简介

依赖图遍历的死代码猎人工具,生成带安全评级的分级删除计划。

  • 适合重大重构前的代码库净化,降低新成员接入的认知负担。
  • 必须配合Graph-It-Live CLI建立反向索引才能发挥最大效能。
  • 无--reversedIndex参数时将跳过优化步骤,转为基础扫描模式运行。
  • dead-code-hunter 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Dead Code Hunter

Systematic scan of the dependency graph to surface orphan symbols and unreferenced files. Produces a ranked, safety-annotated deletion plan powered by Graph-It-Live.

Requires

Graph-It-Live CLI installed and indexed:

npm install -g @magic5644/graph-it-live
graph-it scan

When to Use

  • Before a major refactor — clean up before you restructure
  • After removing a feature — confirm nothing is left dangling
  • Periodic code hygiene pass on a growing codebase
  • Before onboarding a new developer — reduce noise in the codebase

Critical Prerequisite — Reversed Index

Without --reversedIndex=true, every caller/reference lookup returns empty results → guaranteed false positives. get_symbol_callers and find_referencing_files both query the reverse index. If the index was built without it, all symbols will appear orphaned, even live ones. Always build the index with --reversedIndex=true before running this skill.

Scope Caveat

find_unused_symbols operates per-file. There is no single graph-it deadcode --project command (yet). This skill orchestrates multiple tool calls to achieve project-wide coverage. On very large projects (500+ files), prioritize high-risk folders (src/, lib/, core/) rather than scanning everything. For a fully automated single-pass solution, the right approach is a native graph-it deadcode CLI command built into @magic5644/graph-it-live. That would have significantly higher impact than this skill alone, but requires development work on the CLI itself.

Workflow — Step by Step

Step 1 — Build/refresh the index

graph-it scan --reversedIndex=true
--reversedIndex=true is mandatory. It instructs graph-it to build the reverse lookup index (who imports what, who calls what). Without it, Steps 4 and 5 have no data and every symbol will appear uncalled — producing false positives across the entire scan.

Step 2 — Get the list of project files

graph-it tool get_index_status

Parse the output to retrieve the list of indexed source files. Filter out:

  • node_modules/, dist/, build/, .cache/
  • Test files (*.test.*, *.spec.*, __tests__/) — treat separately
  • Type declaration files (*.d.ts)
  • Configuration files (*.config.*, vite.config.*, etc.)

This is your scan target list.


Step 3 — Per-file unused symbol scan

For each file in the scan target list, run:

graph-it tool find_unused_symbols --filePath=<absolutePath>

Collect results into a flat list:

[
  { file: "src/utils/format.ts", symbol: "formatCurrency", kind: "function" },
  { file: "src/services/legacyAuth.ts", symbol: "hashPasswordMD5", kind: "function" },
  ...
]

Step 4 — Confirm with caller lookup (avoid false positives)

find_unused_symbols detects exports not imported by other files in the index. However a symbol may be called dynamically or from outside the indexed workspace (e.g. a published library). For every candidate, confirm with:

graph-it tool get_symbol_callers --filePath=<absolutePath> --symbolName=<symbol> --reversedIndex=true
Passing --reversedIndex=true here ensures the tool queries the reverse call graph. Omitting it falls back to forward-only traversal, which will miss most callers.
  • 0 callers → confirmed dead code candidate
  • 1+ callers → false positive, discard
  • Only test-file callers → flag as "test-only symbol", handle separately

Step 5 — Detect fully orphaned files

A file is a ghost file if:

  1. It has 0 referencing files (nothing imports it)
  2. It is not a known entry point (index, main, cli, server, etc.)

Check with:

graph-it tool find_referencing_files --filePath=<absolutePath> --reversedIndex=true
Without --reversedIndex=true, this tool cannot find reverse references and will incorrectly classify every file as unreferenced.

A ghost file may contain multiple symbols — mark the entire file for deletion rather than symbol-by-symbol.


Step 6 — Rank candidates by deletion safety

Apply this risk classification:

Risk LevelCriteriaAction
Safe0 callers, 0 referencing files, not a public API exportDelete freely
Likely safe0 callers confirmed, file has other live symbolsRemove symbol, keep file
Review firstSymbol is exported from a barrel (index.ts)Check if barrel is consumed externally
Do not deleteDynamic call patterns detected (eval, string-based dispatch)Flag only
Test-onlyOnly called from test filesEvaluate — may be intentional

Output Format

Produce a Deletion Plan in this format:


Dead Code Scan Report

Scanned: <N> files | Candidates found: <M> symbols + <K> ghost files

Ghost Files (entire file can be deleted)

FileLast modifiedReason
src/utils/oldMigration.ts2022-03-110 imports, 0 callers, not an entry point

Suggested command:

# Review first, then:
rm src/utils/oldMigration.ts

Orphan Symbols — Safe to Remove

SymbolFileKindCallers
formatLegacyCurrencysrc/utils/format.tsfunction0
MD5Hashsrc/services/auth.tsfunction0

Orphan Symbols — Review First

SymbolFileRiskNote
createReportsrc/api/index.tsBarrel exportCheck if consumed by external packages

Test-Only Symbols

SymbolFileTest callers
mockPaymentGatewaysrc/mocks/payment.ts3 test files

Recommended Deletion Order

  1. Ghost files first — highest impact, no surgical precision needed
  2. Orphan symbols in non-barrel files — safe, isolated changes
  3. Barrel exports — requires checking external consumers
  4. Test-only symbols — discuss with the team

Safety Checklist Before Deleting

  • Run graph-it tool get_symbol_callers --reversedIndex=true one more time after any refactor that modified imports
  • Check if the project is a published library — unused exports may be part of the public API
  • Check package.json exports field — symbols exported via package entry points are always live
  • Run the test suite after each deletion batch to catch dynamic usage not visible to static analysis
  • Commit in small batches — one file or one symbol group per commit for easy revert

Quick Scan (Single File or Folder)

If you only want to scan one file:

graph-it scan --reversedIndex=true   # rebuild if not already done with the flag
graph-it check src/utils/format.ts
graph-it tool find_unused_symbols --filePath=/abs/path/src/utils/format.ts

If you want a folder, use graph-it summary <folder> to get the file list, then iterate.


Limitations & Future Improvements

  • Dynamic dispatch (obj[methodName](), require(variable)) is invisible to static analysis — always review before deleting
  • Monorepos: scan per package, not at root, to avoid cross-package false positives
  • Framework magic: decorators (@Component, @Injectable) may make symbols appear unused but they're resolved at runtime — exclude framework entry files from the scan
  • graph-it deadcode CLI command (not yet available): a native single-pass project-wide dead code scanner would eliminate the per-file iteration overhead and provide a richer output with confidence scores. If this is a bottleneck, open an issue on @magic5644/graph-it-live.

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

33.28%
按下载量换算18

Claude

32.64%
按下载量换算18

Cursor

18.59%
按下载量换算10

Gemini CLI

10.2%
按下载量换算6

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

执行命令

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

安装前确认

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

来源信息

继续浏览同类 Skills