git-branch-manager
π―Skillfrom edanstarfire/claudecode_webui
Manages Git branches by safely creating, switching, and cleaning up branches with intelligent handling of uncommitted changes.
Installation
npx skills add https://github.com/edanstarfire/claudecode_webui --skill git-branch-managerSkill Details
Create, switch, and manage git branches with proper handling of uncommitted changes. Use when creating feature branches, switching contexts, or cleaning up after merges.
Overview
# Git Branch Manager
Instructions
When to Invoke This Skill
- Creating a new feature/fix/chore branch
- Switching between branches
- Cleaning up merged branches
- Handling uncommitted changes before branch operations
- Validating current branch state
Core Capabilities
- Branch Creation - Create properly named branches from main
- Branch Switching - Safe branch changes with uncommitted change handling
- Branch Cleanup - Remove local branches after merge
- Branch Validation - Verify branch state and history
Standard Workflows
#### Creating a New Branch
- Check Repository State
Invoke the git-state-validator skill to verify:
- Current branch status
- Uncommitted changes
- Working directory state
- Handle Uncommitted Changes
If changes exist, ask user:
- Stash: git stash push -m "WIP: switching to new branch"
- Commit: Guide through commit process first
- Abort: Cancel branch creation
- Ensure Latest Main
```bash
git checkout main
git fetch origin
git pull origin main
```
- Determine Branch Prefix
Based on work type:
- feat/ - New features
- fix/ - Bug fixes
- chore/ - Maintenance, tooling
- docs/ - Documentation
- refactor/ - Code refactoring
- test/ - Test additions/fixes
- perf/ - Performance improvements
- Create Branch
```bash
git checkout -b
```
Branch name format:
- Use kebab-case
- Maximum 50 characters
- Descriptive but concise
- Example: feat/add-user-authentication
#### Switching Branches
- Check Repository State
Invoke the git-state-validator skill to verify:
- Current branch name
- Uncommitted changes
- Working directory status
- Handle Changes (if any)
- Offer to stash, commit, or abort
- If stash: git stash push -m "WIP: switching from
- Switch Branch
```bash
git checkout
```
- Restore Stash (if applicable)
After switching, if user stashed:
```bash
git stash list
git stash pop
```
#### Cleaning Up Branches
- Verify Branch is Merged
```bash
git branch --merged main
```
- Switch to Main (if on the branch being deleted)
```bash
git checkout main
```
- Check Branch Exists Before Deletion
```bash
git branch --list
```
If no output, branch doesn't exist - skip deletion
- Delete Local Branch (only if exists)
```bash
git branch -d
```
Use -D (force delete) only if user explicitly confirms:
```bash
git branch -D
```
- Verify Deletion
```bash
git branch --list
```
Safe Branch Deletion Helper
CRITICAL: Always check if branch exists before attempting deletion to avoid errors.
Safe Deletion Pattern:
```bash
# Check if branch exists
if git branch --list
git branch -d
echo "Branch deleted"
else
echo "Branch does not exist, skipping"
fi
```
Why This Matters:
- Prevents "branch not found" errors in automated workflows
- Handles cases where remote deletion already removed local tracking branch
- Makes cleanup scripts idempotent (safe to run multiple times)
Branch Naming Conventions
Good Examples:
feat/user-profile-pagefix/login-validation-errorchore/update-dependenciesdocs/api-endpoint-guide
Bad Examples:
my-branch(no type prefix)feat/ThisIsMyNewFeature(not kebab-case)feat/add-the-new-user-profile-page-with-authentication-and-settings(too long)
Error Handling
Branch Already Exists:
Ask user to:
- Switch to existing:
git checkout - Delete and recreate:
git branch -D&& git checkout -b - Choose different name
Uncommitted Changes Conflict:
```
error: Your local changes to the following files would be overwritten by checkout
```
- Must stash or commit changes first
- Cannot proceed without handling changes
Merge Conflicts When Pulling:
```
error: Merge conflict in
```
- Must resolve conflicts before creating branch
- Guide user through conflict resolution
Cannot Delete Current Branch:
```
error: Cannot delete branch '
```
- Must switch to different branch first
- Run:
git checkout mainthen retry delete
Examples
Example 1: Create feature branch for issue
```
Context: Working on issue #42 to add dark mode
Action:
- Check uncommitted changes (none found)
- Switch to main: git checkout main
- Update main: git pull origin main
- Create branch: git checkout -b feat/add-dark-mode-toggle
Output: "Created and switched to feat/add-dark-mode-toggle"
```
Example 2: Switch branches with uncommitted work
```
Context: User has uncommitted changes, wants to switch branches
Action:
- Detect uncommitted changes
- Ask user: "You have uncommitted changes. Stash, commit, or abort?"
- User chooses stash
- Run: git stash push -m "WIP: switching branches"
- Switch: git checkout other-branch
- Offer to pop stash if returning later
```
Example 3: Clean up after merge
```
Context: PR merged, need to clean up local branch
Action:
- Verify branch is merged: git branch --merged main
- Switch to main: git checkout main
- Check if branch exists: git branch --list feat/old-feature
- Delete branch (if exists): git branch -d feat/old-feature
- Update main: git pull origin main
Output: "Branch cleaned up, main is up to date"
```
Example 4: Handle branch naming
```
Context: User wants to fix a bug in login validation
Action:
- Determine type: "fix" (bug fix)
- Extract description: "login validation"
- Format: fix/login-validation-error
- Create: git checkout -b fix/login-validation-error
```
More from this repository10
Synchronizes local main branch with remote, pulling latest changes and ensuring a clean, up-to-date base for new worktrees.
Retrieves recent issues related to login, presents most relevant issue ``` Reads and analyzes GitHub issues to provide comprehensive context and implementation details.
Automates GitHub pull request workflows by tracking, reviewing, and managing PRs across repositories with intelligent filtering and status updates
Generates well-structured, semantic git commit messages by guiding developers through a standardized commit message composition process.
requirement-validator skill from edanstarfire/claudecode_webui
Explores codebases systematically by identifying relevant files, tracing functionality, and understanding architectural patterns through targeted search techniques.
Generates comprehensive, step-by-step implementation plans with clear technical details, testing strategies, and risk assessment for complex software features.
process-manager skill from edanstarfire/claudecode_webui
Analyzes code changes by tracing direct and indirect dependencies, identifying potential impacts and risks before implementing modifications.
Validates git repository state by checking working directory status, branch conflicts, and repository health before critical git operations.