一键导入
speckit-worktrees-clean
Remove merged, orphaned, or stale worktrees and reclaim disk space
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Remove merged, orphaned, or stale worktrees and reclaim disk space
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Generate a custom checklist for the current feature based on user requirements.
Identify underspecified areas in the current feature spec by asking up
Run a budget-aware exploration loop that externalizes every finding into the harness state files
Initialize externalized harness state (budget, candidates, curated set, evidence, verification, observations) for the active feature
Synthesize curated evidence and verification records into the feature's research.md with a coverage table
Render a compact, budget-aware slice of the harness state with a recommended next action
| name | speckit-worktrees-clean |
| description | Remove merged, orphaned, or stale worktrees and reclaim disk space |
| compatibility | Requires spec-kit project structure with .specify/ directory |
| metadata | {"author":"github-spec-kit","source":"worktrees:commands/speckit.worktrees.clean.md"} |
Remove worktrees for branches that have been merged or are no longer needed. Safely cleans up worktree directories and reclaims disk space.
$ARGUMENTS
You MUST consider the user input before proceeding (if not empty). The user may specify:
005-api-gateway) — remove that worktree onlymerged — remove all merged worktreesstale — remove stale worktrees (30+ days inactive)all — remove all worktrees (with strong warning)git worktree list — should show more than the primary checkout)Scan worktrees: List all linked worktrees and classify them:
all specifiedBuild cleanup plan: Based on user input, determine what to remove.
| User Input | Targets |
|---|---|
| Specific branch | That worktree only (with confirmation) |
merged | All merged worktrees |
stale | All stale worktrees (30+ days) |
all | Everything except the primary checkout |
| No input | Merged + orphaned only |
Present cleanup plan (always show before acting):
## Worktree Cleanup Plan
| # | Branch | Path | Status | Dirty | Action |
|---|--------|------|--------|-------|--------|
| 1 | 005-api-gateway | ../MyProject--005-api-gateway | Merged | clean | REMOVE |
| 2 | 002-old-feature | ../MyProject--002-old-feature | Orphaned | clean | REMOVE |
| 3 | 004-chat-system | ../MyProject--004-chat-system | Idle | 2 files | KEEP |
**Will remove**: 2 worktrees
**Will keep**: 1 worktree
Proceed? (confirm before executing)
Wait for user confirmation before executing any removal.
Check for uncommitted changes before each removal:
git -C <path> status --porcelainExecute cleanup for each confirmed worktree:
git worktree remove <path> (or git worktree remove --force <path> if confirmed for dirty)git worktree unlock <path> firstgit worktree prune after all removalsReport summary:
git worktree prune.worktrees/ dirs equally