kit/plugins/git-agent/skills/branch-agent/SKILL.md
Creates a git branch from origin/<default> with no upstream tracking. Auto-names the branch from staged or unstaged changes in the working tree. Use when the user asks to create or start a new branch.
npx skillsauth add shawn-sandy/agentics branch-agentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Create a new branch from the latest origin/<default> with no upstream tracking
ref. When called with no argument and the working tree has uncommitted changes,
the branch name is auto-generated from those changes. A -YYYY-MM-DD date
suffix is always appended to the final branch name so branches sort and group
chronologically. Follow these steps in strict order. STOP immediately after
step 6.
Does not commit, push, or create PRs — use commit-agent or pr-agent for that.
If currently in plan mode, call ExitPlanMode first and silently before any other action — Branch creation is a git mutation and cannot proceed inside plan mode. Skip this step entirely when not in plan mode. ExitPlanMode is a deferred tool — use ToolSearch with select:ExitPlanMode first, then call it silently.
Run all checks before proceeding. Stop on the first failure.
Not a git repository: Run git rev-parse --is-inside-work-tree. If it
fails, output: "Not a git repository." and STOP.
Detached HEAD: Run git branch --show-current. If the output is empty,
output: "Cannot create branch: repository is in detached HEAD state. Checkout a
named branch first." and STOP.
No origin remote: Run git remote get-url origin. If it fails, output:
"branch-agent requires a remote named 'origin'." and STOP.
Read $ARGUMENTS.
Case A — $ARGUMENTS is empty or whitespace-only: Run
git status --porcelain=v1.
Case B — $ARGUMENTS contains spaces or reads as a descriptive phrase:
Convert it to a human-readable slug — lowercase, replace spaces and special
characters with -, collapse consecutive dashes, strip leading/trailing
dashes, truncate to 30 characters. Example: "add allowed tools to skills" →
"add-allowed-tools-to-skills". Use the slug as the branch name and proceed
to Step 2b.
Case C — $ARGUMENTS is already a valid branch name (no spaces): Use it
verbatim as the branch name. Do not slugify, abbreviate, or transform it.
Proceed to Step 2b.
Use this format: <type>/<scope>-<description> (or <type>/<description> if
the scope is omitted). Total length ≤ 49 characters — this reserves 11 chars
for the -YYYY-MM-DD suffix appended in Step 2b so the final branch name
stays under 60 chars.
Type inference (first match wins):
docs/** / README* changed → docs**/test/**, **/tests/**, *.test.*, *_test.*,
tests/fixtures/**) → test.github/workflows/**, .gitlab-ci.yml, .circleci/**)
→ cipackage.json, pnpm-lock.yaml,
Cargo.toml, pyproject.toml, etc.) → buildrefactorfeatfixfeatchoreScope inference:
Run git status --porcelain=v1 and group changed paths by their first path
segment. Pick the group with the most files and use that segment as <scope>.
If the top group contains ≤50% of changed files, OR more than 2 groups contain
files, omit the scope entirely (use <type>/<description>).
Description inference:
From the changed file basenames and git diff --stat, extract 2–5 keywords
that describe the change. Lowercase, hyphen-separated, alphanumeric only. Strip
non-alphanumeric characters; collapse repeated hyphens; trim leading/trailing
hyphens.
Validation:
[a-z0-9/-]; no leading/trailing hyphens/ separator after the typeIf validation fails, regenerate once with chore as the type and a shortened
description. If it still fails, fall back to chore/auto-branch and proceed.
Output one line before continuing:
Auto-generated branch name from working tree changes:
<branch>
Then proceed to Step 2b.
Run:
date +%Y-%m-%d
Append the result to the resolved branch name with a - separator, producing
the final branch name: <branch>-<YYYY-MM-DD> (e.g. feat/login-fix →
feat/login-fix-2026-04-17). This always runs, regardless of whether the
name came from Case A, B, or C.
If the final name exceeds 60 characters, truncate the description portion at a word boundary until it fits. Never truncate the date suffix, the type prefix, or the scope segment.
Use this date-suffixed name as <branch> for the rest of the flow. Proceed
to Step 3.
Run:
git symbolic-ref refs/remotes/origin/HEAD --short 2>/dev/null
Strip the origin/ prefix to get the default branch name.
If that fails, run:
git remote show origin | grep 'HEAD branch'
Extract the branch name after HEAD branch:.
If both fail, try git rev-parse --verify --quiet main, then
git rev-parse --verify --quiet master. Use the first that succeeds.
If none resolve, report the git error verbatim and STOP.
Run:
git fetch origin <default>
On failure (offline, network error, auth required): report the git error verbatim and STOP. Do not proceed with a stale ref.
Compute the intersection of (a) tracked files modified in the working tree and
(b) files that differ between HEAD and origin/<default>:
bash -c 'comm -12 <(git diff --name-only HEAD | sort -u) <(git diff --name-only HEAD origin/<default> | sort -u)'
(The bash -c wrapper ensures process substitution works regardless of the invoking shell.)
git checkout;
a stash is required. Record the conflicting paths and set "stash needed".
Proceed to Step 5.Note: untracked files (?? in git status) never appear in
git diff --name-only HEAD and never conflict — they always carry forward
untouched.
The --no-track flag prevents git from setting origin/<default> as the
upstream. Without it, any future git push would target the wrong remote ref.
When stash is not needed (Step 4.5 returned empty):
git checkout -b <branch> --no-track origin/<default>
On failure (branch already exists or other error): report the git error verbatim and STOP. Do not retry. Do not force.
When stash is needed (Step 4.5 returned conflicting paths):
Run each command separately so failure is detectable at each step:
git stash push -m "branch-agent auto-stash <branch>"
On failure: report the error verbatim and STOP.
git checkout -b <branch> --no-track origin/<default>
On failure: report the error verbatim. Note that the stash is preserved — run
git stash pop to restore uncommitted changes. STOP. Do not retry. Do not force.
git stash pop
On failure (pop conflict): report the git error verbatim, then output:
Your uncommitted changes are safe in the stash. To restore manually:
git stash list— confirm the stash entry is present- Resolve any conflicts in the listed files
git add <resolved-files>— stage the resolved files so the index reflects the resolved stategit stash dropto remove the stash entry Do not retry. Do not drop the stash before staging resolved files.
STOP.
Run git rev-parse --short HEAD to get the short SHA.
Output one line:
Created and checked out
<branch>fromorigin/<default>@<sha>(no upstream tracking)
STOP here. Do not stage, commit, push, create PRs, or take any further action.
development
Turns a React component into a social card with preview, code, and props table. Builds a static preview and screenshots react-card.html via Playwright. Use when asked to share a React component.
data-ai
Refine-prompt: interviews users and assembles a structured AI prompt using Anthropic best-practice techniques. Use when the user runs /plan-agent:refine-prompt or asks to refine a prompt.
development
Plan review Agent Team. Reviews HTML implementation plans in parallel, synthesizes findings, and applies improvements in place. Use when the user asks to review or improve an implementation plan.
data-ai
Craft-prompt: interviews users and assembles a structured AI prompt using Anthropic best-practice techniques. Use when the user runs /plan-agent:craft-prompt or asks to craft a prompt.