/install deadcode
\r \r
DeadCode -- Dead Code & Unused Export Detector\r
\r DeadCode scans source files for dead code, unused exports, orphan files, unreachable code paths, and code cruft across JavaScript/TypeScript, Python, Go, and CSS/SCSS. It uses regex-based pattern matching against 60+ dead code patterns, lefthook for git hook integration, and produces markdown reports with actionable cleanup recommendations.\r \r
Commands\r
\r
Free Tier (No license required)\r
\r
deadcode scan [file|directory]\r
One-shot dead code scan of files or directories.\r \r How to execute:\r
bash "\x3CSKILL_DIR>/scripts/deadcode.sh" scan [target]\r
```\r
\r
**What it does:**\r
1. Accepts a file path or directory (defaults to current directory)\r
2. Auto-detects language types (JavaScript/TypeScript, Python, Go, CSS/SCSS)\r
3. Finds all source files matching known patterns\r
4. Runs 60+ dead code patterns against each file\r
5. Runs file-level checks for orphan detection and structural issues\r
6. Calculates a dead code score (0-100) per file and overall\r
7. Outputs findings with: file, line number, check ID, severity, description, recommendation\r
8. Exit code 0 if score >= 70, exit code 1 if too much dead code found\r
9. Free tier limited to 5 source files per scan\r
\r
**Example usage scenarios:**\r
- "Scan my code for dead code" -> runs `deadcode scan .`\r
- "Check this file for unused exports" -> runs `deadcode scan src/utils.ts`\r
- "Find dead code in my Python project" -> runs `deadcode scan src/`\r
- "Are there orphan files in my repo?" -> runs `deadcode orphans .`\r
\r
### Pro Tier ($19/user/month -- requires DEADCODE_LICENSE_KEY)\r
\r
#### `deadcode hooks install`\r
Install git pre-commit hooks that scan staged source files before every commit.\r
\r
**How to execute:**\r
```bash\r
bash "\x3CSKILL_DIR>/scripts/deadcode.sh" hooks install\r
```\r
\r
**What it does:**\r
1. Validates Pro+ license\r
2. Copies lefthook config to project root\r
3. Installs lefthook pre-commit hook\r
4. On every commit: scans all staged source files for dead code, blocks commit if critical/high findings, shows cleanup advice\r
\r
#### `deadcode hooks uninstall`\r
Remove DeadCode git hooks.\r
\r
```bash\r
bash "\x3CSKILL_DIR>/scripts/deadcode.sh" hooks uninstall\r
```\r
\r
#### `deadcode report [directory]`\r
Generate a markdown dead code report with findings, severity breakdown, and cleanup steps.\r
\r
```bash\r
bash "\x3CSKILL_DIR>/scripts/deadcode.sh" report [directory]\r
```\r
\r
**What it does:**\r
1. Validates Pro+ license\r
2. Runs full scan of the directory\r
3. Generates a formatted markdown report from template\r
4. Includes per-file breakdowns, dead code scores, cleanup priority\r
5. Output suitable for code reviews and tech debt tracking\r
\r
#### `deadcode orphans [directory]`\r
Find orphan files that are never imported or referenced by any other file.\r
\r
```bash\r
bash "\x3CSKILL_DIR>/scripts/deadcode.sh" orphans [directory]\r
```\r
\r
**What it does:**\r
1. Validates Pro+ license\r
2. Builds an import/reference graph across all source files\r
3. Identifies files that are never imported/required/referenced\r
4. Excludes entry points (index files, main files, test files, config files)\r
5. Reports orphan files with confidence levels\r
\r
### Team Tier ($39/user/month -- requires DEADCODE_LICENSE_KEY with team tier)\r
\r
#### `deadcode ignore [pattern]`\r
Manage ignore rules for dead code detection.\r
\r
```bash\r
bash "\x3CSKILL_DIR>/scripts/deadcode.sh" ignore [pattern]\r
```\r
\r
**What it does:**\r
1. Validates Team+ license\r
2. Adds/removes patterns to the ignore list in ~/.openclaw/openclaw.json\r
3. Patterns can be file globs or check IDs\r
4. Supports per-project and global ignore rules\r
\r
#### `deadcode sarif [directory]`\r
Generate SARIF output for CI/CD integration.\r
\r
```bash\r
bash "\x3CSKILL_DIR>/scripts/deadcode.sh" sarif [directory]\r
```\r
\r
**What it does:**\r
1. Validates Team+ license\r
2. Runs full scan of the directory\r
3. Outputs findings in SARIF v2.1.0 format\r
4. Compatible with GitHub Code Scanning, Azure DevOps, and other CI systems\r
5. Includes rule definitions, locations, and severity mappings\r
\r
#### `deadcode status`\r
Show license and configuration information.\r
\r
```bash\r
bash "\x3CSKILL_DIR>/scripts/deadcode.sh" status\r
```\r
\r
## Detected Dead Code Patterns\r
\r
DeadCode detects 60+ dead code patterns across 5 language categories:\r
\r
| Category | Examples | Severity |\r
|----------|----------|----------|\r
| **JavaScript/TypeScript** | Unused exports, console.log left in code, commented-out blocks, unreachable code after return/throw, empty function bodies, unused variables, dead switch cases, deprecated markers, empty catch blocks | Critical/High |\r
| **Python** | Functions defined but never called, unused imports, pass-only bodies, commented-out code, dead code after return/raise, __all__ mismatches, empty except blocks | Critical/High |\r
| **Go** | Unused imports, unexported dead functions, dead code after return/panic, empty function bodies, commented-out code, empty init() functions | High/Medium |\r
| **CSS/SCSS** | Unused CSS classes/IDs, empty rule blocks, duplicate selectors, commented-out styles, !important overuse, unused CSS variables, empty media queries, vendor prefixes | Medium/Low |\r
| **General** | Orphan files, large comment blocks, TODO/FIXME density, debug/test code in production, placeholder text, feature flag remnants | High/Medium |\r
\r
## Configuration\r
\r
Users can configure DeadCode in `~/.openclaw/openclaw.json`:\r
\r
```json\r
{\r
"skills": {\r
"entries": {\r
"deadcode": {\r
"enabled": true,\r
"apiKey": "YOUR_LICENSE_KEY_HERE",\r
"config": {\r
"severityThreshold": "high",\r
"ignorePatterns": ["**/test/**", "**/fixtures/**", "**/*.spec.*"],\r
"ignoreChecks": [],\r
"reportFormat": "markdown"\r
}\r
}\r
}\r
}\r
}\r
```\r
\r
## Important Notes\r
\r
- **Free tier** works immediately with no configuration\r
- **All scanning happens locally** -- no code is sent to external servers\r
- **License validation is offline** -- no phone-home or network calls\r
- Pattern matching only -- no AST parsing, no external dependencies\r
- Supports scanning multiple language types in a single pass\r
- Git hooks use **lefthook** which must be installed (see install metadata above)\r
- Exit codes: 0 = clean (score >= 70), 1 = too much dead code (for CI/CD integration)\r
\r
## Error Handling\r
\r
- If lefthook is not installed and user tries `hooks install`, prompt to install it\r
- If license key is invalid or expired, show clear message with link to https://deadcode.pages.dev/renew\r
- If a file is binary, skip it automatically with no warning\r
- If no source files found in target, report clean scan with info message\r
- If language type cannot be determined, skip the file gracefully\r
\r
## When to Use DeadCode\r
\r
The user might say things like:\r
- "Scan my code for dead code"\r
- "Find unused exports in my project"\r
- "Are there orphan files in my repo?"\r
- "Check for unreachable code"\r
- "Find commented-out code blocks"\r
- "Detect unused imports in my Python code"\r
- "Generate a dead code report"\r
- "Set up pre-commit hooks for dead code detection"\r
- "Check for console.log statements left in production"\r
- "Find empty function bodies"\r
- "Are there any unused CSS classes?"\r
- "Scan for TODO/FIXME comments"\r
- "Find placeholder code"\r
- "Check for debug code left in production"\r
- "Generate SARIF output for my CI pipeline"\r
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install deadcode - After installation, invoke the skill by name or use
/deadcode - Provide required inputs per the skill's parameter spec and get structured output
What is deadcode?
Dead code and unused export detector — scans JavaScript/TypeScript, Python, Go, Java, and CSS for dead code, orphan files, unused exports, and code cruft. It is an AI Agent Skill for Claude Code / OpenClaw, with 78 downloads so far.
How do I install deadcode?
Run "/install deadcode" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is deadcode free?
Yes, deadcode is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does deadcode support?
deadcode is cross-platform and runs anywhere OpenClaw / Claude Code is available (darwin, linux, win32).
Who created deadcode?
It is built and maintained by suhteevah (@suhteevah); the current version is v1.0.1.