
- Updated
Find dead code and safe things to delete
This prompt finds code nobody uses anymore and tells you how confident it is that each piece is safe to remove. It also warns about hidden users, such as dynamic imports or templates, before you delete anything.
Act as a senior engineer tidying up a codebase. Language and framework: [e.g. TypeScript, Next.js] Code: [PASTE THE FILES OR MODULE] Find unused functions, variables, imports, exports, feature flags that are always on or off, commented-out blocks and duplicate logic. For each, say how confident you are that it is safe to remove and what could still use it (dynamic imports, reflection, other services, templates). Group the result into safe to delete now, check first, and keep.
Remove things in small commits and run the tests after each one, so a mistake is easy to undo.
Get a better result
A grouped list of unused functions, variables, imports, exports, flags and duplicate blocks, each with a confidence level, what could still use it, and a clear split into delete now, check first and keep.
Something marked safe is used through a dynamic import or a template.
Fix: Name those patterns in your paste, for example “routes are loaded by file name”. Search the whole project for each name before you delete it.
- You paste only one file, so exports look unused. Paste the importing files too, or run your own search for the exported names. An export used elsewhere cannot be judged from one file.
- You delete everything in one commit. Follow the tip: small commits and tests after each, so you can undo a single removal without losing the rest.
Add your package file and ask “which dependencies are not imported anywhere, and which are used only by build tools or tests?”
Take only the items in the check first group and tell me the exact search I should run for each to confirm nothing uses them.
Guides on this topic
More chat & writing prompts
See all 465 →More like this
- Do a large refactor in small safe stepsClaude Code · Cursor
- Let an AI agent fix failing tests properlyClaude Code · Cursor
- Make confusing code easy to readClaude · ChatGPT · Gemini
- Plan a safe technology migrationChatGPT · Gemini · Claude
- Refactor messy code safelyChatGPT · Gemini · Claude



