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

find-dead-code找到死代码

Agent Skill

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

总安装

665

周安装

28

GitHub Stars

292

下载量

233
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/tobihagemann/turbo --skill find-dead-code

简介

find-dead-code 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。

  • 可结合来源仓库、安装命令和原始 README 继续核验具体用法。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。
  • 当前顶部介绍为空,需参考原始 SKILL.md 获取详细功能说明。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Find Dead Code

Identify dead code in a codebase. Core rule: code only used in tests is still dead code. Only production usage counts.

Step 1: Detect Languages, Scope & Test Boundaries

Determine the project structure:

  1. Check for config files: package.json, tsconfig.json, pyproject.toml, setup.py, Package.swift, .xcodeproj, Cargo.toml, go.mod, pom.xml, build.gradle
  2. Glob for source files: **/*.ts, **/*.py, **/*.swift, **/*.go, **/*.rs, **/*.java
  3. Identify source roots — where production code lives (e.g., src/, lib/, Sources/)
  4. Partition the codebase into analysis units by top-level source directories (e.g., src/auth/, src/api/, src/utils/, lib/models/). Each directory becomes one subagent's scope in Step 3.

If the user specified a scope, restrict analysis to that scope.

Test File Patterns

Establish which files are test files. Code referenced ONLY from these locations is dead.

