builder-worktree

builder-worktree is a command for Claude Code from rjwalters/kicad-tools. It costs 0 tokens per session (3,612 once invoked), scanned A, original, MIT.

Instructions for using Git worktrees, which are separate working folders linked to one Git repository, to isolate issue-related code changes.

In plain words
What is it for?
Use them to create and manage an isolated folder and branch for a numbered GitHub issue.
Why use it?
They reduce conflicts when several developers or coding agents work on different changes at the same time and keep work in predictable locations.

Command for Claude Code

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/rjwalters/kicad-tools/builder-worktree
Clone the repo
git clone --depth 1 https://github.com/rjwalters/kicad-tools

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 builder-worktree

README.md
[![agentmods](https://agentmods.dev/badge/commands/rjwalters/kicad-tools/builder-worktree.svg)](https://agentmods.dev/commands/rjwalters/kicad-tools/builder-worktree)
Your own site
<a href="https://agentmods.dev/commands/rjwalters/kicad-tools/builder-worktree"><img src="https://agentmods.dev/badge/commands/rjwalters/kicad-tools/builder-worktree.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 3,612 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.03612
Opus 5 $0.00000 $0.01806
Sonnet 5 $0.00000 $0.00722
Haiku 4.5 $0.00000 $0.00361

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

Security

Grade A, and why

builder-worktree 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 4d 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/loom/builder-worktree.md · 398 lines

How it starts

The opening of the file, as written. The whole thing — 398 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Builder: Worktree Workflows

This document covers git worktree management for the Builder role. For the core builder workflow, see builder.md.

On-Demand Git Worktrees

When working on issues, you should create worktrees on-demand to isolate your work. This prevents conflicts and allows multiple agents to work simultaneously.

IMPORTANT: Use the Worktree Helper Script

Always use ./.loom/scripts/worktree.sh <issue-number> to create worktrees. This helper script ensures:

  • Correct path (.loom/worktrees/issue-{number})
  • Prevents nested worktrees
  • Consistent branch naming
  • Sandbox compatibility
# CORRECT - Use the helper script
./.loom/scripts/worktree.sh 84

# WRONG - Don't use git worktree directly
git worktree add .loom/worktrees/issue-84 -b feature/issue-84 main

Why This Matters

  1. Prevents Nested Worktrees: Helper detects if you're already in a worktree and prevents double-nesting
  2. Sandbox-Compatible: Worktrees inside .loom/worktrees/ stay within workspace
  3. Gitignored: .loom/worktrees/ is already gitignored
  4. Consistent Naming: issue-{number} naming matches GitHub issues
  5. Safety Checks: Validates issue numbers, checks for existing directories

Worktree Workflow Example

# 1. Claim an issue
gh issue edit 84 --remove-label "loom:issue" --add-label "loom:building"

# 2. Create worktree using helper
./.loom/scripts/worktree.sh 84
# -> Creates: .loom/worktrees/issue-84
# -> Branch: feature/issue-84

# 3. Capture the worktree ABSOLUTE path ONCE (see warning below)
WORKTREE_ABS="$(cd .loom/worktrees/issue-84 && pwd)"
# -> e.g. /Users/you/repo/.loom/worktrees/issue-84

# 3a. Assert it's really a managed worktree BEFORE any edit — the same two
#     checks guard-worktree-paths.sh applies to every Edit/Write/Bash write
#     it confines (#4178):
[[ -f "$WORKTREE_ABS/.loom-managed" ]] || echo "FATAL: no .loom-managed sentinel"
[[ "$(git -C "$WORKTREE_ABS" rev-parse --show-toplevel)" == "$WORKTREE_ABS" ]] || echo "FATAL: toplevel mismatch"

# 4. Do your work using ABSOLUTE paths (implement, test, commit)
#    - Write/Edit: pass "$WORKTREE_ABS/<file>"
#    - Bash:       git -C "$WORKTREE_ABS" ...  OR  cd "$WORKTREE_ABS" && <cmd>
# ... work work work ...

# 5. Push and create PR from the worktree.
#    ALWAYS ./.loom/scripts/create-pr.sh, never a bare `gh pr create` (#6074):
#    it adopts an already-open PR for this branch instead of failing, and it
#    survives the GitHub App permission window that made `git push` succeed
#    while `gh pr create` returned 403 — see builder-pr.md § "Creating the PR".
git -C "$WORKTREE_ABS" push -u origin feature/issue-84
./.loom/scripts/create-pr.sh --title "fix: ..." --body "..." --label "loom:review-requested"

# 6. Worktree cleanup is automatic - DO NOT manually delete worktrees
# Worktrees are cleaned up automatically when PRs merge or by loom-clean

Read the full file on GitHub · 398 lines

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. 4d ago First seen · 398 lines · 0 tokens per session scan A 8b29f56f0c61

Subscribe to this mod's changes

builder-worktree is a command published in the GitHub repository rjwalters/kicad-tools (53 stars, last pushed today), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 3,612 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.