refactor: extract skills from commands across 8 plugins
Refactored commands to extract reusable skills following the Commands → Skills separation pattern. Each command is now <50 lines and references skill files for detailed knowledge. Plugins refactored: - claude-config-maintainer: 5 commands → 7 skills - code-sentinel: 3 commands → 2 skills - contract-validator: 5 commands → 6 skills - data-platform: 10 commands → 6 skills - doc-guardian: 5 commands → 6 skills (replaced nested dir) - git-flow: 8 commands → 7 skills Skills contain: workflows, validation rules, conventions, reference data, tool documentation Commands now contain: YAML frontmatter, agent assignment, skills list, brief workflow steps, parameters Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,124 +1,44 @@
|
||||
---
|
||||
name: branch-cleanup
|
||||
description: Remove merged and stale branches locally and optionally on remote
|
||||
agent: git-assistant
|
||||
---
|
||||
|
||||
# /branch-cleanup - Clean Merged and Stale Branches
|
||||
|
||||
## Visual Output
|
||||
## Skills
|
||||
|
||||
When executing this command, display the plugin header:
|
||||
|
||||
```
|
||||
┌──────────────────────────────────────────────────────────────────┐
|
||||
│ 🔀 GIT-FLOW · Branch Cleanup │
|
||||
└──────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
Then proceed with the workflow.
|
||||
- skills/visual-header.md
|
||||
- skills/git-safety.md
|
||||
- skills/sync-workflow.md
|
||||
- skills/environment-variables.md
|
||||
|
||||
## Purpose
|
||||
|
||||
Remove branches that have been merged OR whose remote tracking branch no longer exists, both locally and optionally on remote.
|
||||
Remove branches that have been merged OR whose remote tracking branch no longer exists.
|
||||
|
||||
## Behavior
|
||||
## Parameters
|
||||
|
||||
### Step 1: Prune Remote Refs
|
||||
| Parameter | Description |
|
||||
|-----------|-------------|
|
||||
| `--dry-run` | Preview without deleting |
|
||||
| `--remote` | Also delete remote branches |
|
||||
| `--stale-only` | Only delete stale branches (upstream gone) |
|
||||
|
||||
```bash
|
||||
# Remove stale remote-tracking references
|
||||
git fetch --prune
|
||||
```
|
||||
## Workflow
|
||||
|
||||
### Step 2: Identify Branches for Cleanup
|
||||
|
||||
```bash
|
||||
# Find merged local branches
|
||||
git branch --merged <base-branch>
|
||||
|
||||
# Find merged remote branches
|
||||
git branch -r --merged <base-branch>
|
||||
|
||||
# Find local branches with deleted upstreams (stale)
|
||||
git branch -vv | grep ': gone]'
|
||||
```
|
||||
|
||||
### Step 3: Present Findings
|
||||
|
||||
```
|
||||
Found branches for cleanup:
|
||||
|
||||
Merged (safe to delete):
|
||||
- feat/login-page (merged 3 days ago)
|
||||
- fix/typo-header (merged 1 week ago)
|
||||
- chore/deps-update (merged 2 weeks ago)
|
||||
|
||||
Stale (remote deleted):
|
||||
- feat/old-feature (upstream gone)
|
||||
- fix/already-merged (upstream gone)
|
||||
|
||||
Remote (merged into base):
|
||||
- origin/feat/login-page
|
||||
- origin/fix/typo-header
|
||||
|
||||
Protected (won't delete):
|
||||
- main
|
||||
- development
|
||||
- staging
|
||||
|
||||
Delete these branches?
|
||||
1. Delete all (local merged + stale + remote)
|
||||
2. Delete merged only (skip stale)
|
||||
3. Delete stale only (upstream gone)
|
||||
4. Let me pick which ones
|
||||
5. Cancel
|
||||
```
|
||||
|
||||
### Step 4: Execute Cleanup
|
||||
|
||||
```bash
|
||||
# Delete merged local branches
|
||||
git branch -d <branch-name>
|
||||
|
||||
# Delete stale local branches (force needed since no upstream)
|
||||
git branch -D <stale-branch-name>
|
||||
|
||||
# Delete remote branches
|
||||
git push origin --delete <branch-name>
|
||||
```
|
||||
|
||||
### Step 5: Report
|
||||
|
||||
```
|
||||
Cleanup complete:
|
||||
|
||||
Deleted local (merged): 3 branches
|
||||
Deleted local (stale): 2 branches
|
||||
Deleted remote: 2 branches
|
||||
Skipped: 0 branches
|
||||
|
||||
Remaining local branches:
|
||||
- main
|
||||
- development
|
||||
- feat/current-work (not merged, has upstream)
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `GIT_DEFAULT_BASE` | `development` | Base branch for merge detection |
|
||||
| `GIT_PROTECTED_BRANCHES` | `main,master,development,staging,production` | Never delete these |
|
||||
| `GIT_AUTO_DELETE_REMOTE` | `false` | Auto-delete remote branches |
|
||||
| `GIT_CLEANUP_STALE` | `true` | Include stale branches (upstream gone) in cleanup |
|
||||
|
||||
## Safety
|
||||
|
||||
- Never deletes protected branches
|
||||
- Warns about unmerged branches that still have upstreams
|
||||
- Confirms before deleting remote branches
|
||||
- Uses `-d` (safe delete) for merged branches
|
||||
- Uses `-D` (force delete) only for stale branches with confirmation
|
||||
- Stale branches are highlighted separately for review
|
||||
1. **Display header** - Show GIT-FLOW Branch Cleanup header
|
||||
2. **Prune remote refs** - `git fetch --prune`
|
||||
3. **Find merged branches** - `git branch --merged <base-branch>`
|
||||
4. **Find stale branches** - `git branch -vv | grep ': gone]'`
|
||||
5. **Exclude protected** - Never delete protected branches (per git-safety.md)
|
||||
6. **Present findings** - Show merged, stale, and protected lists
|
||||
7. **Confirm deletion** - Options: all, merged only, stale only, pick, cancel
|
||||
8. **Execute cleanup** - Delete selected branches
|
||||
9. **Report** - Show deletion summary
|
||||
|
||||
## Output
|
||||
|
||||
On success:
|
||||
```
|
||||
Cleaned up:
|
||||
Local (merged): 3 branches deleted
|
||||
|
||||
Reference in New Issue
Block a user