LanguageTest file patterns
TS/JS*.test.{ts,tsx,js,jsx}, *.spec.{ts,tsx,js,jsx}, __tests__/**, __mocks__/**, *.stories.{ts,tsx,js,jsx}
Pythontest_*.py, *_test.py, tests/**, test/**, conftest.py
Swift*Tests.swift, *Test.swift, Tests/**, *UITests.swift, XCTestCase subclasses
Go*_test.go, testdata/**
Rusttests/**, benches/**, #[cfg(test)] modules (inline test modules within source files)
Java/Kotlinsrc/test/**, *Test.java, *Tests.java, *Spec.java, *Test.kt
Generalfixtures/**, __fixtures__/**, mocks/**, testutils/**, testhelpers/**, spec/**

Also exclude: test runner configs (jest.config.*, vitest.config.*, pytest.ini), storybook files, benchmark files.

Step 2: Quick Wins — CLI Tools (Optional)

If a CLI tool is installed, run it as a fast first pass for zero-reference dead code.

LanguageToolCheckRun
TS/JSknipnpx knip --versionnpx knip --no-exit-code
Pythonvulturevulture --versionvulture <src_dirs> --min-confidence 80
Swiftperipherywhich peripheryperiphery scan --skip-build
Godeadcodewhich deadcodedeadcode./...
Rustcompiler warnings`cargo build 2>&1 \grep "dead_code"`

Important limitation: CLI tools count test imports as real usage. They cannot detect code that is only used in tests. They only find symbols with literally zero references anywhere. Step 3 is required for test-only detection.

If no CLI tool is installed, skip to Step 3. Do not ask the user to install anything.

Step 3: Test-Only Analysis — Parallel Subagents (Core)

This is the primary analysis. Use the Agent tool to launch one subagent per top-level source directory from Step 1 in a single assistant message so they run concurrently. Each Agent call uses model: "opus" and does not set run_in_background. Expect one Agent tool call per directory, capped at 8 by the Rules section. State the count explicitly when emitting the calls.

Subagent Strategy

Each subagent receives:

  1. Its assigned directory to scan for exported symbols
  2. The test file patterns from Step 1
  3. The full project root path so it can grep across the entire codebase

Subagent Task

Each subagent performs these steps on its assigned directory:

a) Find exported/public symbols:

LanguageExported symbol patterns
TS/JSexport function, export const, export let, export var, export class, export interface, export type, export enum, export default, module.exports
PythonTop-level def and class in non-_-prefixed modules, module-level constants (FOO =...), symbols in __all__, public functions (no _ prefix)
Swiftpublic func, public var, public let, public class, public struct, public enum, public protocol, open class, open func, open var
GoCapitalized identifiers: func FooBar, type FooBar struct, var FooBar, const FooBar (Go uses capitalization for public visibility)
Rustpub fn, pub struct, pub enum, pub trait, pub const, pub static, pub type, pub mod
Java/Kotlinpublic class, public static, public void, public fields, val/var properties, fun (top-level), @Bean, @Component, @Service annotated classes

b) For each symbol, grep across the entire codebase for references, excluding:

  • The definition file itself
  • Generated/vendored directories (node_modules/, dist/, build/, vendor/, __pycache__/, .tox/, .build/, DerivedData/, target/)

c) Classify each reference as test or production based on the test file patterns.

CRITICAL — same-module references count as production usage. A symbol called by another production file within the same module/package is alive. Do not report symbols as "dead" when they have zero *external* callers but are used internally. Only report symbols with zero production references from *any* file. "Unnecessarily public" (could be internal/unexported) is a visibility issue, not dead code — do not include it.

d) Report structured results for each symbol:

  • Symbol name, type (function/class/const/etc.), definition file and line range
  • Number of production references (with file paths) — including same-module references
  • Number of test references (with file paths)
  • Classification: dead (zero prod refs anywhere), test-only (only test refs), alive (has prod refs)

Merging Results

After all subagents complete, collect and merge their results. Deduplicate any symbols that appear in multiple reports (e.g., re-exports).

Step 4: Filter, Classify & Evaluate

Apply these filters to the merged results from Steps 2 and 3:

  1. Framework entry points: Skip symbols used by convention — React components in barrel files, Django views in URL configs, Go init() and main() functions, Go interface implementations, Rust main(), Rust trait implementations, #[derive(...)] generated code, CLI handlers registered in main, magic/lifecycle methods (__init__, __repr__), serialization methods (to_json, from_dict), interface/protocol implementations
  2. Re-export chains: Trace barrel files (index.ts, __init__.py) before declaring a symbol dead. A symbol re-exported through a barrel may have indirect consumers.
  3. Dynamic usage: Flag symbols that might be used via reflection (getattr, importlib, reflect package in Go, proc_macro in Rust), string-based lookups, or decorator/attribute registration as "likely dead" rather than "definite"
  4. Cross-package references: In monorepos, verify a symbol isn't imported by a sibling package before declaring it dead
  5. Design docs / specs / roadmaps: If the project has spec files, roadmaps, or TODO files (e.g., .turbo/specs/, ROADMAP.md, TODO.md), cross-reference test-only findings against them. Test-only APIs may be planned features awaiting integration — flag as investigate rather than delete

Classify each finding:

  • Definite dead: zero references outside its definition file
  • Test-only dead: references exist, but ALL are in test files
  • Likely dead: uncertain due to dynamic usage, framework conventions, or complex re-export chains

Evaluate Findings

Run the /evaluate-findings skill on the classified results to verify each finding against the actual code and weed out false positives. Read the full definition file for each finding — not just the flagged symbol. The surrounding code may reveal that the feature is already implemented differently (e.g., a public ping() method may be test-only while a private keepalive loop in handleConnect() does the real work).

Proceed with the evaluation results in the next section.

Recommend Action

For each surviving finding, assign a recommendation:

SignalRecommendation
No tests, no production usagedelete
Has tests but no production usage, and no spec/roadmap referencedelete (method + test assertions)
Has tests but no production usage, referenced in spec/roadmap/TODOinvestigate (planned feature, not dead)
Partially wired up, unclear intent, or needs domain contextinvestigate

For findings marked investigate, run the /investigate skill to determine whether the code is a planned feature, an unwired integration, or truly dead.

Common Dead Code Patterns

Watch for these high-yield patterns that tools and simple grep often miss:

  1. Test-only state accessors: Public properties/methods that expose internal state solely for test assertions (e.g., isEnabled, count, currentItems). The module's production consumers use behavior (events, callbacks, side effects) — only tests peek at the internal state. When removing these, the corresponding test assertions must also be removed or rewritten to use behavior-based verification.
  2. Unused data model fields: Properties on serializable types (Codable structs, dataclasses, POJOs) that are decoded but never read by any production code. When removing a field from a serializable type, also update all data files that encode it (JSON, YAML, XML, database schemas, migration files).
  3. Vestigial enum cases: Enum cases defined but never constructed or matched against in production code.
  4. Orphaned convenience methods: Public wrappers that call through to another public method with slightly different parameters, where all callers use the underlying method directly.

Adjacent Findings

While scanning for dead code, note (but do not act on) these related issues for the user:

  • Bugs near dead code: Dead code often neighbors buggy code — a missing call, a wiring gap, or an incomplete integration
  • Unwired features: Code that is "almost alive" — defined, tested, but not connected to the rest of the system. Distinguish from truly dead code.

Step 5: Present Findings

Group results by confidence level:

Definite Dead (zero references outside definition)

FileSymbolTypeLine RangeRecommendation

Test-Only Dead (referenced only in tests)

FileSymbolTypeTest files referencing itRecommendation

Likely Dead (verify manually)

FileSymbolTypeReason for uncertaintyRecommendation

Include:

  • Total count per category
  • Estimated removable lines
  • Suggested removal order (leaf dependencies first)

Rules

  • If more than 8 top-level source directories are identified, ask the user to narrow scope or group related directories into fewer subagent batches.
  • If no dead code is found, report that explicitly and note any scope limitations or analysis caveats.

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

34.73%
按下载量换算81

Claude

32.9%
按下载量换算77

Cursor

19.51%
按下载量换算45

Gemini CLI

8.83%
按下载量换算21

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

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

来源信息

继续浏览同类 Skills