codebase-pruner
Codebase Pruner
Audit a repo for dead code, estimate deletion risk, and remove only high-confidence candidates in small verified slices. Reason from real entrypoints, config references, and runtime wiring instead of guessing from filenames.
Core Rules
- Treat dead code as code with no live path from any entrypoint, config reference, or runtime hook.
- Map references before deleting anything. One missed reference invalidates the deletion.
- Prefer
Auditfirst. UseExecuteonly after the dead-code inventory is clear enough to act safely. - If a candidate has dynamic dispatch risk, reflection risk, or external integration risk, flag it instead of deleting it automatically.
- Never delete generated files. Update the generator or generated output flow instead.
- Never mix pruning with unrelated feature work or refactors.
- Prefer narrow, reversible slices with verification after each slice.
Step 0: Detect Active Agent and Doc Folder
Before reporting or editing, detect which agent is running:
More from afu-it/safe-code
safe-code
Full repo hygiene in one pass. Uses /safe-code for first-time setup, /safe-code --continue for context-safe resume, and /safe-code --save for handoff + local commit. Detects the active agent, initializes all continuity docs inside the current project only, audits and removes dead code in safe slices, refactors in place, and keeps docs in sync. /safe-code --save creates or uses a local git repo and commits locally only — it never pushes to a remote. Universal git remote detection is informational only. Use when asked to do a full cleanup, full hygiene pass, /safe-code, or maintain a repo in one go.
9safe-refactor-code
Refactor code safely in small verified slices while keeping repo continuity docs in sync. Uses code-review graph tools for rename previews, impact radius, affected flows, and post-change review when available. Use when an agent is asked to refactor, restructure, clean up, remove or replace code, modernize modules, or do follow-up hygiene in a repo.
7build-graph
Build or update the code review knowledge graph. Use before safe-code audits, refactors, reviews, debugging, or when the graph may be stale.
1review-changes
Review working-tree, branch, or PR changes using graph change detection, blast-radius analysis, affected flows, and test coverage checks.
1explore-codebase
Navigate and understand codebase structure using the code-review graph. Use for repo orientation, AGENTS.md authoring, architecture mapping, or finding relevant code.
1debug-issue
Systematically debug issues using graph-powered code navigation, recent-change detection, affected flows, and targeted verification.
1