Agent skill

Using Git Worktrees

by KbWen in KbWen/agentic-os

Use Git worktrees to create parallel working directories safely; avoid branch-switch contamination.

MITAuto-check passedAgent Workflows

Install Using Git Worktrees

skills CLI
$ npx skills add KbWen/agentic-os --skill using-git-worktrees -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install KbWen/agentic-os using-git-worktrees --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/KbWen/agentic-os.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/using-git-worktrees .claude/skills/using-git-worktrees && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
using-git-worktrees
GitHub stars
206
Token cost
~538 tokens
SKILL.md length
289 words
Files
2
Skills in repo
12
Repo updated
First seen
Licence
MIT

At a glance

Use Git worktrees to create parallel working directories safely; avoid branch-switch contamination.

  • Works in 6 steps: Detect nesting first — do not create a… → Ensure the primary workspace is clean… → List existing worktrees first: git… → …
  • Tasks that involve Git worktrees
  • SKILL.md covers Overview, Workspace Selection Principles, Safety Checks and Setup Workflow, plus 1 more section
  • Calls git

What it does

Using Git Worktrees is an agent skill from KbWen/agentic-os. Use Git worktrees to create parallel working directories safely; avoid branch-switch contamination.

Its SKILL.md is about 540 tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files (for example `agents/openai.yaml`).

It sits in Agent Workflows, covering Git worktrees. It works with Git. The repository describes itself as: Governance framework for AI coding agents. It runs them through a five-step workflow (plan, build, review, test, ship) where no step counts as done without evidence. Drop-in… The licence is MIT.

When your agent uses it

  • Tasks that involve Git worktrees

Example prompts

  • “/using-git-worktrees”

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Detect nesting first — do not create a worktree from inside another worktree or a submodule
  2. Ensure the primary workspace is clean (prevent taking uncommitted changes).
  3. List existing worktrees first: git worktree list.
  4. Check that the target directory does not exist or is empty.
  5. Keep the worktree path out of the tracked tree — prefer a sibling dir (../wt-). If it must live inside the repo, verify it is ignored…
  6. Confirm branch naming and tracking strategies.

What it can do on your machine

Read from SKILL.md and the folder at commit 81a4034. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • git

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Using Git Worktrees loads about 538 tokens when it runs. Until then it costs about 30 tokens; SKILL.md has 289 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~30
When it runs · the whole SKILL.md, loaded when a task matches
~538

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from KbWen/agentic-os at commit 81a4034, republished under its MIT licence (© KbWen). 289 words, ~538 tokens.

Download SKILL.mdSave it as .claude/skills/using-git-worktrees/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
using-git-worktrees
description
Use Git worktrees to create parallel working directories safely; avoid branch-switch contamination.

Using Git Worktrees

Overview

Git worktree allows mounting multiple working directories onto the same repository simultaneously, each mapped to a different branch. This is ideal for parallel development and hotfixes.

Workspace Selection Principles

  • Manage them centrally outside the repo or in a dedicated folder (e.g., ../wt-<task>).
  • Name them with task semantics (feature/hotfix + short name).
  • Avoid confusing or overwriting existing workspaces.

Safety Checks

  1. Detect nesting first — do not create a worktree from inside another worktree or a submodule:
    • You are already in a linked worktree if git rev-parse --git-dir differs from git rev-parse --git-common-dir (they match in the main worktree). cd to the main worktree before adding.
    • You are in a submodule if git rev-parse --show-superproject-working-tree is non-empty. Operate on the intended repo, not the submodule.
  2. Ensure the primary workspace is clean (prevent taking uncommitted changes).
  3. List existing worktrees first: git worktree list.
  4. Check that the target directory does not exist or is empty.
  5. Keep the worktree path out of the tracked tree — prefer a sibling dir (../wt-<task>). If it must live inside the repo, verify it is ignored first: git check-ignore -q <path> (exit 0 = ignored). A non-ignored in-repo worktree pollutes the parent's git status and can be committed by accident.
  6. Confirm branch naming and tracking strategies.

Setup Workflow

  1. Create a branch and add a worktree:
    • git worktree add ../wt-<task> -b <branch-name>
  2. Switch to the new directory and run a baseline test.
  3. Develop, commit, and verify independently in that directory.
  4. Remove the worktree when finished (if no longer needed):
    • git worktree remove ../wt-<task>

Common Mistakes

  • Committing in the wrong worktree.
  • Deleting a worktree without confirming if the branch should be preserved.
  • Chaotic directory naming, leading to unclear task mapping.

© KbWen, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in .agents/skills/using-git-worktrees of KbWen/agentic-os.

  • SKILL.md
  • agents/openai.yaml

Open the folder on GitHubat commit 81a4034

Compare with similar skills

Using Git Worktrees next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Using Git Worktrees compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Using Git Worktrees this skillKbWen/agentic-os206—~538Automated safety check: PassMIT
Using Git Worktreesfarm-fe/farm5.6k13 repos~2kAutomated safety check: PassMIT
Agtx Task Sweepfynnfluegge/agtx1.7k—~1.7kAutomated safety check: PassApache-2.0
PRP Workstream OrchestratorWirasm/prp2.3k—~3.5kAutomated safety check: PassMIT
Squad Agent Collaboration Patternsmicrosoft/waza1.4k4 repos~500Automated safety check: PassMIT
Vspawnvlinx-io/VelaTerm270—~2.5kAutomated safety check: PassMIT

