skills/branch/SKILL.md
Creates and switches to a new, conventionally named branch — derives the name from an inline description, conversation context, or local git diffs. Preserves all local changes. Never commits or pushes. Use when you want a properly named branch for new or in-progress work.
npx skillsauth add oprogramadorreal/optimus-claude skills/branchInstall 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 and switch to a new, conventionally named branch. Works in two common scenarios:
/optimus:branch "add user authentication").The branch name is derived from the first available context: an inline description, conversation history, or local git diffs. Never commits, pushes, stages, or modifies anything — purely a local branch operation.
Read $CLAUDE_PLUGIN_ROOT/skills/init/references/multi-repo-detection.md for workspace detection. If a multi-repo workspace is detected:
.git/, so git commands must target individual repos)git status --short is non-empty)AskUserQuestion — header "Target repo", question "Multiple repos have local changes. Which repo should get the new branch?": list each repo as an optionRecord the current branch:
git rev-parse --abbrev-ref HEAD
Determine a meaningful description for the branch from the first source that provides enough signal (check in this priority order):
/optimus:branch "fix login timeout"), use it directlygit status --short
If there are local changes, analyze them to infer intent:
# File-level overview
git diff --stat
git diff --cached --stat
# Content details (for deeper analysis if file names alone are ambiguous)
git diff
git diff --cached
When analyzing diffs, look for:
src/auth/ → authentication, tests/ → testing)If no source provides enough signal to generate a meaningful name (no inline description, no conversation context, and either no local changes or changes too ambiguous to interpret), inform the user:
Could not determine a meaningful branch name from the conversation or local changes.
Provide a description, e.g., `/optimus:branch "add user authentication"`
Then stop — do not create a branch with a generic or meaningless name.
Read $CLAUDE_PLUGIN_ROOT/skills/commit/references/branch-naming.md for the naming convention. Use the Type Detection Keywords section to determine <type> from context, and apply the Slug Rules to generate <slug>.
Handle collisions: if git show-ref --verify --quiet refs/heads/<branch-name> succeeds (branch exists), append -2 to the slug. If that also exists, try -3, and so on up to -9. If all collide, inform the user and stop.
git checkout -b <branch-name>
Report (adapt based on whether local changes exist):
## Branch
Created `<branch-name>` from `<original-branch>`.
Local changes preserved (nothing committed or pushed).
If the working tree was clean (no local changes), omit the "Local changes preserved" line:
## Branch
Created `<branch-name>` from `<original-branch>`.
Recommend the next step based on context:
/optimus:tdd to build the feature test-first/optimus:commit to stage, commit, and optionally push/optimus:worktree for an isolated workspace/optimus:commit when readyTell the user the closing tip per $CLAUDE_PLUGIN_ROOT/references/skill-handoff.md "Closing tip wording" — use Variant B with <continuation-skill(s)> = /optimus:commit and <non-continuation-examples> = /optimus:tdd, /optimus:worktree, etc.
git checkout -b carries staged, unstaged, and untracked files to the new branch untouched. Do not run git stash, git add, git reset, or any command that alters the working tree or indexAskUserQuestion when multiple repos have changes or when context is truly insufficientdevelopment
Use when starting a new project or product and you want a docs-first plan before writing code — scaffolds an empty, product-neutral spec-driven-development cascade (product vision, MVP PRD, target tech-stack) for a human to fill, then hands off to brainstorm. Emits skeletons only; it never authors product content and never overwrites existing docs.
tools
Compacts the current conversation into a single self-contained handoff document under docs/handoffs/ so a fresh agent — a new session, a different AI tool, or another developer on a different machine — can resume the work by reading only that file. References committed artifacts (PRDs, plans, ADRs, issues, commits) by path or URL and inlines anything not yet pushed. Redacts secrets and PII. Re-running on an existing handoff lets you enhance the shared doc or overwrite it. Use when pausing work that someone else or a future session will pick up, or when a long conversation needs a durable summary.
development
Improves unit test coverage on demand — discovers testing gaps and generates tests that follow project conventions. Requires /optimus:init to have set up test infrastructure first. Conservative — only adds new test files, never refactors existing source code. Supports `deep` mode for iterative in-conversation test generation and `deep harness` mode for an automated multi-cycle unit-test + testability-refactor loop with fresh context per phase. Use when test coverage is low, after adding new code that lacks tests, or when you want an automated coverage-improvement harness.
development
Guides test-driven development — decompose a feature or bug fix into behaviors, then cycle through Red (failing test) → Green (minimal implementation) → Refactor for each one. Requires /optimus:init and working test infrastructure. Use when starting a new feature or bug fix with test-first discipline.