Prompier
ApprovedEngineeringrefactoringcleanupcode

Dead code audit and removal roadmap

PL by Prompier Library ☆☆☆☆☆ New Version 1 · updated Nov 10, 2026
Reviewed by moderator Prompier Library on Nov 10, 2026. Checked for personal data, secrets, risky instructions and a clear license.

About this prompt

Finds likely unused code in a codebase or module, rates how safe each item is to remove and orders the cleanup into phases. Use when a codebase feels heavy and you want to shrink it safely.

Prompt text

You are a senior engineer who removes dead code carefully. Audit the code I provide and give me a phased cleanup plan that does not break anything. Inputs - Code or file listing to audit: {{code_scope}} - Language and framework: {{language_and_framework}} - Known entry points (main files, routes, scheduled jobs, public APIs, exported libraries): {{entry_points}} - Test coverage and how risky changes are for us: {{tests_and_risk}} Steps 1. Discovery: list candidates in categories: unreferenced functions, classes and files; unused exports and imports; unreachable branches; feature flags that are permanently on or off; commented-out blocks; unused config, routes or database fields; duplicated helpers; dependencies never imported. 2. Verification: for each candidate, state the evidence that it is unused and what could hide a use: dynamic calls, reflection, string-based lookups, templates, serialization, external callers, scheduled tasks, plugins. If a use cannot be ruled out from the code given, say so. 3. Classify: confirmed dead, probably dead, uncertain. Score the removal risk (low, medium, high) and the benefit (lines removed, complexity reduced). 4. Plan phases: phase 1 trivial and safe (unused imports, commented-out code), phase 2 clearly dead code with tests, phase 3 uncertain items that need runtime evidence such as logs or usage metrics before deletion. 5. For each phase give a way to confirm nothing broke and a way to undo. Output format - Short summary with counts per category - Candidate table: item, location, evidence, confidence, risk, phase - The three-phase plan with verification steps - Items to leave alone and why Quality bar - Do not recommend deleting anything you cannot support with evidence from the supplied code. - Prefer many small, reversible changes over one large cleanup. - Keep explanations short and concrete.

Variables

4 variables
VariableWhat to enterExampleDefault
{{code_scope}}Paste the code or file listing to auditsrc/utils/legacy_export.js, src/reports/old/*.js, src/api/v1/...—
{{language_and_framework}}The language and frameworkJavaScript, Express 4—
{{entry_points}}Main files, routes, scheduled jobs, public APIs or exported librariesserver.js, routes in src/api, a nightly cron in jobs/cleanup.js—
{{tests_and_risk}}Test coverage and how risky changes areAbout 40% coverage; billing code is high risk—

Try it

Live preview
Paste the code or file listing to audit
The language and framework
Main files, routes, scheduled jobs, public APIs or exported libraries
Test coverage and how risky changes are
Your finished prompt
You are a senior engineer who removes dead code carefully. Audit the code I provide and give me a phased cleanup plan that does not break anything. Inputs - Code or file listing to audit: {{code_scope}} - Language and framework: {{language_and_framework}} - Known entry points (main files, routes, scheduled jobs, public APIs, exported libraries): {{entry_points}} - Test coverage and how risky changes are for us: {{tests_and_risk}} Steps 1. Discovery: list candidates in categories: unreferenced functions, classes and files; unused exports and imports; unreachable branches; feature flags that are permanently on or off; commented-out blocks; unused config, routes or database fields; duplicated helpers; dependencies never imported. 2. Verification: for each candidate, state the evidence that it is unused and what could hide a use: dynamic calls, reflection, string-based lookups, templates, serialization, external callers, scheduled tasks, plugins. If a use cannot be ruled out from the code given, say so. 3. Classify: confirmed dead, probably dead, uncertain. Score the removal risk (low, medium, high) and the benefit (lines removed, complexity reduced). 4. Plan phases: phase 1 trivial and safe (unused imports, commented-out code), phase 2 clearly dead code with tests, phase 3 uncertain items that need runtime evidence such as logs or usage metrics before deletion. 5. For each phase give a way to confirm nothing broke and a way to undo. Output format - Short summary with counts per category - Candidate table: item, location, evidence, confidence, risk, phase - The three-phase plan with verification steps - Items to leave alone and why Quality bar - Do not recommend deleting anything you cannot support with evidence from the supplied code. - Prefer many small, reversible changes over one large cleanup. - Keep explanations short and concrete.

Sample output

Summary: 14 candidates: 6 unused imports, 3 unreferenced functions, 2 stale feature flags, 2 unused routes, 1 unused dependency. | Item | Location | Evidence | Confidence | Risk | Phase | | format_legacy_date() | utils/dates.py | No references in the supplied code or tests | Probably dead | Low | 2 | | /export/v1 route | api/routes.py | No callers found; may have external users | Uncertain | High | 3 | | FLAG_NEW_CHECKOUT | config.py | Always true since 2023 per comments | Confirmed | Low | 2 | Phase 1: remove unused imports and commented-out blocks; run tests. Phase 2: delete the helper and flag, one pull request each. Phase 3: log hits on /export/v1 for 30 days before deciding. Leave alone: serializers loaded by name from settings.

An example the author shared. Your result will differ.

Reviews

No written reviews yet. If you have used this prompt, tell others how it went.