Skip to content
Development
Command

/cleanup

Clean up merged branches, worktrees, and temporary files

From plugin
claude-plugin-prd-workflow
1227 skills17 agents27 commands

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/cleanup

Context preview

What this command does when you run it.

Clean up merged branches, worktrees, and temporary files

Command definition

cleanup.md
name: cleanup
description: Clean up merged branches, worktrees, and temporary files
category: Development Tools
version: 0.4.2

Cleanup Command

Clean up development artifacts after PRD completion.

Purpose

Maintain clean repository state:

  • Remove merged branches (local and remote)
  • Delete unused worktrees
  • Clean up temporary files
  • Free disk space
  • Maintain organized git history

Workflow

1. Scan for Cleanup Opportunities

**Identify**:

  • Merged branches (local)
  • Merged branches (remote)
  • Orphaned worktrees
  • Temporary files in `.prds/`
  • Old debug sessions

**Display summary**:

🧹 Cleanup Opportunities

Merged Branches (local):
• feature/PRD-003-oauth2 (merged 5 days ago)
• feature/PRD-005-dark-mode (merged 2 days ago)

Merged Branches (remote):
• origin/feature/PRD-003-oauth2

Worktrees:
• ../worktrees/PRD-003-oauth2 (orphaned)

Temp Files:
• .prds/thoughts/ (347 MB)
• .prds/debug-sessions/ (old sessions)

Total space recoverable: ~450 MB

2. Confirm Cleanup

Ask user to confirm:

  • Which categories to clean
  • Dry-run option available
  • Safety checks (won't delete unmerged work)

3. Execute Cleanup

**Local branches**:

git branch -d feature/PRD-XXX-name

**Remote branches**:

git push origin --delete feature/PRD-XXX-name

**Worktrees**:

git worktree remove ../worktrees/PRD-XXX-name

**Temp files**:

  • Keep last 30 days of debug sessions
  • Archive old thoughts to `.prds/archive/`

4. Report Results

āœ… Cleanup Complete

Removed:
• 3 local branches
• 2 remote branches
• 1 worktree
• 120 MB temp files

Space freed: 450 MB

Your repository is now clean! šŸŽ‰

Safety Features

**Protected branches**:

  • main/master: Never deleted
  • develop: Never deleted
  • Current branch: Never deleted

**Unmerged work**:

  • Check merge status before deletion
  • Warn if branch has unmerged commits
  • Require --force flag for unmerged branches

**Backup**:

  • Archived files moved to `.prds/archive/`
  • Can be restored if needed

Flags

**Dry-run** (`--dry-run`):

  • Show what would be deleted
  • Don't actually delete anything

**Force** (`--force`):

  • Delete unmerged branches (use carefully)

**Categories**:

  • `--branches-only`: Only clean branches
  • `--worktrees-only`: Only clean worktrees
  • `--files-only`: Only clean temp files

**Examples**:

/cleanup                    # Interactive cleanup
/cleanup --dry-run          # Preview only
/cleanup --branches-only    # Only branches
/cleanup --force            # Include unmerged branches

Configuration

{
  "cleanup": {
    "auto_delete_remote": false,
    "keep_debug_sessions_days": 30,
    "archive_thoughts": true,
    "protected_branches": ["main", "master", "develop"]
  }
}

Success Criteria

  • āœ… All merged branches cleaned
  • āœ… Orphaned worktrees removed
  • āœ… Old temp files archived
  • āœ… Disk space freed
  • āœ… No unmerged work lost
  • āœ… Repository clean and organized

---

**Version**: 0.4.2 **Plugin**: claude-prd-workflow v0.4.2

Read more
Ships withclaude-plugin-prd-workflow

The complete Claude Code plugin for Product-Driven Development Transform PRDs from ideas to shipped features with AI-powered review, guided implementation, and automated quality gates. Never ship unclear requirements again.

Get the whole plugin

Other commands on claude-plugin-prd-workflow.