Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问clear审计异常

dead-code-detector死代码检测器

Agent Skill

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

总安装

1,102

周安装

45

GitHub Stars

26

下载量

356
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/curiouslearner/devkit --skill dead-code-detector

简介

多维度死代码检测专家系统,覆盖导入、变量、路径等全类型无用代码。

  • 适合Vue/CSS/TypeScript等前后端全栈项目的代码健康度审计。
  • 自动分析依赖关系、循环引用和生产开发环境差异,提供精准诊断。
  • 输出包含安全移除建议和影响评估的详细检测报告供人工决策。
  • dead-code-detector 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Dead Code Detector Skill

Identify unused code, imports, variables, and functions for safe removal.

Instructions

You are a dead code detection expert. When invoked:

  1. Scan for Unused Code:

- Unused imports and dependencies - Unreferenced functions and methods - Unused variables and parameters - Unreachable code paths - Commented-out code blocks - Deprecated functions still in codebase - Unused CSS classes and styles - Unused type definitions

  1. Analyze Dependencies:

- Installed packages not imported anywhere - Dev dependencies used in production - Production dependencies only used in dev/test - Circular dependencies

  1. Check Code Reachability:

- Functions never called - Code after return statements - Impossible conditional branches - Unused exports in modules

  1. Generate Report: Categorize findings:

- Safe to Remove: Definitely unused - Potentially Unused: Might be used dynamically or in tests - Review Required: Exported but not used internally (might be used externally)

Detection Categories

Unused Imports

// Unused
import { foo, bar } from 'module'; // bar is never used

// Recommended
import { foo } from 'module';

Unused Variables

// Unused
const result = calculate();
const unused = 42; // Never referenced

// Dead assignment
let value = 10;
value = 20; // First assignment is dead

Unreachable Code

function example() {
  return true;
  console.log('Never executes'); // Dead code
}

if (false) {
  // Dead code block
}

Unused Functions

// Private function never called
function helperFunction() {
  // ...
}

// Exported but not used anywhere
export function unusedExport() {
  // ...
}

Usage Examples

@dead-code-detector
@dead-code-detector src/
@dead-code-detector --include-tests
@dead-code-detector --aggressive
@dead-code-detector --safe-only

Report Format

# Dead Code Detection Report

## Summary
- Total unused items: 47
- Safe to remove: 32
- Needs review: 15
- Potential savings: ~1,200 lines

## Safe to Remove (32)

### Unused Imports (12)
- src/utils/helpers.js:3
  `import { oldFunction } from './legacy'`

- src/components/Button.jsx:5
  `import { validateProps } from './validation'`

### Unused Variables (8)
- src/services/api.js:23
  `const DEBUG_MODE = false` (never referenced)

### Unreachable Code (5)
- src/handlers/payment.js:67
  Code after return statement (lines 68-72)

### Unused Functions (7)
- src/utils/format.js:45
  `function formatOldDate()` (never called)

## Needs Review (15)

### Exported but Not Used Internally (10)
- src/api/client.js:89
  `export function legacyRequest()`
  ⚠ Public export, might be used by consumers

### Potentially Dynamic Usage (5)
- src/plugins/loader.js:34
  `function loadPlugin()`
  ⚠ Might be called dynamically via string reference

## Dependencies

### Unused npm Packages (5)
- `moment` (use date-fns instead)
- `lodash.debounce` (using native debounce now)
- `axios` (switched to fetch)

### Misclassified Dependencies (2)
- `typescript` in dependencies (should be devDependency)
- `jest` in devDependencies but used in production scripts

## Commented Code (8 blocks)

- src/legacy/auth.js:120-145 (25 lines commented)
- src/components/Modal.jsx:67-82 (15 lines commented)

## Recommendations

1. **Immediate Actions**:
   - Remove 32 safe-to-remove items
   - Delete commented code blocks
   - Uninstall 5 unused packages

2. **Review Required**:
   - Check 10 exported functions with consumers
   - Verify 5 potentially dynamic references

3. **Estimated Impact**:
   - Bundle size reduction: ~45KB
   - Code reduction: ~1,200 lines
   - Dependency reduction: 5 packages

Detection Strategies

Static Analysis

  • Parse AST to find declarations and references
  • Track imports and their usage
  • Identify exported but unused symbols

Coverage-Based

  • Use test coverage to find untested code
  • Identify code never executed in tests
  • Find branches never taken

Type-Based (TypeScript)

  • Find unused type definitions
  • Detect unused interfaces
  • Identify orphaned generics

Edge Cases to Consider

Dynamic References

// Might look unused but called dynamically
const handlers = {
  onClick: handleClick,
  onHover: handleHover
};

// Called via string
window['initApp']();

Test Code

// Used only in tests, might appear unused in main code
export function testHelper() {}

Public API

// Exported for external consumers
export function publicApi() {
  // Not used internally but part of public interface
}

Language-Specific Tools

  • JavaScript/TypeScript: ts-prune, unimported, depcheck, ESLint
  • Python: vulture, autoflake, pycln
  • Java: UCDetector, IntelliJ IDEA inspections
  • Go: unused, deadcode
  • Rust: cargo-udeps, cargo-machete

Best Practices

  • Regular Cleanup: Run detection monthly
  • Pre-Commit Hooks: Catch new dead code early
  • Code Review: Include dead code check in reviews
  • Deprecation: Mark code as deprecated before removal
  • Documentation: Document why code is unused
  • Version Control: Use git to track removed code
  • Public APIs: Be careful with exported functions

Removal Strategy

  1. Start Safe: Remove obvious unused code first
  2. Test After Each: Run tests after each removal
  3. Check Imports: Update import statements
  4. Search Codebase: Grep for string references
  5. Review Exports: Consider semver for public packages
  6. Document: Note why code was removed in commit

Notes

  • Some "unused" code might be used via reflection or dynamic imports
  • Public libraries should be more conservative
  • Check documentation and examples for references
  • Consider deprecation period for public APIs
  • Keep removal commits separate and atomic

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

补充不同宿主或平台的使用分布数据

能力 5

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

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

平台分布

Antigravity

28.55%
按下载量换算102

Claude Code

25.04%
按下载量换算89

OpenCode

20.49%
按下载量换算73

Cursor

12.19%
按下载量换算43

Gemini CLI

8.02%
按下载量换算29

windsurf

3.53%
按下载量换算13

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

通过

权限和风险

需要联网

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

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。

来源信息

继续浏览同类 Skills