Branch
Start work on a new git branch, optionally in a new worktree.
Arguments
Accepts one of the following as arguments:
- Issue number: e.g.,
/branch 123 — fetches the issue title and derives the
branch name
- Description: e.g.,
/branch add shellcheck support — derives the branch name
from the text
- Worktree flag: append
--worktree or -w to create a git worktree instead of
a regular branch
Examples:
/branch 123 — branch from issue #123
/branch add dark mode toggle — branch from description
/branch 123 --worktree — worktree from issue #123
/branch fix login redirect -w — worktree from description
Branch Naming
Derive the branch name using this format:
<type>/<issue-number?>-<slug>
- type: Infer from context —
feat/, fix/, chore/, docs/, refactor/,
perf/, test/, ci/
- If an issue has labels like
bug → fix/, enhancement → feat/,
documentation → docs/
- If a description starts with a semantic prefix, use it
- Default to
feat/ if unclear
- issue-number: Include only if an issue number was provided
- slug: Lowercase, hyphenated, max ~50 chars, derived from the issue title or
description
- Strip filler words when too long
- e.g., "Add shellcheck support for shell scripts" →
add-shellcheck-support
Examples:
- Issue #123 titled "feat(cli): add watch mode" →
feat/123-add-watch-mode
- Issue #45 labeled
bug, titled "Parser crashes on empty input" →
fix/45-parser-crashes-on-empty-input
- Description "add dark mode" →
feat/add-dark-mode
- Description "fix: resolve null pointer" →
fix/resolve-null-pointer
Usage — Regular Branch
When asked to start a new branch (no --worktree / -w flag):
Ensure clean state:
- Run
git status — if there are uncommitted changes, warn the user and stop
- Do NOT stash or discard changes automatically
Fetch latest:
git fetch origin
Resolve branch name:
- If an issue number was given, fetch it:
gh issue view <number> --json title,labels
- Derive the branch name per the naming rules above
Create and switch to the branch:
git checkout -b <branch-name> origin/main
Confirm — Print the branch name and a summary of what was done
Usage — Worktree
When --worktree or -w is specified:
Ensure clean state:
- Run
git status — if there are uncommitted changes, warn the user and stop
Fetch latest:
git fetch origin
Resolve branch name (same rules as above)
Determine worktree path:
- Place as a sibling directory to the current repo
- Format:
<repo-dir>-<slug> (without the type prefix)
- e.g., if repo is at
~/Code/py-lintro and branch is feat/123-add-watch-mode:
- Worktree path:
~/Code/py-lintro-123-add-watch-mode
- e.g., if branch is
fix/parser-crash:
- Worktree path:
~/Code/py-lintro-parser-crash
Create the worktree:
git worktree add -b <branch-name> <worktree-path> origin/main
Confirm — Print the worktree path, branch name, and how to navigate there:
Created worktree at ~/Code/py-lintro-123-add-watch-mode
Branch: feat/123-add-watch-mode (from origin/main)
To start working:
cd ~/Code/py-lintro-123-add-watch-mode
Important
- NEVER force-delete branches or worktrees
- NEVER stash or discard uncommitted changes — always warn and stop
- Always branch from
origin/main (freshly fetched)
- If the branch name already exists, warn the user and ask what to do
1---2name: branch3description: Start work on a new branch or worktree. Use when asked to start a new branch, new worktree, begin work on a feature/fix, or start fresh. Supports issue numbers and plain descriptions.4---56# Branch78Start work on a new git branch, optionally in a new worktree.910## Arguments1112Accepts one of the following as arguments:1314- **Issue number**: e.g., `/branch 123` — fetches the issue title and derives the15 branch name16- **Description**: e.g., `/branch add shellcheck support` — derives the branch name17 from the text18- **Worktree flag**: append `--worktree` or `-w` to create a git worktree instead of19 a regular branch2021Examples:2223- `/branch 123` — branch from issue #12324- `/branch add dark mode toggle` — branch from description25- `/branch 123 --worktree` — worktree from issue #12326- `/branch fix login redirect -w` — worktree from description2728## Branch Naming2930Derive the branch name using this format:3132```text33<type>/<issue-number?>-<slug>34```3536- **type**: Infer from context — `feat/`, `fix/`, `chore/`, `docs/`, `refactor/`,37 `perf/`, `test/`, `ci/`38 - If an issue has labels like `bug` → `fix/`, `enhancement` → `feat/`,39 `documentation` → `docs/`40 - If a description starts with a semantic prefix, use it41 - Default to `feat/` if unclear42- **issue-number**: Include only if an issue number was provided43- **slug**: Lowercase, hyphenated, max ~50 chars, derived from the issue title or44 description45 - Strip filler words when too long46 - e.g., "Add shellcheck support for shell scripts" → `add-shellcheck-support`4748Examples:4950- Issue #123 titled "feat(cli): add watch mode" → `feat/123-add-watch-mode`51- Issue #45 labeled `bug`, titled "Parser crashes on empty input" →52 `fix/45-parser-crashes-on-empty-input`53- Description "add dark mode" → `feat/add-dark-mode`54- Description "fix: resolve null pointer" → `fix/resolve-null-pointer`5556## Usage — Regular Branch5758When asked to start a new branch (no `--worktree` / `-w` flag):59601. **Ensure clean state**:61 - Run `git status` — if there are uncommitted changes, warn the user and stop62 - Do NOT stash or discard changes automatically632. **Fetch latest**:6465 ```bash66 git fetch origin67 ```68693. **Resolve branch name**:70 - If an issue number was given, fetch it:71 `gh issue view <number> --json title,labels`72 - Derive the branch name per the naming rules above734. **Create and switch to the branch**:7475 ```bash76 git checkout -b <branch-name> origin/main77 ```78795. **Confirm** — Print the branch name and a summary of what was done8081## Usage — Worktree8283When `--worktree` or `-w` is specified:84851. **Ensure clean state**:86 - Run `git status` — if there are uncommitted changes, warn the user and stop872. **Fetch latest**:8889 ```bash90 git fetch origin91 ```92933. **Resolve branch name** (same rules as above)944. **Determine worktree path**:95 - Place as a **sibling directory** to the current repo96 - Format: `<repo-dir>-<slug>` (without the type prefix)97 - e.g., if repo is at `~/Code/py-lintro` and branch is `feat/123-add-watch-mode`:98 - Worktree path: `~/Code/py-lintro-123-add-watch-mode`99 - e.g., if branch is `fix/parser-crash`:100 - Worktree path: `~/Code/py-lintro-parser-crash`1015. **Create the worktree**:102103 ```bash104 git worktree add -b <branch-name> <worktree-path> origin/main105 ```1061076. **Confirm** — Print the worktree path, branch name, and how to navigate there:108109 ```text110 Created worktree at ~/Code/py-lintro-123-add-watch-mode111 Branch: feat/123-add-watch-mode (from origin/main)112113 To start working:114 cd ~/Code/py-lintro-123-add-watch-mode115 ```116117## Important118119- NEVER force-delete branches or worktrees120- NEVER stash or discard uncommitted changes — always warn and stop121- Always branch from `origin/main` (freshly fetched)122- If the branch name already exists, warn the user and ask what to do