1---2name: branch3description: Use when a user asks to create a new local git branch and start issue work (for example, "create branch" or "start working on issue XYZ"). Use this for issue-based branch naming in the `type/scope-short-description` pattern and for always syncing local `main` from `origin/main` before creating the new branch, creating the local tracking `main` branch first when needed.4---56# Branch Create78## Path Resolution (avoid missing-skill errors)910- Always open this skill using the absolute path from the active session skills list (for example `<agent-skills-root>/branch/SKILL.md`).11- Do not use guessed repo-relative skill paths unless the session explicitly lists that exact path.12- If you see a missing-skill error from a stale path, re-open from the active session skills list and continue.1314## Workflow15161. Confirm the issue target (for example `#123`, `123`, or an issue URL). If missing, ask the user for it.172. Identify the branch type.18 - Prefer issue labels if available.19 - Suggested defaults: `feature`, `bugfix`, `chore`, `docs`, `refactor`, `test`, `release`.20 - If ambiguous, ask the user to choose.213. Identify scope.22 - Use issue metadata if available (component, area, or team).23 - If unavailable, ask for a short scope token.244. Build the short description from the issue title.25 - Lowercase.26 - Remove stop words and punctuation.27 - Replace whitespace with hyphens.28 - Keep concise (recommended <= 5 words).29 - Limit final slug length to keep the branch name manageable.305. Form branch name as `type/scope-short-description`.31 - Examples:32 - `bugfix/api-auth-token-refresh`33 - `feature/dashboard-lien-card`34 - `chore/ci-fix-cache-busting`356. Verify the repository can branch from `main`.36 - Confirm the repo has an `origin` remote.37 - Confirm `origin/main` exists.38 - If switching to `main` would require leaving a dirty worktree, stop and ask the user instead of stashing or resetting anything.397. Sync local `main` from `origin/main` before branching:40 - `git fetch origin main`41 - If local `main` exists: `git switch main`42 - If local `main` does not exist: `git switch -c main --track origin/main`43 - `git pull --ff-only origin main`448. Create branch locally from updated `main`:45 - `git switch -c "<branch-name>"`469. Set issue start-work state in GitHub before coding (execution mode).47 - Add in-progress label:48 - `gh issue edit <issue> --add-label "agent/in-progress"`49 - Remove conflicting status labels when present:50 - `gh issue edit <issue> --remove-label "agent/resolved" || true`51 - `gh issue edit <issue> --remove-label "agent/blocking" || true`52 - `gh issue edit <issue> --remove-label "Blocked" || true`53 - Post a start comment that includes branch name:54 - `gh issue comment <issue> --body "Status: in progress. Branch: <branch-name>. Owner mode: Agent/Hybrid/Human."`55 - If your repo uses a project board status field, also move the item to `In progress`.5610. Report the branch name and current status with:57 - `git status -sb`5859## Hard rules6061- Create a local branch only (do not push unless explicitly requested).62- Always branch from an updated local `main` that matches `origin/main`.63- For issue-driven execution, do not start implementation until the issue is marked `agent/in-progress` (or user explicitly says not to mutate GitHub).64- Never stash, reset, or rebase just to make the branch creation succeed.65- Do not run branch resets/rebases/cherrypicks unless explicitly instructed.66- If the repository has no `main` branch, stop and ask the user for the correct base branch.67- If `origin/main` is missing, stop and ask the user for the correct remote base branch.6869## Optional issue metadata enrichment (when `gh` is available)7071- Try `gh issue view <issue> --json number,title,labels` when possible.72- Use labels to infer type.73- Use the title to derive a short description.74- If metadata is unavailable, continue with user-provided values.7576## Optional issue creation (when user asks to create one first)7778- If the user asks you to open an issue before branching, avoid inline `--body "..."` for multiline Markdown.79- Use a temp file with `gh issue create --body-file` to prevent shell quoting/backtick interpolation bugs:80 - `BODY_FILE=$(mktemp)`81 - `cat > "$BODY_FILE" <<'EOF'` ... `EOF`82 - `gh issue create --title "<title>" --body-file "$BODY_FILE"`83 - `rm -f "$BODY_FILE"`