get_dead_code
Tiered refactor plan for unused code — high/medium/low confidence findings with per-directory rollups, ownership hotspots, and safe-to-delete impact estimates. Pure graph + SQL, no LLM calls.
Dead-code detection that's fast (under 10 seconds for any repo size,
no LLM involvement) and conservative by design. Findings are
classified into confidence tiers; safe_to_delete requires
confidence ≥ 0.70 and excludes dynamically-loaded patterns
(*Plugin, *Handler, *Adapter, *Middleware). Framework-aware:
Flask, FastAPI, Django, Rails, Laravel, and TYPO3 routes and
convention files don't get flagged as unused.
When to call
- Before refactor sprints —
min_confidence=0.7to prioritize safe deletions. - Library API audits —
kind="unused_export"to find unused public symbols. - Monorepo cleanup —
include_zombie_packages=Trueto find packages no other package depends on. - Aggressive cleanup —
include_internals=Trueto also surface unused private symbols (higher false-positive rate).
Parameters
Prop
Type
Returns
| Field | Description |
|---|---|
summary | total_findings, filtered_findings, deletable_lines, safe_to_delete_count, by_kind |
tiers.{high,medium,low} | Each: description, count, lines, safe_count, findings, truncated |
by_directory | (if group_by="directory") per-dir rollup sorted by lines |
by_owner | (if group_by="owner") ownership hotspots sorted by lines |
impact | total_lines_reclaimable, safe_lines_reclaimable, recommendation |
limit_note | Present if the requested limit was clamped to 25 |
Each finding contains kind, file_path, symbol_name, confidence,
reason, safe_to_delete, lines, last_commit_at, primary_owner,
age_days, and last_meaningful_change.
Example
get_dead_code(min_confidence=0.7) # safe cleanups only
get_dead_code(kind="unused_export", group_by="owner")
get_dead_code(directory="src/legacy/", include_internals=True)
get_dead_code(repo="all") # workspace-wideThings worth knowing
- Confidence tiers:
- High (≥ 0.8) — zero references, safe to delete.
- Medium (0.5–0.8) — likely unused, may have indirect references.
- Low (< 0.5) — possibly used via dynamic dispatch / reflection.
- Safe-to-delete heuristic — zero references and stable age (not modified in months). The threshold isn't just confidence.
- Cross-repo adjustment (workspace mode) — if a file has cross-repo
consumers, confidence is reduced by 50%; if other repos depend on
this repo's package,
unused_exportconfidence drops to 30% with a verification note. - Zombie package detection — monorepo packages flagged when no other package depends on them.
- Last meaningful change — derived from significant commits (feature/fix/refactor only, style/chore filtered out).
- Limit clamping — requests over 25 are clamped due to the MCP
transport budget.
limit_notewill suggest tier/directory/owner filters to paginate.
Repowise surfaces candidates. Engineers decide. Keep the team in the
loop on big deletions — group_by="owner" makes it easy to route a
cleanup PR to the right reviewer.
get_why
Architectural-decision archaeology. Search decisions in natural language, anchor them to a file path, or pull the global decision-health dashboard. Falls back to git archaeology when no recorded decisions exist.
Dependency graph
How repowise builds the two-tier dependency graph — file nodes and symbol nodes — with import resolution, call resolution, heritage extraction, and community detection.