Similar skills

  • A skill your agent uses when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git…

    5.6k GitHub starsUsed in 13 repos~2k tokens
    Agent WorkflowsAuto-check passed
  • Agtx Task Sweep

    fynnfluegge/agtx

    Breaks a conversation's results into feature-level tasks and pushes them to the agtx kanban board, where each task gets its own worktree and agent session.

    1.7k GitHub stars~1.7k tokensUpdated 5 days ago
    Agent WorkflowsAuto-check passed
  • Coordinates several PRP workstreams in isolated Git worktrees from one session, verifying proof, holding merge gates and sequencing the merges.

    2.3k GitHub stars~3.5k tokensUpdated 6 days ago
    Agent WorkflowsAuto-check passed
  • Official

    Shared collaboration rules for a team of squad agents covering worktree awareness, writing decisions to an inbox, cross-agent requests and reviewer lockout.

    1.4k GitHub starsUsed in 4 repos~500 tokens
    Agent WorkflowsAuto-check passed
  • Vspawn

    vlinx-io/VelaTerm

    Explicitly spawn a standalone child session under the current vlx-term session, passing the task in as its first message (mirrors spawntask).

    270 GitHub stars~2.5k tokensUpdated yesterday
    Agent WorkflowsAuto-check passed
  • Guides decisions for agents working in an aweb team: when to check shared state, claim tasks, take locks, read team roles and instructions, and open separate worktrees.

    115 GitHub stars~4k tokensUpdated today
    Agent WorkflowsAuto-check passed

More from KbWen/agentic-os

All 12 skills in this repo
  • API Design

    KbWen/agentic-os

    Design or review REST/GraphQL APIs when endpoints or contracts change.

    206 GitHub stars~1k tokensUpdated yesterday
    Auto-check passed
  • Frontend Patterns

    KbWen/agentic-os

    Apply frontend conventions when components, pages, forms, or client state change.

    206 GitHub stars~1.2k tokensUpdated yesterday
    Auto-check passed
  • Karpathy Principles

    KbWen/agentic-os

    Behavioral guidelines to reduce common LLM coding mistakes — Think Before Coding, Simplicity First, Surgical Changes, Goal-Driven Execution.

    206 GitHub stars~1.5k tokensUpdated yesterday
    Auto-check passed
  • Production Readiness

    KbWen/agentic-os

    Use at review and ship, automatically for feature or architecture changes and on request for error handling, logging, crash reporting, or observability; verify errors reach production monitoring.

    206 GitHub stars~938 tokensUpdated yesterday
    Auto-check passed
  • Doc Lookup

    KbWen/agentic-os

    Check official docs when framework APIs or configuration may be version-sensitive.

    206 GitHub stars~2.6k tokensUpdated yesterday
    Auto-check: warnings
  • Systematic Debugging

    KbWen/agentic-os

    A skill your agent uses when investigating a bug, test failure, flaky test, unexpected behavior, or a hotfix, or an unexplained or failed fix; find the root cause first.

    206 GitHub stars~496 tokensUpdated yesterday
    Auto-check passed

Works with

Questions about Using Git Worktrees

What does Using Git Worktrees do?

Use Git worktrees to create parallel working directories safely; avoid branch-switch contamination. Using Git Worktrees is an agent skill from KbWen/agentic-os. Use Git worktrees to create parallel working directories safely; avoid branch-switch contamination.

When should I use Using Git Worktrees?

Using Git Worktrees fits situations like: tasks that involve Git worktrees.

How do I install Using Git Worktrees in Claude Code?

Run `npx skills add KbWen/agentic-os --skill using-git-worktrees -a claude-code`. Or copy the skill folder (.agents/skills/using-git-worktrees in KbWen/agentic-os) into .claude/skills/using-git-worktrees in your project. Claude Code loads it when a task matches its description.

How do I install Using Git Worktrees in Codex?

Run `npx skills add KbWen/agentic-os --skill using-git-worktrees -a codex`. Or copy the skill folder (.agents/skills/using-git-worktrees in KbWen/agentic-os) into .agents/skills/using-git-worktrees in your project. Codex loads it when a task matches its description.

Can I use Using Git Worktrees in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add KbWen/agentic-os --skill using-git-worktrees -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/using-git-worktrees, .gemini/skills/using-git-worktrees, .github/skills/using-git-worktrees and .opencode/skills/using-git-worktrees in your project.

What does Using Git Worktrees need to run?

Going by SKILL.md and its folder, Using Git Worktrees needs the command-line tools its instructions call (git).

Does Using Git Worktrees access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Using Git Worktrees safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Using Git Worktrees use?

Using Git Worktrees is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Using Git Worktrees use?

About 538 tokens (SKILL.md is roughly 2.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Using Git Worktrees?

Skills that share tags, products or a category with Using Git Worktrees: Using Git Worktrees (farm-fe/farm, 5.6k stars), Agtx Task Sweep (fynnfluegge/agtx, 1.7k stars), PRP Workstream Orchestrator (Wirasm/prp, 2.3k stars) and Squad Agent Collaboration Patterns (microsoft/waza, 1.4k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Using Git Worktrees?

KbWen (a GitHub user) maintains it in KbWen/agentic-os, which has 206 GitHub stars. The repository holds 12 skills in this directory. The repository was last updated on October 6, 2026.

Source: KbWen/agentic-os on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.