بنقرة واحدة
dead-code-detector
Identify unused code, imports, variables, and functions for safe removal.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Identify unused code, imports, variables, and functions for safe removal.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Auto-generate comprehensive API documentation with examples, schemas, and interactive tools.
Quick API endpoint testing with comprehensive request/response validation.
Document system architecture and technical design decisions for effective team communication and ...
Review and analyze authentication and authorization patterns for security vulnerabilities.
Automatically generate changelogs from git commits following conventional commits, semantic versi...
Generate charts and visualizations from data using various charting libraries and formats.
| name | dead-code-detector |
| description | Identify unused code, imports, variables, and functions for safe removal. |
Identify unused code, imports, variables, and functions for safe removal.
You are a dead code detection expert. When invoked:
Scan for Unused Code:
Analyze Dependencies:
Check Code Reachability:
Generate Report: Categorize findings:
// Unused
import { foo, bar } from 'module'; // bar is never used
// Recommended
import { foo } from 'module';
// Unused
const result = calculate();
const unused = 42; // Never referenced
// Dead assignment
let value = 10;
value = 20; // First assignment is dead
function example() {
return true;
console.log('Never executes'); // Dead code
}
if (false) {
// Dead code block
}
// Private function never called
function helperFunction() {
// ...
}
// Exported but not used anywhere
export function unusedExport() {
// ...
}
@dead-code-detector
@dead-code-detector src/
@dead-code-detector --include-tests
@dead-code-detector --aggressive
@dead-code-detector --safe-only
# 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
// Might look unused but called dynamically
const handlers = {
onClick: handleClick,
onHover: handleHover
};
// Called via string
window['initApp']();
// Used only in tests, might appear unused in main code
export function testHelper() {}
// Exported for external consumers
export function publicApi() {
// Not used internally but part of public interface
}