Qualityprompt onlyModerate

Dead Code Eliminator

Automatically identifies and removes unused code to improve codebase quality and maintainability. This loop performs iterative scans for dead code, removes it gradually, and ensures no regressions are introduced.

← all loops
dead codecode cleanupstatic analysismaintainabilityoptimization

Goal

Remove unused code

How to Run

This loop guides an AI agent to iteratively identify and remove dead code while ensuring safety. It uses a dead code scan tool and stops when no unused code remains.

  1. 01

    Start the loop

    Initiate the loop in your coding environment (e.g., Cursor, Claude Code).

  2. 02

    Monitor iterations

    Watch as the agent scans for dead code, removes it, and checks again.

  3. 03

    Verify completion

    Ensure the 'Analysis clean' condition is met and the exit condition is reached.

Workflow Steps

  1. 01

    Identify dead code

    Use static analysis or linting tools to detect unused functions, variables, or modules.

  2. 02

    Run check command

    Execute the configured dead code scan to generate a report of unused code.

  3. 03

    Inspect results

    Review the scan output to distinguish true dead code from false positives.

  4. 04

    Remove dead code

    Delete confirmed unused code while preserving active logic and dependencies.

  5. 05

    Document changes

    Log all deletions for transparency and audit purposes.

  6. 06

    Repeat until clean

    Loop back to step 1 if unused code is still detected.

  7. 07

    Exit on success

    Terminate when the dead code scan reports no issues.

Kickoff Prompt

Start the "Dead Code Eliminator" loop.

Goal: Remove unused code
Max iterations: 10
Between iterations run: dead code scan
Exit when: Analysis clean


Please analyze this codebase to identify and remove all dead code. Begin by running a dead code scan to detect unused functions, variables, and modules. After each removal, rerun the scan to confirm the codebase is now clean. Do not proceed if any false positives are detected without explicit approval.

Self-pace this loop. After each iteration, run `dead code scan` and evaluate the output, and only continue if the exit condition is not met (Analysis clean). Stop when the exit condition passes or 10 iterations are reached. Give a short status update each pass.

Guardrails

hardcoded
  • ·Never remove code that is referenced elsewhere or conditionally used (e.g., feature flags).
  • ·Run in a version-controlled environment to allow easy rollback of changes.
  • ·Use a reliable dead code detection tool compatible with your tech stack.
  • ·Manually review critical deletions before finalizing them.
  • ·Avoid modifying files outside the scope of dead code removal.

Flow Diagram

rendering…

Related loops — Quality