update-branch-name — Claude Code command: what it does, how to install
Renames the active Git branch based on its changes against main. It is useful when you started coding on a temporary branch like temp.
npx claude-code-templates@latest --command git-workflow/update-branch-nameWhat update-branch-name does
The command inspects modified files against main using git diff main...HEAD. Claude Code analyzes the diff and determines what task was completed.
Next, it generates a descriptive branch name. The agent updates the local branch with git branch -m [new-branch-name] and confirms the result via git branch.
The instructions explicitly check against main. If your primary branch is master or develop, the diff command will fail.
What it helps with
- rename a working branch based on modified files
- inspect differences between the current branch and
main - update the local branch name without typing
git branch -mmanually
Example prompts for the agent
- /update-branch-name
- Rename the current branch based on my changes against main
- Check the diff with main and update the branch name
How to install update-branch-name
1claude-code-templates
npx claude-code-templates@latest --command git-workflow/update-branch-name2Manually: put the files in place
.claude/commands/update-branch-name.mdCall it with /update-branch-name. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/update-branch-name.mdCall it with /prompts:update-branch-name. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/update-branch-name.prompt.mdManually: put the files in place
.gemini/commands/update-branch-name.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about update-branch-name
How to install update-branch-name in Claude Code?
Run npx claude-code-templates@latest --command git-workflow/update-branch-name in your project root. The command definition will be placed in .claude/commands/update-branch-name.md.
What does update-branch-name do?
It compares your current work against main using git diff, suggests a fitting branch name, and executes git branch -m to rename it.
What is required for update-branch-name to work?
Your repository must have a main branch, because the prompt hardcodes git diff main...HEAD.
Source text
update-branch-name.md · MIT
--- description: "Rename the current branch to a descriptive name based on its changes against main" --- # Update Branch Name Follow these steps to update the current branch name: 1. Check differences between current branch and main branch HEAD using `git diff main...HEAD` 2. Analyze the changed files to understand what work is being done 3. Determine an appropriate descriptive branch name based on the changes 4. Update the current branch name using `git branch -m [new-branch-name]` 5. Verify the branch name was updated with `git branch`
© davila7 · MIT · davila7/claude-code-templates