speckit-git-clean
Clean up the current feature worktree, branch, issue, and any uncommitted changes.
SKILL.md.specify/extensions/git/.specify-dev/agent-commands/claude/speckit-git-clean/SKILL.md
GitHubClean Current Feature
Remove a feature worktree that is no longer needed. By default, the command resolves the feature from the current worktree's git branch, then discards uncommitted changes, removes the feature worktree, deletes the feature branch, and closes any linked GitHub issue.
User Input
$ARGUMENTS
You MUST consider the user input before proceeding (if not empty).
Behavior
- Parse arguments. Support
--force/-f,--worktree <path>,--spec <path>, and--issue <number>. A single positional target is also allowed and may be a worktree path, a spec directory, or an issue number. - Resolve the cleanup target in this order:
- an explicit
--worktreepath or worktree-like positional path - an explicit
--specpath orspecs/<slug>positional path - an explicit
--issuenumber or#<issue>positional value - the current worktree (
git rev-parse --show-toplevel)
- an explicit
- Derive
feature_directoryand the feature branch from git in the target worktree, and readsource_issuefrom its.specify/feature.jsonwhen present. The worktree path is never read from a file — doing so is how this command used to be pointed at the previous feature's worktree (issue #33). - If the target worktree has uncommitted changes:
- abort with a file list unless
--forcewas passed - when
--forceis passed, discard tracked and untracked changes before removal
- abort with a file list unless
- Close the linked GitHub issue when
source_issueis present andghis available. - Remove the feature worktree with
git worktree removewhen the target is not the primary checkout. - Delete the feature branch with
git branch -Dafter the worktree is removed. - Leave a short status summary describing what was cleaned and what was skipped.
Execution
- Bash:
.specify/extensions/git/scripts/bash/clean.sh [--force|-f] [--worktree <path>] [--spec <path>] [--issue <number>] [target]
Graceful Degradation
- If Git is not available or the current directory is not a repository: warn and exit.
- If no
specs/<branch>directory exists for the current branch and no explicit target is provided: refuse and explain how to point the command at a worktree, spec, or issue. - If
ghis missing or the issue cannot be resolved: the cleanup still proceeds and prints a notice. - If the target is the primary checkout, the script will not remove that checkout in place; it will only clean the working tree and report the branch/worktree details so the user can rerun from a different checkout if needed.