Matrix Nuke
npx machina-cli add skill ojowwalker77/Claude-Matrix/nuke --openclawMatrix Nuke
Comprehensive codebase hygiene analysis. Detects dead code, unused imports, orphaned files, circular dependencies, stale TODOs, unnecessary comments, overengineered dependencies, and more across 11 categories.
Tip: This skill runs in a forked context for unbiased analysis - clean slate, no conversation history bias.
Architecture
ORCHESTRATOR (parse mode, dispatch agents, aggregate report)
|
+-- STRUCTURAL AGENT --> dead exports, orphaned files, unused imports
+-- CIRCULAR DEP AGENT --> import cycle detection
+-- DEPENDENCY AGENT --> unused npm packages, overengineered deps
+-- GENERATIVE AGENT --> comments, console.log, copy-paste, TODOs
+-- TRIAGE AGENT --> confidence scoring, safety filtering, tiering
Usage
Parse user arguments from the skill invocation (text after the trigger phrase).
Expected format: /nuke [mode] [path]
Modes
| Mode | Command | Behavior |
|---|---|---|
| Scan | /nuke or /nuke scan | Report only - touch nothing (default) |
| This | /nuke this <file> | Single file analysis |
| Safe | /nuke safe | Report HIGH confidence only (>90%) |
| Aggressive | /nuke aggressive | Report MEDIUM+ confidence (>70%) |
Path Filtering
Append a path to any mode to limit scope:
/nuke scan src/api/- only scan src/api//nuke this src/utils/auth.ts- single file
Examples
/nuke # Full scan, report only
/nuke scan # Same as above
/nuke this src/utils/auth.ts # Single file analysis
/nuke scan src/api/ # Scan specific directory
/nuke safe # High-confidence findings only
/nuke aggressive # Medium+ confidence findings
Pipeline
Follow the orchestration detailed in references/nuke-pipeline.md:
- Pre-flight - Check index availability (
matrix_index_status), detect entry points from package.json, parse mode - Structural Analysis - Use
matrix_find_dead_codefor dead exports + orphaned files - Circular Dep Detection - Use
matrix_find_circular_depsfor import cycles - Dependency Analysis - Read package.json, cross-reference with actual imports via
Grep - Generative Analysis - AI inspection of files for comments, console.log, duplication, TODOs
- Triage - Apply safety rules, assign confidence scores, classify into tiers
- Report - Generate formatted output per
references/output-format.md
Early exit for /nuke this: Only run Structural + Generative agents on that single file. Skip dependency and circular dep analysis.
Graceful degradation: If index is unavailable, fall back to Grep-based analysis. Report reduced accuracy.
What Gets Detected (11 Categories)
Structural (deterministic, via MCP tools)
- Dead exports - exported symbols with zero callers across the codebase
- Orphaned files - files that nothing imports (excluding entry points)
- Circular dependencies - import cycles in the dependency graph
- Unused npm packages - in package.json but never imported
- Unused imports - imports brought in but never referenced in the file
Generative (AI judgment required)
- Unnecessary comments - obvious/redundant comments (
// increment i,// constructor) - Commented-out code - dead code hiding in comments (contains
{,=,function,return) - Console.log leftovers -
console.logandconsole.debugleft from debugging (NOTconsole.error) - Overengineered deps - libraries replaceable with native APIs (
lodash.get->?.,moment->Intl) - Copy-paste duplication - near-identical code blocks (5+ similar consecutive lines)
- Stale TODO/FIXME - ancient TODOs with no linked issues and old git blame dates
Safety Rules
See references/safety-rules.md for full details. Key rules:
- Never flag entry points - index.ts, main.ts, bin/*, package.json main/module/exports
- Never flag framework conventions - pages/, routes/, app/, .config., migrations/
- Never flag dynamically imported modules - import(), require() references
- Never flag public API surface - root barrel exports, @public JSDoc
- Respect .nukeignore - if present, honor it like .gitignore
Additional Resources
references/nuke-pipeline.md- Full orchestrator pipelinereferences/agents/structural-agent.md- Dead code detection via MCP toolsreferences/agents/generative-agent.md- AI-judged detection patternsreferences/agents/dependency-agent.md- Package analysis and native alternativesreferences/agents/triage-agent.md- Confidence scoring and safety filteringreferences/safety-rules.md- Entry point detection, what NOT to flagreferences/output-format.md- Report template
Source
git clone https://github.com/ojowwalker77/Claude-Matrix/blob/main/skills/nuke/SKILL.mdView on GitHub Overview
Matrix Nuke performs comprehensive codebase hygiene across 11 categories, detecting dead code, unused exports, orphaned files, circular dependencies, stale TODOs, unnecessary comments, overengineered dependencies, and more. It runs in a forked context to ensure unbiased analysis for safe cleanup.
How This Skill Works
An orchestrator coordinates five specialized agents (Structural, Circular Dep, Dependency, Generative, and Triage) to surface issues and assemble a structured report. It relies on Matrix MCP tools (dead code, circular deps, exports, imports, and search utilities) and can fall back to Grep if the index is unavailable. Modes like Scan, This, Safe, and Aggressive, plus optional path filters, control scope and depth.
When to Use It
- Kick off a full codebase cleanup before a major release to reduce dead code and bloated imports
- After a refactor to surface orphaned files, dead exports, and circular dependencies
- Audit for unused npm packages and overengineered dependencies to shrink the footprint
- Investigate import cycles in a monorepo and apply targeted fixes
- Analyze a single file to verify quality, remove unnecessary logs, and prune TODOs
Quick Start
- Step 1: Run a full scan with '/nuke' (default) to generate a baseline report
- Step 2: Narrow the scope with '/nuke scan <path>' or '/nuke this <file>' as needed
- Step 3: Review the report, prune dead code, imports, and packages, then rerun to verify
Best Practices
- Run in a forked context to avoid history bias and ensure clean baseline
- Start with a full scan (default mode) before targeted scans of specific files or dirs
- Cross-check findings with Grep fallback if the index is unavailable or stale
- Back up results and iterate with staged commits to validate removals
- Prioritize Safe findings (>90% confidence) before tackling Aggressive findings
Example Use Cases
- Identify and prune dead exports in a large React/TypeScript project
- Find orphaned files after a module restructuring and delete or relocate them
- Detect circular dependencies in a monorepo and refactor import paths
- Remove unused npm packages to cut installation size and risk surface
- Clean up console.log statements and TODOs across multiple files