/feature-dev:cleanupfrom feature-dev
Bulk-deletes implemented feature artifacts (specs, plans, review history) from .feature-dev/features/ and purges stale review-server pointers. Lists only safe candidates and requires Y/N confirmation before removal. Offers to rescue Decisions Log and unticked QA items to a PR comment or docs/decisions/.
Ships in feature-dev. Installing the plugin adds it to Claude Code.
git remote get-url origingit branch --show-current.feature-dev/features/<slug>/, managed by ${CLAUDE_PLUGIN_ROOT}/scripts/features.py (pass --root <repo root>). Layout: artifact-locations.md.Run ${CLAUDE_PLUGIN_ROOT}/scripts/features.py list --json --root <repo root>. Each entry has slug, status (draft, approved, planned, running, halted, implemented, invalid), plan (steps, completed, halted_at, halt_reason, or null), issue (a ref or null), artifacts (kind, path, needs_review) and, for an invalid feature, a reason. A missing .feature-dev/features/ is an empty list.
The review history, review files and server pointer of a feature live inside its folder, so one feature is one unit: nothing is matched by slug prefix, and no review data outlives its feature.
If the list is empty, STOP and tell the user: "No features found. Nothing to clean up." Do not proceed.
Build three lists from the status of each entry.
Safe to delete:
implemented — the work is done. The features.py delete command itself removes only these, so this list and the script agree.Active work (never offer for deletion):
running or halted — a /feature-dev:tdd run is mid-flight or resumable. Deleting one discards its plan.completed record and strands a dirty working tree with no way to tell which steps already landed.draft, approved or planned — work in progress.Ambiguous (do not offer by default — the user can delete manually):
invalid — a broken feature folder; surface its reason, never include it.While a review page is served, .feature-dev/features/<slug>/reviews/.url holds its address. For every feature that has one, other than a running or halted feature, Read it and probe <url>alive (the pointer ends in /): curl -s -o /dev/null --max-time 2 <url>alive. /alive answers without a token and without resetting the server's idle timer, so the probe never keeps a forgotten review open. Exit 7 (connection refused) means no server — the pointer is stale. Any other exit means something answers — a review in progress:
review in progress — the review's verdict is about to be applied to it;Every stale pointer, of any feature, goes in the stale-pointer list and is removed on its own with review_server.py purge --pointer <slug>, because review_server.py url would otherwise keep printing a dead URL. A pointer of a feature that is deleted below goes with its folder and needs no purge.
The feature folder is gitignored, so anything that exists only in its spec is gone once it is deleted. For each feature in the safe-to-delete list that has a spec artifact:
issue is set (<owner>/<repo>#<N>), run the gh preflight — on failure, treat the SPEC as not current (per its "cleanup's 'published and current' check" rule) and continue to step 2. On success, compute the three Fingerprints: local (issue_spec.py section <SPEC> | issue_spec.py fingerprint -), recorded (issue.fingerprint in the feature's feature.json), and issue (gh issue view <N> --repo <owner>/<repo> --json body -q .body | issue_spec.py fingerprint -). All three equal → the SPEC is published and current: skip step 2 for it, it is not rescuable, and it goes straight to Phase 2 without the rescue question — it still follows the existing status rules for deletion. Any mismatch → the SPEC is not current: note its #<N>, and continue to step 2, where a SPEC with an issue is rescuable regardless of what step 2 finds — the mismatch itself (an unpublished local edit, or an issue that moved since the last publish) is the thing that would otherwise be lost silently. A feature with no issue at all also continues to step 2, under the decision/QA gate below — nothing in this step changes for it.## Decisions Log (written by /feature-dev:tdd), up to the next ## heading or end of file. Non-empty means at least one entry, not just the heading.- [ ] line under ## QA Checklist, up to the next ## heading. Keep the ### group heading (Happy path / Edge cases / Empty states / Error states) each item sits under; ticked - [x] items were verified by the user and are not rescued. An unticked item may have been checked and never ticked, so it is reported as unticked, not as unrun.A published-and-current SPEC is not rescuable and goes straight to Phase 2. A SPEC with an issue that is not current is always rescuable, even with neither a decision nor pending QA — its difference from issue #<N> is itself worth a rescue question, via Republish to #<N> in Phase 2a (below). A SPEC with no issue is rescuable only when it has a decision or pending QA; otherwise it goes straight to Phase 2.
Present a structured summary to the user:
Feature-dev cleanup — candidate inventory
Safe to delete (N features):
- <slug> — "<feature>" — implemented[ — holds: N decisions, M unticked QA items]
...
Active work (left alone, M features):
- <slug> — status: <draft|approved|planned|running|halted|review in progress>
...
Ambiguous (not auto-included, K features):
- <slug> — invalid: <reason>
...
Stale server pointers (P, no server answering):
- <slug>
Counts only — never list the individual files. Omit empty groups, and also list any feature skipped for a live server.
If the "Safe to delete" list and the stale pointers are both empty, STOP and tell the user: "No safe-delete candidates. M active features left alone, K ambiguous ones surfaced for manual review." Do not prompt.
If the "Safe to delete" list is non-empty and Phase 1b found rescuable content, run Phase 2a before the confirmation below; otherwise go straight to it.
Find each spec's PR. A spec's PR is the one for the branch in its own frontmatter branch:, not the current branch — cleanup often runs from another branch than the one the feature shipped on. For each rescuable spec with a branch: and at least one decision or pending QA item, run gh pr view <branch> --json number,state,comments. Offer the PR option only when that returns state: OPEN. A spec with no branch:, a "no pull requests found" error, or a merged or closed PR means no PR option for that spec — say which in one line. Skip this step for a spec that is rescuable only because it is not current (no decision, no pending QA) — there is nothing to put in a PR comment.
Build the text per spec. Skip this step too for a spec rescuable only because it is not current — it has no decisions or QA to write up; its rescue text is the issue diff itself, covered directly in step 3's question. For every other rescuable spec, headed with the slug so a rerun can recognise them:
## Decisions — <slug>
<the Decisions Log entries, verbatim>
## Pending QA — <slug>
Unticked QA items:
<the unticked items, verbatim, under their group headings>
Include only the sections the spec has content for.
Ask. One AskUserQuestion question per rescuable spec, at most 4 per call — batch the rest into further calls. Header Rescue (the header is capped at 12 characters, so the slug goes in the question). Question:
issue fingerprint mismatch is the only reason it is here): "the spec of differs from issue # — local edits were never published, or the issue changed since. Keep it before deleting?"Options:
Comment on PR #<n> — preview: the exact comment text from step 2. Omitted when step 1 found no open PR for this spec, or when the spec has neither a decision nor pending QA to comment (step 1/2 were skipped for it).Save to docs/decisions/<slug>.md — preview: the file content. The description says it is a tracked file the user commits; this command does not commit. Omitted for the same no-decision/no-QA case.Delete anyway — nothing is kept; the Phase 3 report lists what was lost.Republish to #<N> — only offered when the feature has an issue (<owner>/<repo>#<N>). A rescuable spec with one is already not current (Phase 1b step 1 sends a published-and-current spec straight to Phase 2, never through this question). Preview: "runs the publish algorithm against issue #". Picking it runs issue-store.md's Publish algorithm against this spec and target #<N>, start to finish — its gh preflight, the AC-4 conflict ask if the issue's section changed since the last publish, and the AC-5 re-read-and-verify. Do not restate those steps here — follow the reference. For a spec with no decision/QA content, this and Delete anyway are the only two options.Apply the choice. Writing to a PR is visible to reviewers, so it happens only for a spec where the user picked that option — never as a default or a fallback from a failed save. The rescue is a new comment; the PR body is never edited, because a body rewrite can overwrite what the author or a bot put there since it was read.
## Decisions — <slug>, ## Pending QA — <slug>), report "already on PR #" and treat the spec as rescued — a rerun never posts twice. Otherwise Write the step 2 sections not already there to a file at a path unique to this spec and run — feature-dev-cleanup-<slug>-<random>.md in the session scratchpad if one is listed, else under /tmp/. Read the path first and pick another name if it already exists, so a stale file from an earlier run is never posted. Run gh pr comment <n> --body-file <file>. Then re-run gh pr view <branch> --json comments and confirm a comment now carries each heading; a heading still missing after posting is a failed rescue.docs/decisions/<slug>.md exists, Read it and Write its content plus the sections it does not already have; otherwise Write a new file with a # <feature> title and the sections.#<N> from the feature's own issue. On the reference's AC-4 mismatch ask, offer only "overwrite the issue" or "cancel" — this command does not carry Import's tools (no gh issue create, no review_server.py snapshot), so "import the issue's version instead" is out of scope here; treat that pick the same as Failure below, since nothing was published. On a verified publish (the reference's step 7, which records the fingerprint on the feature), the spec's content now lives on the issue and its feature keeps its place in the delete list.gh or Write fails, or the verification above finds a heading missing (PR) or a fingerprint mismatch (Republish), show the error verbatim and mark the spec rescue failed — for Republish, say the republish failed. A failed spec's feature is removed from the delete list — deleting it would lose exactly what the user chose to keep (for Republish, the content the republish tried to save).Then continue to the confirmation, with N recounted after moving rescue-failed features to Active work. P is the stale pointers.
Run Phase 3's commands now with --dry-run: ${CLAUDE_PLUGIN_ROOT}/scripts/features.py delete <slug> --dry-run --root <repo root> once per feature in the delete list, and review_server.py purge --pointer <slug> --dry-run for the stale pointers. Each prints the paths it would remove and removes nothing. A refused: … line (exit 1) takes that feature out of the delete list and into Active work or Ambiguous with the refusal as its reason — a git-tracked file inside the folder is refused even with --force — so the question never promises a deletion that will not happen.
Yes, delete all — proceed with deletionCancel — stop, delete nothingIf the user chose Cancel, report "Cancelled. No files deleted.", then one line per spec already rescued in Phase 2a (Rescued <slug> → PR #<n> or → docs/decisions/<slug>.md (uncommitted — commit it yourself)) — the comment or file already exists and cancelling does not undo it — and STOP.
If the user chose Yes, delete all:
--dry-run — never rm:
${CLAUDE_PLUGIN_ROOT}/scripts/features.py delete <slug> --root <repo root>
It removes the whole feature folder (spec, plan, history, reviews, pointer) only when the feature is implemented; any other state is refused naming it. Never pass --force: this command deletes only what Phase 1 judged safe. A refused: … line (exit 1) means that feature was kept — show it verbatim and count it as kept.${CLAUDE_PLUGIN_ROOT}/scripts/review_server.py purge --pointer <slug> --root <repo root>
purge skips git-tracked files and symlinks and prints skipped <path>: <reason> for each; exit 2 means an argument is invalid and nothing was deleted.Deleted feature <slug>
Removed stale pointer <slug>
Kept <slug> — refused: <reason>
...
Total: N features and P stale pointers removed.
Rescued <slug> → PR #<n> (comment) or → docs/decisions/<slug>.md (uncommitted — commit it yourself); Republished <slug> → issue #<n> (Republish, verified); Kept <slug> — rescue failed: <error> (or, for Republish, — republish failed: <error>); or, for Delete anyway, Lost from <slug>'s spec: followed by the decisions (one line each) and the unticked QA items, so the loss is on record in this session.features.py delete refuses a folder with a tracked file even with --force, and purge skips tracked files; surface the refusal and let the user decide whether to commit or untrack first.features.py delete (and purge --pointer for stale pointers), never rm. A pre-approved rm pattern ends in a wildcard that also matches extra paths; delete accepts one feature slug, refuses a symlinked folder or anything outside .feature-dev/features/, and removes only an implemented feature.curl on /alive, not review_server.py url. url only reports that the pointer file exists; a server killed without cleanup leaves it behind and url still exits 0. Probe /alive, not the page: the page resets the server's idle timer and renders the whole document.features.py delete <slug>); this command exists for bulk cleanup of unambiguous candidates only.What the command file sets; muted values are Claude Code's defaults
feature-dev, artifact-cleanup, implemented-specs, bulk-delete
7-day visitors to each command page
8 commands in this plugin
/explore-planContextUse when starting a feature that touches multiple parts of the codebase and you need a
structured implementation plan before coding.
Do NOT use for simple bug fixes or single-file changes.
/hardenContextUse after an implementation is finished — typically right after /feature-dev:tdd — to review it in
fresh context (defects, spec conformance and tech debt at once), verify every finding, fix the ones
you approve, and re-review what the fixes changed. Replaces running /code-review:staged,
/code-review:receive and /code-review:tech-debt by hand.
Do NOT use for a PR with bot comments (/code-review:triage), for a read-only review
(/code-review:staged or :branch), or before the implementation is done.
/plan-reviewContextUse to re-validate a PLAN-*.md edited by hand, or one written before explore-plan reviewed its own plans. Outputs Blocking / Should Address / Nice to Have findings.
Do NOT use right after /feature-dev:explore-plan (it already ran this review), for code review, or for SPEC review (use /feature-dev:spec-review).
/reviewContextUse to review a SPEC-*.md or PLAN-*.md in the browser — outline, decision cards, text-anchored comments, diff against the previous version — and apply the verdict.
Do NOT use for a structural gap check (use /feature-dev:spec-review or /feature-dev:plan-review) or for code review.
/specContextUse before writing code when requirements are ambiguous or a feature has non-obvious scope.
Do NOT use for simple, self-evident changes.
/spec-reviewContextUse to validate a SPEC-*.md for gaps before planning or implementation. Outputs Blocking / Should Address / Nice to Have findings.
Do NOT use to verify implementation (use /prd:validate).
npx claudepluginhub juanmhidalgo/claude-plugins --plugin feature-devOther plugins' commands for the same job