Dead Code Elimination Loop: Claude Code, Cursor Prompt

Agent LoopsAgent Loops

Dead Code Elimination Loop: Claude Code, Cursor Prompt

Design a loop that detects unused exports, removes them one file at a time, and verifies the build passes after each removal

Design the dead code elimination loop for [YOUR_PROJECT].

Loop steps:
1. Run npx ts-prune (or [YOUR_DEAD_CODE_TOOL]) and parse the output
2. Filter results: skip files matching [EXCLUDE_PATTERNS] (e.g. index.ts re-expor
TLDR

Dead code elimination agent loop for Claude Code. Uses ts-prune to find unused exports, removes them one file at a time, verifies the build and tests still pass, and opens a PR with a summary.

How to use

  1. 1

    Replace [YOUR_PROJECT] with the specific project name to ensure the loop is tailored to your codebase, enhancing the effectiveness of the dead code elimination process.

  2. 2

    Use [EXCLUDE_PATTERNS] to define any file patterns you want to ignore, which helps streamline the filtering process and focuses on relevant code.

  3. 3

    After each run, adjust [MAX_REMOVALS] based on your team's review capacity to maintain a manageable workload while still effectively eliminating dead code.

Frequently asked questions

What is the Dead Code Elimination Loop: Claude Code, Cursor Prompt prompt used for?

Dead code elimination agent loop for Claude Code. Uses ts-prune to find unused exports, removes them one file at a time, verifies the build and tests still pass, and opens a PR with a summary.

How do I get the best results from this loop design prompt?

Paste the prompt into Claude Code, Cursor, Replit, fill in every bracketed placeholder with your specific information, then submit. The more detail you add to each placeholder, the more targeted the output. You can continue in the same conversation to refine tone, length, or focus without restarting from scratch.

Does this prompt work with Claude Code?

Yes. This prompt is optimized for Claude Code and also works well with Cursor and Replit. The structured format with a defined role and numbered steps produces consistent results across all major instruction-following models, so you can use whichever tool you prefer.

How do I access this agent loops prompt?

This loop design prompt is available through TopFreePrompts with a Lucy+ licence. You can get access with a one-time Lucy+ purchase for $109, or a $15/month plan you can cancel anytime. Both options give access to the full library of 1,000,000+ prompts across all categories.

More Agent Loops Prompts

View all

Related Prompts

View all