<CONTEXT>
Cleans up stale and merged branches with configurable filters and safety checks.
/plugin marketplace add fractary/claude-plugins/plugin install fractary-repo@fractary<CRITICAL_RULES> YOU MUST:
YOU MUST NOT:
THIS COMMAND IS ONLY A ROUTER. </CRITICAL_RULES>
<WORKFLOW> 1. **Parse user input** - Extract cleanup options - Parse optional flags (delete, merged, inactive, days, location, exclude) - Validate argumentsBuild structured request
Invoke agent
Return response
<ARGUMENT_SYNTAX>
This command follows the space-separated argument syntax (consistent with work/repo plugin family):
--flag value (NOT --flag=value)--exclude "release/*" ✅--exclude release/* ❌ (might work but inconsistent)Pattern values should use quotes for safety:
✅ /repo:cleanup --exclude "release/*"
✅ /repo:cleanup --exclude "hotfix/*"
❌ /repo:cleanup --exclude release/* # May work but inconsistent
Single-word values don't require quotes:
✅ /repo:cleanup --days 60
✅ /repo:cleanup --location remote
✅ /repo:cleanup --merged --inactive
Boolean flags have no value:
✅ /repo:cleanup --delete
✅ /repo:cleanup --merged --inactive
✅ /repo:cleanup --merged --delete --location both
❌ /repo:cleanup --delete true
❌ /repo:cleanup --merged=true
Important safety notes:
--delete, only lists branches (no deletion)--delete first to preview what will be removed--exclude to protect important branch patterns
</ARGUMENT_SYNTAX><ARGUMENT_PARSING>
Purpose: Clean up stale and merged branches
Optional Arguments:
--delete (boolean flag): Actually delete branches. No value needed, just include the flag. Default is dry-run (only lists branches without deleting). ALWAYS run without this flag first to preview--merged (boolean flag): Include branches that are fully merged into the default branch. No value needed, just include the flag. Safe to delete--inactive (boolean flag): Include branches with no commits in N days (see --days). No value needed, just include the flag. Review carefully before deleting--days (number): Number of days of inactivity to consider a branch stale (default: 30). Example: --days 60 for 60 days. Only applies when --inactive is used--location (enum): Where to clean branches. Must be one of: local (only local branches), remote (only remote branches), both (local and remote) (default: local)--exclude (string): Glob pattern of branches to exclude from cleanup (e.g., "release/", "hotfix/"). Use quotes for patterns with wildcardsMaps to: cleanup-branches
Example:
/repo:cleanup --merged --inactive --days 60
→ Invoke agent with {"operation": "cleanup-branches", "parameters": {"merged": true, "inactive": true, "days": 60}}
</ARGUMENT_PARSING>
<EXAMPLES> ## Usage Examples# List stale branches (dry-run)
/repo:cleanup
# List merged branches
/repo:cleanup --merged
# List inactive branches (older than 60 days)
/repo:cleanup --inactive --days 60
# List merged and inactive branches
/repo:cleanup --merged --inactive --days 90
# Actually delete merged branches
/repo:cleanup --merged --delete
# Clean up remote branches
/repo:cleanup --merged --delete --location remote
# Clean up excluding certain branches
/repo:cleanup --merged --delete --exclude "release/*"
# Clean up both local and remote
/repo:cleanup --merged --inactive --delete --location both
</EXAMPLES>
<AGENT_INVOCATION>
CRITICAL: After parsing arguments, you MUST actually invoke the Task tool. Do NOT just describe what should be done.
How to invoke: Use the Task tool with these parameters:
Example Task tool invocation (customize based on the specific operation):
Request structure:
{
"operation": "cleanup-branches",
"parameters": {
"delete": true|false,
"merged": true|false,
"inactive": true|false,
"days": 30,
"location": "local|remote|both",
"exclude": "pattern"
}
}
The repo-manager agent will:
cleanup-branches - Clean up stale and merged branches with safety checksDO NOT:
<ERROR_HANDLING> Common errors to handle:
No branches to clean:
Info: No branches match cleanup criteria
All branches are active and unmerged
Protected branch in cleanup list:
Warning: Skipping protected branch: main
Protected branches cannot be deleted
</ERROR_HANDLING>
<NOTES> ## Safety FeaturesThe cleanup command includes multiple safety features:
Merged branches:
Inactive branches:
--delete to see what would be cleanedThis command works with:
Platform is configured via /repo:init and stored in .fractary/plugins/repo/config.json.
For detailed documentation, see: /docs/commands/repo-cleanup.md
Related commands:
/repo:branch - Manage branches/repo:branch list --stale - List stale branches only/repo:init - Configure repo plugin
</NOTES>