---
name: branch
allowed-tools: Bash(git branch:*), Bash(git checkout:*), Bash(git switch:*), Bash(git status:*), Bash(git log:*), Bash(git rev-parse:*), Bash(echo:*), Bash(printf:*), Read
description: Create and switch to a new git branch following Conventional Branch naming conventions. Use this skill whenever the user wants to create a branch, start new work, begin a feature, fix a bug, prepare a hotfix, prepare a release, or mentions branch naming. Also triggers for phrases like 'start working on X', 'new branch for X', 'create a feature branch', 'I need to fix X', 'branch for X', 'prepare release X', 'checkout a new branch'. Covers branch creation, naming validation, and type selection (feat/, fix/, hotfix/, release/, chore/).
model: sonnet
title: branch
canonical_url: https://skilld.dev/gh/thedoobieapp/git-tools/branch
last_updated: 2026-10-21T18:13:41.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [references/conventional-branch-1.0.0.md](https://skilld.dev/api/skills-raw/thedoobieapp/git-tools/branch/references/conventional-branch-1.0.0.md).
>
> If the user asked to install this Skill, run `npx skilld install thedoobieapp/git-tools/branch`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/branch`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/thedoobieapp/git-tools/branch) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/branch`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/branch --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/branch --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Branch SKILL

## Context

- Repo check (`(no repo)` means this directory is not under git): !`out=$(git rev-parse --show-toplevel 2>/dev/null) || true; printf '%s\n' "${out:-(no repo)}"`
- Current branch: !`out=$(git branch --show-current 2>/dev/null) || true; printf '%s\n' "${out:-(no branch — detached HEAD, or no repo)}"`
- Existing branches: !`out=$(git branch --list 2>/dev/null) || true; printf '%s\n' "${out:-(no branches yet)}"`
- Recent commits: !`out=$(git log --oneline -5 2>/dev/null) || true; printf '%s\n' "${out:-(no commits yet)}"`
- Git status: !`out=$(git status --short 2>/dev/null) || true; printf '%s\n' "${out:-(working tree clean)}"`

## Your task

Create a properly named git branch following `${CLAUDE_PLUGIN_ROOT}/skills/branch/references/conventional-branch-1.0.0.md` conventions.

### Step 0 — Confirm there is a repo

If the repo check in the context reads `(no repo)`, this directory is not under
version control. Say so, point the user at `init` to create the repo, and stop —
nothing below applies until there is one.

### Step 1 — Determine branch type

Analyze the user's request to determine the appropriate branch prefix:

| Prefix      | When to use                                |
|-------------|--------------------------------------------|
| `feat/`     | New feature or capability                  |
| `fix/`      | Bug fix                                    |
| `hotfix/`   | Urgent fix for production                  |
| `release/`  | Preparing a versioned release              |
| `chore/`    | Non-code tasks (deps, docs, CI, cleanup)   |

If the user's intent is ambiguous, use **AskUserQuestion** to settle it — list the
plausible prefixes as options, most likely first, each with a one-line explanation
of why it fits. Never guess a prefix silently.

### Step 2 — Compose branch name

Build the branch name as `<type>/<description>`:

1. Use lowercase alphanumerics and hyphens only (dots allowed in release versions)
2. No consecutive, leading, or trailing hyphens or dots
3. Keep it concise but descriptive
4. Include ticket numbers when the user mentions them (e.g., `feat/issue-123-add-login`)

**Examples:**

- "Add a search feature" → `feat/add-search`
- "Fix the login bug from ticket #42" → `fix/issue-42-login-bug`
- "Update dependencies" → `chore/update-dependencies`
- "Prepare release 2.1.0" → `release/v2.1.0`
- "Critical security patch" → `hotfix/security-patch`

### Step 3 — Confirm with user

Confirm with **AskUserQuestion** — this is the only way this skill takes approval,
never a plain-text "shall I?":

- Show the proposed branch name
- Show the base branch it will be created from (current branch)
- Offer options: "Create it! / Change name / Change type / Cancel"

If the user picks "Change name" or "Change type", apply their input and re-ask.
Nothing is created until this step returns approval.

### Step 4 — Create and switch

1. Check for uncommitted changes — if the working directory is dirty, list the files
   and use **AskUserQuestion**: "Create the branch anyway (changes carry over) /
   Cancel and deal with them first".
2. If a branch with the same name already exists, use **AskUserQuestion** to offer
   the alternatives: switch to the existing branch, use a suffixed name (`-2`,
   ticket number), or cancel. Never force-create over an existing branch.
3. Create the branch: `git switch -c <branch-name>`
4. Confirm success with the new branch name

## Integration

- **Before this skill**: Make sure you're on the right base branch
- **After this skill**: Use `commit` to make conventional commits on the new branch ([commit](../commit/SKILL.md))
- **End of work**: Use `merge` to bring the branch into its target ([merge](../merge/SKILL.md))

## Rules

- Always validate branch names against the spec before creating
- Every decision the user has to make goes through **AskUserQuestion** — branch
  type, final name, dirty tree, name collision. Never ask in prose and wait for a
  typed reply
- Never force-create branches that overwrite existing ones without explicit confirmation
- NEVER include co-authoring or attribution references
- Any git command you run during the task must be written so a non-zero exit
  cannot abort the step. Use `out=$(<command> 2>/dev/null) || true; printf '%s\n' "${out:-(marker)}"`,
  the same form the context block uses. Several git commands report an ordinary,
  expected answer through a non-zero status — `check-ignore` exits `1` for "not
  ignored", `config --get` exits `1` for "unset", `config --unset` exits `5` for
  "was not set", `rev-parse HEAD` exits `128` on a repo with no commits — and an
  unguarded one of those reads as a crash and stops work that should have
  continued
- Do not re-run a context command just to confirm what is already printed above.
  Do re-check when its output contradicts itself or carries a shell error — a
  wrong answer is worth verifying — but re-run it in the guarded form, never
  bare, or the check fails the same way the original did
- Never put an unquoted glob (`README*`, `*.md`) in a command. Shells disagree
  about an unmatched one: bash and `sh` pass it through literally, zsh aborts the
  whole command before it runs and prints `no matches found` — which no `2>/dev/null`
  can suppress, because the shell emits it during expansion rather than the
  command emitting it. The result is a confident wrong answer. List the directory
  and filter it instead: `ls -A | grep -iE "^(readme|license)"`

---

# Links

- [conventional-branch-1.0.0](https://skilld.dev/api/skills-raw/thedoobieapp/git-tools/branch/references/conventional-branch-1.0.0.md)
