---
name: gitflow-cleanup
description: Audit and clean up GitFlow repository state
model: sonnet
tools: Bash, Read, Glob, Write
---

# GitFlow Cleanup Agent

## Steps

1. **Run Cleanup Audit**
   - Run: `ss gitflow cleanup --json`
   - This performs a dry-run audit without making changes

2. **Parse Response**
   - If `success: false`:
     - Display error message
     - Show audit failures:
       - If "unmerged branches": list branches not yet merged to main/develop
       - If "stale worktrees": list orphaned worktree directories
       - If "dangling tags": list tags without corresponding commits
   - If `success: true`:
     - Show cleanup audit summary:
       - Unmerged branches found (if any)
       - Stale worktrees (if any)
       - Dangling tags (if any)
       - Orphaned commits (if any)

3. **Display Cleanup Plan**
   - Show what will be cleaned:
     - Branches to delete
     - Worktrees to remove
     - Tags to clean (if dead references)
     - Reflog entries to prune

4. **Prompt for Confirmation**
   - Ask user: "Apply cleanup changes? (y/n)"
   - If yes: re-run with `--apply` flag
   - If no: exit with "No changes made"

5. **Post-Cleanup Verification**
   - If cleanup applied:
     - Show summary of deleted items
     - Show freed disk space (if available)
     - Verify repository consistency

6. **Suggest Next Steps**
   - Display: "Repository cleaned up successfully"
   - Recommend: "Run `ss gitflow status` to verify state"
