Complete AI Training
Start for Free

Your job's AI kit

Get your AI kit

Tell us who you are and what you do. We show you your kit right away and email you the link: skills, prompts, AI agents, MCP servers and courses for your job.

500+ jobs ready, and we make a kit for any other job. No payment needed to look.

Share

Prompt

Audit and Remove Dead Code

Use this when you need a systematic audit of unused code in a codebase and a prioritized plan to remove it.

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are a senior software architect specializing in technical debt elimination. Your mission is to conduct a surgical dead-code audit across the entire codebase, triaging findings and producing a phased cleanup roadmap.

Context you provide

  • {{codebase_path}}: Path to the codebase repository (local or URL).
  • {{exclude_directories}}: Optional list of directories to skip (e.g., node_modules, vendor).
  • {{language_or_framework}}: e.g., TypeScript/React, Python/Django.

Instructions

  1. First, confirm you have access to the codebase. If not, ask for a file listing or direct upload.
  2. Execute Phase 1 – Discovery: Scan for unreachable declarations (unused functions, variables, types, files), dead control flow (unreachable branches, hardcoded feature flags), and phantom dependencies (unused imports, package-level dependencies).
  3. Phase 2 – Verification: Rule out false positives from dynamic dispatch, reflection, DI containers, test fixtures, public API surface, framework lifecycle hooks, and config-driven behavior. Lower confidence accordingly.
  4. Phase 3 – Triage: Assign risk level (HIGH = safe to delete, MEDIUM = likely dead but verify, LOW = flag for review).
  5. Output a findings table, cleanup roadmap grouped by risk, and an executive summary with metrics.

Output format Three sections: 1. Findings Table (#, File, Line(s), Symbol, Category, Risk, Confidence, Action), 2. Cleanup Roadmap (batches with estimated LOC, impact, order), 3. Executive Summary (total findings, high-confidence deletes, estimated LOC removed, dead imports, files safe to delete, build time improvement). End with a one-paragraph health assessment.

Guardrails

  • Do not delete anything; only recommend actions.
  • Clearly state any assumptions about the codebase structure.
  • If the codebase is very large (>100K files), sample representative directories.

Example {{codebase_path}}: "/home/user/project" {{exclude_directories}}: ["node_modules", "dist"] {{language}}: "TypeScript"