Dead code removal via massively parallel deep agents. You are the ORCHESTRATOR — you scan, verify, batch, then delegate ALL removals to parallel agents.
<rules>
- LSP is law. Verify with
LspFindReferences(includeDeclaration=false)before ANY removal decision. - Never remove entry points.
src/index.ts,src/cli/index.ts, test files, config files,packages/— off-limits. - You do NOT remove code yourself. You scan, verify, batch, then fire deep agents. They do the work.
</rules>
<false-positive-guards>
NEVER mark as dead:
- Symbols in
src/index.tsor barrelindex.tsre-exports - Symbols referenced in test files (tests are valid consumers)
- Symbols with
@public/@apiJSDoc tags - Hook factories (
createXXXHook), tool factories (createXXXTool), agent definitions inagentSources - Command templates, skill definitions, MCP configs
- Symbols in
package.jsonexports
</false-positive-guards>
PHASE 1: SCAN — Find Dead Code Candidates
Run ALL of these in parallel:
<parallel-scan>
TypeScript strict mode (your primary scanner — run this FIRST):
This gives you the definitive list of unused locals, imports, parameters, and types with exact file:line locations.
Explore agents (fire ALL simultaneously as background):
</parallel-scan>
Collect all results into a master candidate list.
PHASE 2: VERIFY — LSP Confirmation (Zero False Positives)
For EACH candidate from Phase 1:
Also apply the false-positive-guards above. Produce a confirmed list:
Action types:
REMOVE— delete the symbol/import/file entirelyPREFIX _— unused function parameter required by signature → rename to_paramName
If ZERO confirmed: report "No dead code found" and STOP.
PHASE 3: BATCH — Group by File for Conflict-Free Parallelism
<batching-rules>
Goal: maximize parallel agents with ZERO git conflicts.
- Group confirmed dead code items by FILE PATH
- All items in the SAME file go to the SAME batch (prevents two agents editing the same file)
- If a dead FILE (entire file deletion) exists, it's its own batch
- Target 5-15 batches. If fewer than 5 items total, use 1 batch per item.
Example batching:
Files in the same directory CAN be batched together (they won't conflict as long as no two agents edit the same file). Maximize batch count for parallelism.
</batching-rules>
PHASE 4: EXECUTE — Fire Parallel Deep Agents
For EACH batch, fire a deep agent:
<agent-prompt-template>
Every deep agent gets this prompt structure (fill in the specifics per batch):
</agent-prompt-template>
Fire ALL batches simultaneously. Wait for all to complete.
PHASE 5: FINAL VERIFICATION
After ALL agents complete:
Produce summary:
SCOPE CONTROL
If $ARGUMENTS is provided, narrow the scan:
- File path → only that file
- Directory → only that directory
- Symbol name → only that symbol
allor empty → full project scan (default)
ABORT CONDITIONS
STOP and report if:
- More than 50 candidates found (ask user to narrow scope or confirm proceeding)
- Build breaks and cannot be fixed by reverting


