원클릭으로
speckit-worktree-clean
Remove stale or merged worktrees and reclaim disk space
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Remove stale or merged worktrees and reclaim disk space
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Think before building. Use when the user asks to reason about, analyze, evaluate, compare options, make an architecture decision, choose between approaches, think through a problem, or assess trade-offs. Also use when the user asks 'why did we...', 'should we...', 'what are our options', 'is this the right approach', or wants to frame/reframe a problem.
Archive a feature specification into main project memory after merge, resolving gaps and conflicts
Generate spec-kit configuration tailored to the existing codebase
Incrementally adopt SDD for existing features with reverse-engineered specs
Auto-discover project structure, tech stack, frameworks, and architecture patterns
Verify bootstrap output matches actual project structure and conventions
| name | speckit-worktree-clean |
| description | Remove stale or merged worktrees and reclaim disk space |
| compatibility | Requires spec-kit project structure with .specify/ directory |
| metadata | {"author":"github-spec-kit","source":"worktree:commands/speckit.worktree.clean.md"} |
Remove worktrees for branches that have been merged or are no longer needed. Safely cleans up .worktrees/ directory entries and reclaims disk space.
$ARGUMENTS
You MUST consider the user input before proceeding (if not empty). The user may specify a branch name to clean (e.g., "005-api-gateway"), "merged" to clean all merged worktrees, or "all" to clean everything.
.specify/ directory.worktrees/ directory exists and contains worktreesScan worktrees: List all worktrees and classify them:
Build cleanup plan: Based on user input, determine what to remove:
| User Input | Action |
|---|---|
| Specific branch name | Remove that worktree only (with confirmation) |
merged | Remove all merged worktrees |
stale | Remove all stale worktrees (30+ days inactive) |
all | Remove all worktrees except main (with strong warning) |
| No input | Remove merged and orphaned only (safest default) |
Present cleanup plan: Show a preview before making any changes:
# Worktree Cleanup Plan
| # | Branch | Status | Action | Disk Size |
|---|--------|--------|--------|-----------|
| 1 | 005-api-gateway | ✅ Merged | Remove | ~45 MB |
| 2 | 002-old-feature | ❌ Orphaned | Remove | ~32 MB |
| 3 | 004-chat-system | 🟡 Idle | Keep (not merged) | ~41 MB |
**Will remove**: 2 worktrees (~77 MB)
**Will keep**: 1 worktree
Confirm with user: Ask for explicit confirmation before proceeding. Removing worktrees with uncommitted changes is destructive.
Check for uncommitted changes: Before removing each worktree:
git -C .worktrees/{branch}/ status --porcelain to check for uncommitted workExecute cleanup: For each worktree to remove:
git worktree remove .worktrees/{branch-name} to safely removegit worktree unlock .worktrees/{branch-name} first.worktrees/ directorygit worktree prune after all removals to clean up stale referencesReport: Output a summary:
.worktrees/git worktree prune to clean up stale administrative files