worktree-init

worktree-init is a command for Claude Code from davila7/claude-code-templates. It costs 12 tokens per session (831 once invoked), scanned A, original, MIT.

A command that creates separate Git worktrees for multiple development tasks and opens each one in a Ghostty terminal panel. A worktree is an additional working directory connected to the same Git repository.

In plain words
What is it for?
Use it to set up parallel tasks, create task-specific branches and worktree folders, fetch the latest repository state, and run separate development sessions.
Why use it?
It lets you work on several branches at the same time without repeatedly switching the files in one directory. Each task can run in its own terminal and Claude session.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: names the AskUserQuestion tool.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is git worktree add -b claude/<name> ../worktrees/<repo-name>/claude-<name> origin/<main-branch>.

Good fit Use it to set up parallel tasks, create task-specific branches and worktree folders, fetch the latest repository state, and run separate development sessions.

Compare 6 commands from other repositories ↓
About the project

Claude Code Templates is a command-line tool and catalogue for configuring Anthropic’s Claude Code with agents, commands, settings, hooks, integrations, skills, and project templates. Developers use it to browse and install reusable components for their coding workflows. The catalogue includes many of these Claude Code components.

davila7/claude-code-templates · 34,829 stars · on GitHub · aitmpl.com

Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/davila7/claude-code-templates
agentmods
npx agentmods add commands/davila7/claude-code-templates/worktree-init

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

README.md
[![agentmods](https://agentmods.dev/badge/commands/davila7/claude-code-templates/worktree-init/github.svg)](https://agentmods.dev/commands/davila7/claude-code-templates/worktree-init)
Your own site
<a href="https://agentmods.dev/commands/davila7/claude-code-templates/worktree-init"><img src="https://agentmods.dev/badge/commands/davila7/claude-code-templates/worktree-init/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for worktree-init

Your own site · 80×15
<a href="https://agentmods.dev/commands/davila7/claude-code-templates/worktree-init"><img src="https://agentmods.dev/badge/commands/davila7/claude-code-templates/worktree-init.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 12 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 831 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00012 $0.00831
Opus 5.5 $0.00005 $0.00332
Sonnet 5.5 $0.00002 $0.00166
Haiku 4.5 $0.00001 $0.00083

Measured 3mo ago against content hash 32a29d3468a2, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

worktree-init 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 3mo 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/worktree-init.md · 89 lines

How it starts

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

Worktree Parallel Init

Create multiple git worktrees for parallel development: $ARGUMENTS

Instructions

You are setting up parallel worktrees so the user can work on multiple tasks simultaneously in separate Ghostty terminal panels, each running its own Claude instance.

Step 1: Validate Environment

  1. Check this is a git repository: git rev-parse --is-inside-work-tree
  2. Get the repo name: basename $(git rev-parse --show-toplevel)
  3. Get the main branch name (check for main or master): git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' — if that fails, default to main
  4. Ensure working tree is clean: git status --porcelain. If dirty, warn the user and ask if they want to continue.
  5. Fetch latest: git fetch origin

Step 2: Parse Tasks

Parse tasks from $ARGUMENTS. Tasks are separated by | (pipe character).

If $ARGUMENTS is empty, use AskUserQuestion to ask the user to describe their tasks (they can provide multiple separated by |).

For each task description:

  • Trim whitespace
  • Generate a kebab-case branch name: claude/<kebab-case-task> (max 50 chars, alphanumeric and hyphens only)
  • Generate a worktree directory path: ../worktrees/<repo-name>/claude-<kebab-case-task>

Step 3: Create Worktrees

For each task:

  1. Create the parent directory if needed: mkdir -p ../worktrees/<repo-name>
  2. Create the worktree:
    git worktree add -b claude/<name> ../worktrees/<repo-name>/claude-<name> origin/<main-branch>
    
  3. Write a .worktree-task.md file inside the new worktree with this content:
    # Worktree Task
    
    **Branch:** claude/<name>
    **Task:** <original task description>
    **Created:** <ISO date>
    **Source repo:** <path to main repo>
    

Step 4: Check for Dependencies

If a package.json exists in the repo root, note that each worktree may need npm install (or the appropriate package manager).

Check for:

  • package-lock.json → npm install
  • yarn.lock → yarn install
  • pnpm-lock.yaml → pnpm install
  • bun.lockb → bun install

Read the full file on GitHub · 89 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. 3mo ago First seen · 89 lines · 12 tokens per session scan A 32a29d3468a2

Subscribe to this mod's changes

worktree-init is a command published in the GitHub repository davila7/claude-code-templates (34,829 stars, last pushed today), licensed MIT. It adds 12 tokens to every session and 831 once invoked, about $0.0000 per session on Opus 5.5. 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.

Related

worktree-init compared with commands from other repositories

worktree-init next to 6 commands from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
worktree-initdavila7/claude-code-templatesCommand35ktodayMITA12Claude Code
ccc-forkKevinZai/commanderCommand6todayMITA46Claude Code
ccc-multi-repoKevinZai/commanderCommand6todayMITA48Claude Code
ccc-parallelKevinZai/commanderCommand6todayMITA36Claude Code
ccc-aoKevinZai/commanderCommand6todayMITA35Claude Code
ccc-prKevinZai/commanderCommand6todayMITA34Claude Code
ccc-verifyKevinZai/commanderCommand6todayMITA62Claude Code