checkout-branch

checkout-branch is a command for Claude Code from kayba-ai/agentic-context-engine. It costs 0 tokens per session (676 once invoked), scanned A, original, Apache-2.0.

A command for switching to an existing Git branch, using a separate worktree when needed. A Git worktree is another directory containing a checkout of a branch.

In plain words
What is it for?
Use it with a full or partial branch name to fetch branches, resolve matches, inspect existing worktrees, and create a new worktree when necessary.
Why use it?
It finds the correct branch and avoids manually checking branches, fetching updates, and managing worktree paths.

Command for Claude Code

About the project

Agentic Context Engine is an open-source engine that gives AI agents a persistent learning loop, helping them remember successful strategies and learn from failures across sessions. It is used to improve production agents, and also powers Kayba’s hosted service. Catalogue add-ons support workflows for operating and configuring the engine.

kayba-ai/agentic-context-engine · 2,564 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/kayba-ai/agentic-context-engine/checkout-branch
Clone the repo
git clone --depth 1 https://github.com/kayba-ai/agentic-context-engine

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for checkout-branch

README.md
[![agentmods](https://agentmods.dev/badge/commands/kayba-ai/agentic-context-engine/checkout-branch.svg)](https://agentmods.dev/commands/kayba-ai/agentic-context-engine/checkout-branch)
Your own site
<a href="https://agentmods.dev/commands/kayba-ai/agentic-context-engine/checkout-branch"><img src="https://agentmods.dev/badge/commands/kayba-ai/agentic-context-engine/checkout-branch.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 676 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00676
Opus 5 $0.00000 $0.00338
Sonnet 5 $0.00000 $0.00135
Haiku 4.5 $0.00000 $0.00068

Measured 5d ago against content hash 524088f752db, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

checkout-branch scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/checkout-branch.md · 65 lines

What it actually says

Switch to an existing branch by checking out its worktree, or creating one if needed.

Arguments: $ARGUMENTS should be the branch name (full or partial match)

Examples:

  • /checkout-branch feature/john/add-caching → switch to branch (create worktree if needed)
  • /checkout-branch add-caching → partial match, resolve to full branch name
  • /checkout-branch fix → if multiple matches, list them and ask to be specific

Steps:

  1. Parse branch name from arguments
  2. Fetch latest from remote: git fetch --prune
  3. Get all branches (local + remote): git branch -a --format='%(refname:short)'
  4. Resolve branch name:
    • Exact match: use directly
    • Partial match: find branches containing the search term
    • No match: show error with similar branches (if any)
  5. Get worktree list: git worktree list --porcelain
  6. Check if resolved branch has an existing worktree
  7. If worktree exists:
    • Show path and suggest cd <path>
  8. If no worktree:
    • Construct worktree path: ../<sanitized-branch-name> (replace all / with -)
    • If remote-only branch (starts with origin/): git worktree add <path> -b <local-name> <remote-name>
    • If local branch: git worktree add <path> <branch>
    • Symlink .env: if <main-worktree>/.env exists (get main worktree from git worktree list --porcelain | head -1), run ln -s <main-worktree>/.env <new-worktree>/.env
    • Show path and suggest cd <path>

On success (worktree exists), output:

✓ Branch already has worktree at: <worktree-path>

To switch to the worktree:
  cd <worktree-path>

On success (worktree created from local branch), output:

✓ Created worktree: <worktree-path>
✓ Linked .env → <main-worktree>/.env

To switch to the worktree:
  cd <worktree-path>

On success (worktree created from remote branch), output:

✓ Created local branch: <branch-name> (tracking origin/<branch-name>)
✓ Created worktree: <worktree-path>
✓ Linked .env → <main-worktree>/.env

To switch to the worktree:
  cd <worktree-path>

Error handling:

  • Branch not found: "Branch not found: . Did you mean one of these?" (list similar branches)
  • Multiple partial matches: "Multiple branches match '':" (list matches, ask to be more specific)
  • No branches at all: "No branches found matching ''"

Branch resolution priority:

  1. Exact match on full branch name
  2. Exact match on last segment (e.g., "add-caching" matches "feature/john/add-caching")
  3. Partial substring match anywhere in branch name
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 65 lines · 0 tokens per session scan A 524088f752db

Subscribe to this mod's changes

checkout-branch is a command published in the GitHub repository kayba-ai/agentic-context-engine (2,564 stars, last pushed 7d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 676 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.