worktree-setup

A command that creates Git worktrees for one or more GitHub issues. A Git worktree is a separate working directory connected to the same Git repository, so work can happen in parallel.

In plain words
What is it for?
Use it to validate issue numbers, check the repository and develop branch, create feature branches and worktrees, and synchronize them after handling multiple issues.
Why use it?
It reduces the manual setup needed before starting issue-based development and checks that the repository is ready.

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/kewton/commandmate/worktree-setup
Clone the repo
git clone --depth 1 https://github.com/Kewton/CommandMate

Made for: Claude Code.

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 2,435 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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.02435
Opus 5 $0.00000 $0.01218
Sonnet 5 $0.00000 $0.00487
Haiku 4.5 $0.00000 $0.00244

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

Security

Grade A, and why

worktree-setup scanned grade A with 1 finding 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 3d 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

curl -s -X POST http://localhost:${CM_PORT:-3000}/api/repositories/sync
.claude/commands/worktree-setup.md · 284 lines

How it starts

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

Worktree Setup スキル

概要

指定したIssue番号に対応するGit Worktree環境を自動構築するスキルです。

使用方法

/worktree-setup [Issue番号...]

:

/worktree-setup 135
/worktree-setup 187 188 191 193

実行内容

あなたはWorktree環境セットアップの専門家です。以下の手順でWorktree環境を構築してください。 複数のIssue番号が指定された場合は、各Issueに対してPhase 1〜7を順番に繰り返し実行します。

パラメータ

  • issue_numbers: 対象Issue番号(必須、1つ以上、スペース区切り、各番号は正の整数)

実行フェーズ

複数Issue指定時: 以下のPhase 1〜7を各Issueに対して順番に実行します。 ただし、Phase 2(前提条件チェック)は初回のみ実行し、Phase 6(Worktree同期)は全Issue完了後にまとめて1回実行します。

Phase 1: 入力検証

  1. Issue番号が正の整数であることを確認
  2. Issue番号が1〜2147483647の範囲内であることを確認
# 共通バリデーション関数を読み込み
# Synced with: src/cli/utils/input-validators.ts MAX_ISSUE_NO
source "$(dirname "$0")/../lib/validators.sh"

# Issue番号の検証
if ! validate_issue_no "$ISSUE_NO"; then
  echo "Error: Invalid issue number"
  exit 1
fi

Phase 2: 前提条件チェック

  1. 現在のディレクトリがGitリポジトリであることを確認
  2. developブランチが存在することを確認
  3. git worktreeコマンドが利用可能であることを確認
# Gitリポジトリチェック
git rev-parse --git-dir > /dev/null 2>&1 || { echo "Error: Not a git repository"; exit 1; }

# developブランチ存在チェック
git show-ref --verify --quiet refs/heads/develop || { echo "Error: develop branch not found"; exit 1; }

Phase 3: Worktree作成

  1. featureブランチ名を決定: feature/{issue_number}-worktree
  2. Worktreeディレクトリを決定: ../commandmate-issue-{issue_number}
  3. git worktree addコマンドを実行
BRANCH_NAME="feature/${ISSUE_NO}-worktree"
WORKTREE_DIR="../commandmate-issue-${ISSUE_NO}"

# 既存Worktreeチェック
if git worktree list | grep -q "$WORKTREE_DIR"; then
  echo "Worktree already exists: $WORKTREE_DIR"
else
  # Worktree作成(developブランチから派生)
  git worktree add -b "$BRANCH_NAME" "$WORKTREE_DIR" develop
fi

Phase 4: 環境設定

  1. Worktreeディレクトリに移動
  2. 依存関係インストール(必要な場合)
  3. Issue専用DBパスを設定
cd "$WORKTREE_DIR"

# 依存関係インストール(node_modulesがない場合)
if [ ! -d "node_modules" ]; then
  npm install
fi

# .envファイルにIssue固有設定を追加(存在しない場合)
if [ ! -f ".env" ]; then
  cp ~/.commandmate/.env .env 2>/dev/null || touch .env
fi

Read the full file on GitHub · 284 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. 3d ago First seen · 284 lines · 0 tokens per session scan A 9ab0a2d6285f

Subscribe to this mod's changes

worktree-setup is a command published in the GitHub repository Kewton/CommandMate (39 stars, last pushed 3d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,435 tokens. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.