A VS Code extension that uses Claude AI to find dead code that traditional static analysis misses.
| Category | Examples |
|---|---|
| 🚫 Unreachable Logic | Code after return, impossible if conditions, catch blocks that hide errors |
| 🔌 Unused APIs | Exported functions never called, orphaned classes, unused variables |
| 🚩 Obsolete Feature Flags | const FEATURE_X = false guards, hardcoded toggles, deprecated flag checks |
npm installOption A — Settings UI:
- Open VS Code Settings (
Cmd+,/Ctrl+,) - Search for "Dead Code"
- Paste your key into Dead Code Detector: Anthropic Api Key
Option B — Environment variable:
export ANTHROPIC_API_KEY=sk-ant-...Press F5 in VS Code to open a new Extension Development Host window.
| Action | How |
|---|---|
| Analyze current file | Cmd+Shift+D / Ctrl+Shift+D |
| Analyze current file | Right-click → "Dead Code: Analyze Current File" |
| Analyze workspace | Command Palette → "Dead Code: Analyze Entire Workspace" |
| Clear diagnostics | Command Palette → "Dead Code: Clear All Diagnostics" |
Results appear as:
- Inline squiggles in the editor (Problems panel)
- Results panel (opens beside your editor) with filtering, severity badges, and jump-to-line
// settings.json
{
"deadCode.anthropicApiKey": "sk-ant-...",
"deadCode.severity": "warning", // error | warning | information | hint
"deadCode.checks": {
"unreachableLogic": true,
"unusedApis": true,
"obsoleteFeatureFlags": true
}
}- JavaScript / TypeScript (
.js,.ts,.jsx,.tsx) - Python (
.py)
src/
extension.ts # Entry point, command registration, diagnostics
analyzer.ts # Claude API call + prompt engineering
resultsPanel.ts # Webview results panel (HTML/CSS/JS)
package.json # Extension manifest, commands, config schema
tsconfig.json
User triggers command
↓
extension.ts → reads file + config
↓
analyzer.ts → calls claude-sonnet-4 with structured prompt
↓
Claude returns JSON array of issues
↓
extension.ts → creates VS Code Diagnostics (squiggles)
↓
resultsPanel.ts → renders filterable HTML panel
To add a new language, add it to activationEvents and isSupportedLanguage() in extension.ts.
To add a new check category, update the system prompt in analyzer.ts and add the category to the DeadCodeResult type.