Skip to main content
Glama

Git branch

git_branch
Idempotent

List, create, switch, or delete local Git branches, optionally including remote-tracking branches. Use it to check the current branch, branch off HEAD, or prune merged branches.

Instructions

List local (and optionally remote-tracking) branches, or create/switch/delete one. Use when: you need the current branch, want to branch off HEAD, switch branches, or prune a merged branch. Avoid when: you need the worktree state (git_status) or a remote PR’s head branch (pr_list). Output: list: current, branches[] {name, current, commit, upstream, track, remote}, branch_count. create/switch/delete: branch, commit/created/switched/deleted/force. Missing branch gives not_found; duplicate name gives conflict.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "git_branch"
  }
}

Input Schema

NameRequiredDescriptionDefault
fromNoOptional start ref for action=create (default: HEAD).
nameNoBranch name (required for create/switch/delete).
forceNotrue allows deleting an unmerged branch (git branch -D); false uses -d.
actionNolist: local branches (add include_remote=true for origin); current: just the checked-out branch; create/switch/delete: local branch.list
reasonNoOptional why (max 400 chars), audit-logged.
include_remoteNotrue includes remote-tracking branches in action=list.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed11 schema fields changedv4.5.0
    • changedInput schema / properties / action / description
      Previous value: -"list: local branches (add include_remote=1 for origin); current: just the checked-out branch; create/switch/delete: local branch."New value: +"list: local branches (add include_remote=true for origin); current: just the checked-out branch; create/switch/delete: local branch."
    • removedInput schema / properties / force / anyOf
      Removed value: -[
      -  {
      -    "type": "boolean"
      -  },
      -  {
      -    "maximum": 1,
      -    "minimum": 0,
      -    "type": "integer"
      -  }
      -]
    • changedInput schema / properties / force / description
      Previous value: -"1 allows deleting an unmerged branch (git branch -D); 0 uses -d."New value: +"true allows deleting an unmerged branch (git branch -D); false uses -d."
    • removedInput schema / properties / force / maximum
      Removed value: -1
    • removedInput schema / properties / force / minimum
      Removed value: -0
    • changedInput schema / properties / force / type
      Previous value: -"integer"New value: +"boolean"
    • removedInput schema / properties / include_remote / anyOf
      Removed value: -[
      -  {
      -    "type": "boolean"
      -  },
      -  {
      -    "maximum": 1,
      -    "minimum": 0,
      -    "type": "integer"
      -  }
      -]
    • changedInput schema / properties / include_remote / description
      Previous value: -"1 includes remote-tracking branches in action=list."New value: +"true includes remote-tracking branches in action=list."
    • removedInput schema / properties / include_remote / maximum
      Removed value: -1
    • removedInput schema / properties / include_remote / minimum
      Removed value: -0
    • changedInput schema / properties / include_remote / type
      Previous value: -"integer"New value: +"boolean"
  2. Addedv4.0.0

TDQS

A3.9/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description explicitly includes delete and force-delete-unmerged-branch behavior, which is a destructive update, while annotations declare destructiveHint=false. It provides useful output and error details, but that direct contradiction with the safety annotation is a serious transparency failure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the operation list, then organized as Use when, Avoid when, Output, and error behavior. Every sentence contributes useful selection or invocation context.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a multi-action tool with no output schema, the description covers usage, alternatives, return shapes for list versus mutations, and key error outcomes like not_found and conflict. It is complete enough for callers to choose and invoke the tool, aside from the annotation conflict.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so all six parameters are already documented in the input schema. The description restates action modes and output behavior but adds little parameter-level meaning beyond the schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names the resource and the distinct operations: list local/remote-tracking branches, create, switch, and delete. It also distinguishes those from neighboring concerns like worktree state and PR branches, so an agent can identify the tool without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives an explicit 'Use when' list and an 'Avoid when' clause naming specific alternatives, git_status and pr_list. This directly routes the agent between branch operations and related tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.