feature-purge
Safely remove an entire feature and every dead reference it leaves behind — not just the folder you point at, but the sibling folders in other architecture…
by Andersonlimahw★ 19 GitHub stars
Install feature-purge in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
About this skill
Feature Purge
Delete a feature for real. You give it one path; it finds the rest of the feature across the codebase, removes it, cleans every reference, and proves the quality gate is still green.
The danger this skill exists to kill: you delete screens/Bets/ but leave usecases/bets/, the repository impl, the navigation route, the barrel export *, and 12 import { Bets } from ... lines — half-dead feature, red build, ghost code.
Invocation
/feature-purge <path> [<path2> ...]
<path> is the primary folder/file to remove (usually the most visible one — a screen, a module). The skill derives the feature slug from it (folder name, normalized: Bets → bets/Bets) and uses that slug to discover the rest.
Workflow (do in order, do not skip)
1. Scope — derive slug + map the primary target
- Resolve the path. Confirm it exists and is inside the repo.
- Derive
slugfrom the leaf name. Keep both casings (Bets,bets) and obvious variants (bet,betting) — list them, you'll grep for all. - List the primary target's files (these are the main removals).
2. Discover sibling targets across layers (the whole point)
Most codebases split one feature across parallel directories (layers, packages, test mirrors). Find the siblings by slug:
- Detect the project's layering from the path. Generic heuristic: take the repo's top source roots (e.g.
src/,app/,lib/,packages/*,test/,__tests__/) and look for any directory or file whose name matches the slug under each root. - Typical siblings: business logic, data/repository, domain/model, infrastructure, state/store, hooks, types, tests, fixtures, styles.
- Build a candidate list. Mark each
confident(name is an exact slug match in a recognized layer) ormaybe(fuzzy / shared dir).
3. Ask before the deep sweep
The slug match finds folders. It does NOT find scattered references (a single import, a route string, an i18n key, a feature-flag entry). Those need a repo-wide grep that is slower and noisier.
Use AskUserQuestion to confirm scope before the expensive search:
- Question: run the deep reference sweep (grep the whole repo for the slug + import paths)?
- Options: Yes — full sweep (recommended) / Targeted only (just the listed folders) / Let me edit the target list first.
If the user already said "be thorough" / "remove everything", skip the question and do the full sweep.
4. Find references (orphan hunt)
For every file about to be removed, grep the repo for things that point at it:
import/require/ re-export (export * from, barrelindexfiles).- Registry/DI wiring (a container that binds the repository, a
useCasesmap). - Navigation routes / deep links / route-name constants.
- i18n keys namespaced under the slug.
- Feature flags, config entries, menu/tab definitions referencing it. Record each as a reference to clean with file + line.
5. Confirm the plan, then execute
Print the plan: main removals · sibling removals · references to clean. Then:
- Delete folders/files (
rm/git rm). - In each referencing file, surgically remove ONLY the orphaned lines (the import, the route entry, the barrel re-export, the i18n key). Do not refactor adjacent code (Karpathy surgical rule).
- After removing imports, remove anything those removals just orphaned (now-unused local imports/vars) — but only what YOUR change orphaned.
6. Quality gate — must end 100% green
Run the project's gate (typecheck / lint / i18n check / tests / build — whatever the repo has). If anything fails because a reference was missed, fix it and re-run. Loop until green. Never finish red.
7. Write the report
Write feature-purge-<slug>-<YYYY-MM-DD>.md (in the repo's docs/reports dir if one exists, else repo root). Use the template below.
Report template
# Feature Purge — <slug>
Date: <YYYY-MM-DD> · Invoked with: `<paths>`
## Removed — primary
- <path/file> (N files)
## Removed — related (other layers)
- <path/file> — <layer> — confident|maybe
## Modified — references cleaned
- <file>:<line> — removed <import|route|barrel export|i18n key|DI binding>
## Quality gate
- typecheck: ✅ | lint: ✅ | i18n: ✅ | tests: ✅ (<n> passed) | build: ✅
## Notes
- <anything skipped, any `maybe` left in place and why>
Rules
- One path in, whole feature out. Always look for siblings in other layers — that is the core value.
- Ask before the repo-wide sweep unless the user opted into thoroughness.
- Surgical: every line you touch traces to removing this feature. No drive-by refactors.
- Never leave the gate red. If you cannot make it green, stop and report what blocks it instead of deleting more.
- Optimized: derive the slug once, grep once per scope, fix-and-recheck only the failing gate step.
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
Bundled files
- plugin.json
FAQ
What does the feature-purge skill do?
Safely remove an entire feature and every dead reference it leaves behind — not just the folder you point at, but the sibling folders in other architecture layers, the imports/registries/routes/i18n keys that point to it, and any newly-orphaned code. Verifies the quality gate stays 100% green and writes a Markdown removal report. Use when deleting a feature, screen, module, or directory and you need it gone WITHOUT leaving dead files or dead code. Triggers on /feature-purge <path>, "remove this feature", "delete this folder safely", "apaga essa feature sem deixar código morto", "limpa essa screen e as camadas".
How do I install the feature-purge skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the feature-purge skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
docx
AnthropicUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
xlsx
AnthropicUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
pptx
AnthropicUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…