From hero-skills
Creates a feature branch from a short description, using the repository's branch convention from HERO.md. Handles uncommitted changes and ensures correct base branch.
How this skill is triggered — by the user, by Claude, or both
Slash command
/hero-skills:create-branch DESCRIPTION_OF_WORKDESCRIPTION_OF_WORKThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Describe what you're going to work on and this skill creates a properly named feature branch based on the repository's branch convention.
Describe what you're going to work on and this skill creates a properly named feature branch based on the repository's branch convention.
$ARGUMENTS - A short description of the work (required)
add user authenticationfix login page crash on mobilerefactor database connection poolingROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
cat "$ROOT/HERO.md" 2>/dev/null || echo "NO_HERO_CONFIG"
Read HERO.md if it exists. This skill uses:
If HERO.md is missing, suggest hero-skills:init-hero but proceed with github-standard convention.
git status --porcelain
BRANCH=$(git branch --show-current)
echo "Current branch: $BRANCH"
If uncommitted changes exist, STOP and show:
⚠ You have uncommitted changes on '$BRANCH':
(list changed files from git status)
These changes will be affected by switching branches.
Options:
1. Stash changes (saved as "create-branch: WIP on $BRANCH") — will auto-restore when done
2. Carry changes to the new branch (default git behavior — changes stay unstaged)
3. Cancel — go back and commit or handle changes first
STOP and wait for user to choose. Do NOT proceed without explicit confirmation.
If user chooses option 1 (stash):
git stash push -m "create-branch: WIP on $BRANCH"
Report the stash ref so the user can find it later:
Stashed as: stash@{0} — "create-branch: WIP on $BRANCH"
Will auto-restore after branch creation.
Track that a stash was created (for Step 5 restore).
DEFAULT_BRANCH=main # or from HERO.md
CURRENT=$(git branch --show-current)
if [ "$CURRENT" != "$DEFAULT_BRANCH" ]; then
echo "Currently on $CURRENT, not $DEFAULT_BRANCH"
fi
If not on the default branch, ask:
You're on '$CURRENT', not '$DEFAULT_BRANCH'.
Options:
1. Switch to $DEFAULT_BRANCH first, then branch (recommended)
2. Branch from $CURRENT instead
If option 1 (switch to default branch):
git checkout "$DEFAULT_BRANCH"
git pull origin "$DEFAULT_BRANCH"
If option 2 (branch from current): Skip the pull — branch from $CURRENT as-is.
Based on the branch-convention from HERO.md:
github-standard (default):
{type}/{short-description}
Examples by work type:
| Description | Branch Name |
|---|---|
| add user authentication | feat/add-user-authentication |
| fix login page crash | fix/login-page-crash |
| refactor database pooling | refactor/database-pooling |
| update CI pipeline | chore/update-ci-pipeline |
Rules:
add/create/implement → feat/, fix/repair/resolve → fix/, refactor/clean/restructure → refactor/, update/bump/upgrade → chore/feat/PROJ-123-add-authIf branch-convention is custom or has a branch-template in HERO.md, follow that template instead.
Present the proposed branch name and let the user confirm or modify:
Proposed branch: feat/add-user-authentication
Enter to confirm, or type a different name:
If .pre-commit-config.yaml exists, check for branch-related hooks:
if [ -f .pre-commit-config.yaml ]; then
grep -A10 "no-commit-to-branch" .pre-commit-config.yaml
fi
The no-commit-to-branch hook restricts which branches you can commit to (not branch naming). If the hook defines a --pattern, verify the proposed branch name is allowed by that pattern. If it would be blocked, warn the user and suggest a compliant name before creating the branch. This prevents frustrating commit rejections later.
# Check that the branch does not already exist (local or remote)
if git branch --list "$BRANCH_NAME" | grep -q .; then
echo "Branch '$BRANCH_NAME' already exists locally. Please choose a different name."
# Ask user to rename or append a number
fi
git checkout -b $BRANCH_NAME
If changes were stashed in Step 1:
git stash pop
Report the restore:
Restored stashed changes from "create-branch: WIP on $BRANCH"
If the stash pop has conflicts, report them clearly and let the user resolve.
Branch Summary
===================
Created: {branch-name}
From: {default-branch} (up to date)
Stash: [restored / carried over / n/a]
Ready to work. When done:
hero-skills:commit-changes - review and commit changes
hero-skills:push-pr - push and open a draft PR
git branch --listGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.
npx claudepluginhub ai-hero/hero-skills --plugin hero-skills