Dead Code Sweep
Find unused files, exports, and dependencies with a static analyzer, remove them in small batches, and run the build and tests after each removal.
Copy the Dead Code Sweep loop
Stops when the analyzer reports no unused files, exports, or dependencies that are safe to remove, or after 8 iterations. Edit the settings block, then paste the whole prompt into your agent.
You are running the "Dead Code Sweep" loop. Settings (edit before running): - Analyzer command: npx knip --reporter json - Check command: npm run build && npm test - Protected paths: public API entry points, scripts/, migrations/ - Max iterations (batches): 8 Goal: remove code and dependencies that nothing uses, without breaking the build or tests. Each iteration: 1. Run the analyzer and list unused files, exports, and dependencies. 2. Pick one related batch, at most 10 items (for example, everything left over from one removed feature). 3. For each item, search the repo for indirect uses: dynamic imports, string-based lookups, framework conventions (routes, pages, plugins), config files, and tests. Skip anything in protected paths or anything with a possible indirect use. 4. Delete the batch and run the check command. 5. If the check fails, restore the batch, mark those items as "keep", and note why. 6. Log: batch description, items removed, items kept. Stop when: - The analyzer finds nothing left that is safe to remove. Success. - You reach the max iteration count. Rules: - Never delete protected paths, migrations, or anything exported from a published package's entry point. - Do not refactor or rename while sweeping. Only delete. - Remove a dependency only after confirming no file imports it and no script or config uses its binary. Final report: files, exports, and dependencies removed, lines deleted, and items kept with reasons.
When this loop fits
- A codebase has grown for years and nobody is sure which modules are still used.
- A feature was removed but its helpers, styles, and dependencies stayed behind.
- You want a smaller bundle or faster installs without risky manual archaeology.
What happens on each pass
The agent repeats these steps until the stop condition holds or it runs out of iterations.
- Analyze. Run an unused code analyzer and list unused files, exports, and dependencies.
- Check for hidden uses. Search for dynamic imports, string references, config files, and public API entry points before deleting.
- Remove one batch. Delete a small, related batch of unused code.
- Build and test. Run the build and tests, and restore the batch if anything fails.
MCP servers for this loop
The 6 strongest of 936 matching servers, ranked by how closely they fit and then by trust score.
- 75Trust score 75 of 100, Good
seekstone
by shaqmughal · TypeScript
Filesystem-direct Obsidian MCP server — search and edit your vault with low context-tax.
RegistryLicenseQualityMaintenanceLicense: A. MIT is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: A. Last commit or release 13 days ago. - 69Trust score 69 of 100, Good
Standalone MCP filesystem tools server — view, edit, shell, workdir.
RegistryLicenseQualityMaintenanceLicense: A. Apache-2.0 is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: A. Last commit or release 11 days ago. - 55Trust score 55 of 100, Fair
Cited, searchable memory of a codebase: hybrid search, git history, impact analysis, doc drift.
RegistryLicenseQualityMaintenanceLicense: Not graded. No license is recorded for this server.Quality: Not graded. No README or tool list has been captured yet.Maintenance: Not graded. No commit or release date has been recorded. - 55Trust score 55 of 100, Fair
Secure filesystem access for AI agents with configurable directory and file type restrictions
RegistryLicenseQualityMaintenanceLicense: Not graded. No license is recorded for this server.Quality: Not graded. No README or tool list has been captured yet.Maintenance: Not graded. No commit or release date has been recorded. - 55Trust score 55 of 100, Fair
Self-hosted semantic code search MCP for Claude Code & Cursor. Multi-repo, AST-aware, stays local.
RegistryLicenseQualityMaintenanceLicense: Not graded. No license is recorded for this server.Quality: Not graded. No README or tool list has been captured yet.Maintenance: Not graded. No commit or release date has been recorded.
55Trust score 55 of 100, FairLocal raw DNA analysis: haplogroups, traits, ClinVar, pharmacogenomics. Nothing is uploaded.
RegistryLicenseQualityMaintenanceLicense: Not graded. No license is recorded for this server.Quality: Not graded. No README or tool list has been captured yet.Maintenance: Not graded. No commit or release date has been recorded.
How to run this loop
- Connect the tools. Install a server the loop can use, for example seekstone, or rely on your agent's built-in terminal and file access.
- Edit the settings block. Replace the example commands, targets, and limits with your project's own. Keep the iteration cap low on the first run.
- Paste it into an agent session. Start a fresh session in Claude Code, Cursor, or VS Code agent mode, in the repository root, and paste the prompt.
- Review before you merge. Read the final report and the diff. The loop leaves its work for you to review rather than shipping it.
Dead Code Sweep questions
When does the Dead Code Sweep loop stop?
It stops as soon as the analyzer reports no unused files, exports, or dependencies that are safe to remove. It also stops after 8 iterations by default, or earlier when the prompt's own stop rules say it is stuck, and then reports what changed and what is left. Change the cap in the settings block at the top of the prompt.
Which analyzer should I use to find dead code?
Knip covers JavaScript and TypeScript files, exports, and dependencies in one pass. For Python, Vulture finds unused functions and variables. Go and Rust compilers already warn about unused code, so their own warnings work as the analyzer.
How does the loop avoid deleting code that is used dynamically?
Before each deletion the agent searches for string references, dynamic imports, and framework conventions such as file-based routes. Protected paths are never touched, and any batch that breaks the build or tests is restored and marked as keep.