worktrees

A workflow for using Git worktrees, which are separate folders and branches for the same repository.

In plain words
What is it for?
Use it to create, inspect, snapshot, clean up, and remove isolated work areas for feature work, experiments, or code reviews.
Why use it?
It lets several tasks or agents work in parallel without repeatedly switching branches or stashing changes.

Skill for Claude CodeCodex

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 skills/agallardol/zcode-git-worktrees/worktrees
Any agent
npx skills add agallardol/zcode-git-worktrees --skill worktrees
Clone the repo
git clone --depth 1 https://github.com/agallardol/zcode-git-worktrees

Made for: Claude Code, Codex.

Per session 75 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,096 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.00075 $0.01096
Opus 5 $0.00037 $0.00548
Sonnet 5 $0.00015 $0.00219
Haiku 4.5 $0.00007 $0.00110

Measured yesterday against content hash bf9d4327c49a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

worktrees 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 yesterday.

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/git-worktrees/skills/worktrees/SKILL.md · 50 lines

How it starts

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

Git worktrees for ZCode

Worktrees give every task its own directory + branch sharing one git object store — parallel agents or humans can work on the same repo without stashing, branch switching, or stepping on each other.

Always use the MCP tools (mcp__git-worktrees__*), never raw git worktree commands — the tools add validation, safety checks, snapshots, and state tracking that raw git lacks.

Tools

Tool Use
worktrees_create {name?, baseRef?, task?, carryDirty?} Create worktree at <store>/<project>/<name>, branch zcode/<name>, base fresh (origin/HEAD) by default
worktrees_list All worktrees: branch, dirty, locked, agent, size, activity
worktrees_status {name} Detail: diff stat, unpushed, snapshots
worktrees_remove {name, force?, deleteBranch?} Safe removal; snapshots uncommitted work first; branch kept by default
worktrees_cleanup {dryRun?, maxAgeDays?, maxCount?} Retention sweep (dry-run by default)
worktrees_prune Sync git + state after manual deletion
worktrees_snapshot {name} Snapshot uncommitted work on demand
worktrees_set_task {name, task?, agentId?, clearAgent?} Link a running agent to its worktree (locks it)
worktrees_auto_session {enabled?} Get/toggle auto-session mode (each new session in a main checkout gets its own worktree)

Slash commands /worktree, /worktree:new, /worktree:list, /worktree:status, /worktree:remove, /worktree:cleanup, /worktree:pr, /worktree:end, /worktree:auto drive the same tools with the full UX.

Auto-session mode (on by default)

Every NEW session started in a repo's main checkout is assigned its own worktree (branch zcode/sess-<id>, based on current HEAD). Resuming a session returns to its worktree; edits to the main checkout are blocked (PreToolUse guard) and redirected to the session worktree; /worktree:end commits everything and removes the worktree. Since sessions there run with cwd still in the main checkout, agents must use absolute paths into the worktree and git -C — the injected SessionStart context explains this. Escape hatches: Settings → Plugins → Git Worktrees or /worktree:auto off (machine-wide, most recent change wins), or per-repo .zcode/worktree.json {"autoSession": false}.

Read the full file on GitHub · 50 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. yesterday First seen · 50 lines · 0 tokens per session scan A bf9d4327c49a

Subscribe to this mod's changes

worktrees is a skill published in the GitHub repository agallardol/zcode-git-worktrees (1 stars, last pushed 11d ago), licensed MIT. It adds 75 tokens to every session and 1,096 once invoked, about $0.0004 per session on Opus 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-31.

Related

Other skills, from other repositories

reversi-master

One-click install + model switch:Claude Code,Codex CLI (OpenAI), Grok Build (xAI), DeepSeek Harness, Kimi Code (Moonshot) ,Qwen Code,Aider,OpenCode,MiMo Code (Xiaomi),ZCode (Z.AI),OpenClaw,Pi,OpenScience,Vibe-Trading,Claude Desktop (3P profile),ChatGPT desktop,OpenCode Desktop.

edison7009/EchoBird · 0 tokens

Trash Talk

AI becomes provocative and mocks the opponent during gameplay.

edison7009/EchoBird · 12 tokens

acceptance-test-authoring

Use when creating or modifying acceptance tests, configuring cucumber-js or behave runners, writing or refactoring step definitions, linting executable Gherkin specs, choosing an acceptance stack, or implementing OpenSpec tasks that involve acceptance tests.

intent-driven-dev/intent-driven-template · 51 tokens

gherkin-authoring

Use when drafting, reviewing, or improving Gherkin, Cucumber scenarios, BDD acceptance criteria, feature examples, Scenario Outlines, Backgrounds, Rules, Doc Strings, Data Tables, tags, or Gherkin embedded in Markdown.

intent-driven-dev/intent-driven-template · 54 tokens

openspec-bulk-apply-change

Use when multiple active OpenSpec changes should be applied concurrently in isolated worktrees with delegated verification and no merge.

intent-driven-dev/intent-driven-template · 30 tokens

architectural-decision-records

Use when documenting, drafting, reviewing, or updating architectural decisions, ADRs, decision logs, tradeoffs, rationale, consequences, alternatives, or architecture decision history.

intent-driven-dev/intent-driven-template · 40 tokens