create-worktree

create-worktree is a command for Claude Code from gopherguides/gopher-ai. It costs 14 tokens per session (895 once invoked), scanned A, original, MIT.

A command for creating or reusing an isolated Git worktree for a GitHub issue or pull request. A worktree is a separate directory connected to the same Git repository, allowing work on another branch without changing the current checkout.

In plain words
What is it for?
Use it inside an authenticated Git repository to create or reuse the worktree and branch for a specified issue or pull request, with optional environment-file copying.
Why use it?
It reduces setup mistakes and keeps issue work separate from other local changes.

Command for Claude Code

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

Runs only inside its plugin — its command needs a path that Claude Code sets for a plugin’s own hooks and for nothing else. Install the plugin, not this.

Part of the go-workflow plugin — 11 skills, 3 commands, 4 agents, 4 hooks shipped together

Good fit Use it inside an authenticated Git repository to create or reuse the worktree and branch for a specified issue or pull request, with optional environment-file copying.

Compare 6 commands from other repositories ↓
Install

Getting it into your agent

This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.

Claude Code
/plugin marketplace add gopherguides/gopher-ai
Claude Code
/plugin install go-workflow

Made for: Claude Code.

Or install go-workflow, the plugin that ships this one along with the rest of its 11 skills, 3 commands, 4 agents, 4 hooks.

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

README.md
[![agentmods](https://agentmods.dev/badge/commands/gopherguides/gopher-ai/create-worktree/github.svg)](https://agentmods.dev/commands/gopherguides/gopher-ai/create-worktree)
Your own site
<a href="https://agentmods.dev/commands/gopherguides/gopher-ai/create-worktree"><img src="https://agentmods.dev/badge/commands/gopherguides/gopher-ai/create-worktree/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 create-worktree

Your own site · 80×15
<a href="https://agentmods.dev/commands/gopherguides/gopher-ai/create-worktree"><img src="https://agentmods.dev/badge/commands/gopherguides/gopher-ai/create-worktree.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 14 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 895 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.00014 $0.00895
Opus 5.5 $0.00006 $0.00358
Sonnet 5.5 $0.00003 $0.00179
Haiku 4.5 $0.00001 $0.00089

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

Security

Grade A, and why

create-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 1mo 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.

plugins/go-workflow/commands/create-worktree.md · 110 lines

How it starts

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

Create Worktree for Issue or PR

If $ARGUMENTS is empty or not provided:

This command creates or reuses an isolated git worktree for working on a GitHub issue or PR.

Usage: /create-worktree <issue-or-pr-number>

Examples:

  • /create-worktree 789 — create worktree for issue #789
  • /create-worktree 42 — if #42 is a PR, resolve its linked issue and create or reuse the issue worktree

What it does: detects PR vs issue → reuses an existing standard issue worktree if found → otherwise creates ../reponame-issue-<num>-<title>/ from the default branch → creates the issue branch → optionally copies env files → registers worktree state.

Prerequisites: gh authenticated; run from inside a git repository.

Ask the user: "What issue or PR number would you like to work on?"


If $ARGUMENTS is provided:

Clear Worktree State

Clear stale worktree state so the pre-tool-use hook does not block setup commands:

"${CLAUDE_PLUGIN_ROOT}/scripts/worktree-state.sh" clear 2>/dev/null || true

Environment Files

Check whether the source repo has environment files before creating or reusing the worktree:

SOURCE_DIR="$(pwd)"
"${CLAUDE_PLUGIN_ROOT}/scripts/worktree-create.sh" env-files --source-dir "$SOURCE_DIR"

If the output starts with ENV_FILES_FOUND=true, use AskUserQuestion: "Found environment files (may contain secrets). Copy them to the worktree?" with Yes, copy them / No, skip.

Create or Reuse Worktree

If the user chose to copy env files:

SOURCE_DIR="$(pwd)"
"${CLAUDE_PLUGIN_ROOT}/scripts/worktree-create.sh" create "$ARGUMENTS" --source-dir "$SOURCE_DIR" --copy-env

Otherwise:

SOURCE_DIR="$(pwd)"
"${CLAUDE_PLUGIN_ROOT}/scripts/worktree-create.sh" create "$ARGUMENTS" --source-dir "$SOURCE_DIR" --no-copy-env

The script validates input and prerequisites, detects PR vs issue, derives the standard branch and path, fetches the default branch, creates or reuses the worktree, optionally copies env files, registers state, and prints:

Read the full file on GitHub · 110 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. 1mo ago Changed · +1 lines 1b35db842cfc
  2. 1mo ago First seen · 109 lines · 14 tokens per session scan A 87dbe748cb9f

Subscribe to this mod's changes

create-worktree is a command published in the GitHub repository gopherguides/gopher-ai (21 stars, last pushed yesterday), licensed MIT. It adds 14 tokens to every session and 895 once invoked, about $0.0001 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.