Agent skill

Worktree

by poteto in poteto/noodle

A skill your agent uses for concurrent sessions, agent team isolation, or any work needing a separate branch.

MITAuto-check passedDevelopment

Install Worktree

skills CLI
$ npx skills add poteto/noodle --skill worktree -a claude-code

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

GitHub CLI
$ gh skill install poteto/noodle worktree --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/poteto/noodle.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/worktree .claude/skills/worktree && 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
worktree
GitHub stars
437
Token cost
~1.4k tokens
SKILL.md length
672 words
Files
1
Skills in repo
26
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses for concurrent sessions, agent team isolation, or any work needing a separate branch.

  • Works in 4 steps: noodle worktree exec — CWD-safe by design → Subshells: (cd /path && cmd) — CWD… → Absolute paths: go build /path/to/pkg/... → …
  • Concurrent sessions
  • SKILL.md covers Valid Workspace Definition, Commands, Critical Safety Rules and Parallel Agent Teams, plus 2 more sections
  • Calls git and go

What it does

Worktree is an agent skill from poteto/noodle. Use for concurrent sessions, agent team isolation, or any work needing a separate branch. Critical for multi-agent workflows. Triggers: "worktree", "new worktree", "clean up worktrees", "need isolation", or when spawning agent teams.

Its SKILL.md is about 1.4k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Git worktrees. The repository describes itself as: Orchestrate agents using skills. The licence is MIT.

When your agent uses it

  • Concurrent sessions
  • Agent team isolation
  • Any work needing a separate branch

Example prompts

  • “worktree”
  • “new worktree”
  • “clean up worktrees”
  • “/worktree”

Workflow steps

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

  1. noodle worktree exec — CWD-safe by design
  2. Subshells: (cd /path && cmd) — CWD resets when subshell exits
  3. Absolute paths: go build /path/to/pkg/...
  4. Tool flags: git -C , go -C

What it can do on your machine

Read from SKILL.md and the folder at commit 82d2921. 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
    • go

    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

Worktree loads about 1.4k tokens when it runs. Until then it costs about 61 tokens; SKILL.md has 672 words of instructions outside code blocks.

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

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 poteto/noodle at commit 82d2921, republished under its MIT licence (© poteto). 672 words, ~1,421 tokens.

Download SKILL.mdSave it as .claude/skills/worktree/SKILL.md (or your agent's skills folder).
name
worktree
description
Use for concurrent sessions, agent team isolation, or any work needing a separate branch. Critical for multi-agent workflows. Triggers: "worktree", "new worktree", "clean up worktrees", "need isolation", or when spawning agent teams.

Worktree

Default to linked-worktree isolation. Multiple sessions often run concurrently. Setup costs ~30 seconds and prevents hours of merge pain.

Valid Workspace Definition

  • Valid for significant or autonomous work: linked checkout created via Skill(worktree) create (typically .worktrees/<name>)
  • Not valid by default: primary checkout at repo root
  • Allowed exception: interactive, single-agent, small changes can run in primary checkout when that is the deliberate choice

All operations use noodle worktree — it enforces CWD safety, correct sequencing, stash/rebase handling, and dep reinstall.

Commands

Preflight
bash
noodle worktree list

Shows all worktrees with merge status. Run at session start to spot stale worktrees from crashed sessions.

Create
bash
noodle worktree create <name>

Creates worktree + branch at .worktrees/<name>, symlinks .claude/settings.local.json, auto-detects package manager, installs deps.

Run commands inside a worktree
bash
noodle worktree exec <name> <command...>

Runs the command inside the worktree via cmd.Dir. The parent shell's CWD never changes — this is the safe way to run builds, tests, or any tool that needs the worktree as CWD.

bash
# Examples
noodle worktree exec my-feature go test ./...
noodle worktree exec my-feature go build ./...

For git operations, git -C also works and doesn't need exec:

bash
git -C <project-root>/.worktrees/<name> status
git -C <project-root>/.worktrees/<name> add -A
git -C <project-root>/.worktrees/<name> commit -m "message"

File reads/edits use absolute paths directly — no exec needed.

Merge
bash
noodle worktree merge <name>
noodle worktree merge <name> --into <branch>

Single command does: CWD safety check -> stash worktree noise -> rebase onto target branch -> merge -> remove worktree -> delete branch -> prune -> reinstall deps. Refuses to run if CWD is inside the worktree or if root checkout is not on the target branch.

By default, the target is the integration branch, auto-detected from origin/HEAD (falls back to main if detection fails). Use --into to merge into any branch — the root checkout must be on that branch when you run the command.

If there are no commits to merge, it exits early and leaves the worktree/branch in place so you can decide whether to continue work or run cleanup.

Merges are serialized via lockfile (.worktrees/.merge-lock). If another merge is in progress, the command waits with short retry intervals (default timeout: 5 minutes) and then proceeds automatically. Stale locks from crashed processes are detected and cleaned up automatically.

Prune merged/patch-equivalent worktrees
bash
noodle worktree prune

Auto-cleans safe worktrees:

  • no commits ahead of integration branch, or patch-equivalent commits only
  • clean working tree (no uncommitted changes)
  • removes stale .worktrees/<name> directories that are no longer real worktrees
Clean up without merging
bash
noodle worktree cleanup <name>

Warns if there are unmerged commits. Use --force to discard them.

Show full SKILL.md (313 more words)Show less

Critical Safety Rules

NEVER cd into .worktrees/ — if the shell CWD is inside a worktree when it gets removed, the shell dies permanently (exit code 1, no recovery, session over). This applies to:

  • Direct cd /path/to/worktree && ... in Bash tool calls
  • Any command that changes CWD as a side effect

The Bash tool maintains a persistent shell — cd in one call persists to ALL future calls. A later rm -rf or git worktree remove on that path kills the shell instantly.

Always use one of these instead:

  1. noodle worktree exec <name> <cmd> — CWD-safe by design
  2. Subshells: (cd /path && cmd) — CWD resets when subshell exits
  3. Absolute paths: go build /path/to/pkg/...
  4. Tool flags: git -C <path>, go -C <path>

Parallel Agent Teams

  1. Lead creates one worktree per teammate: noodle worktree create phase-1
  2. Spawn each with mode: "acceptEdits" — worktrees are isolated scratch space
  3. Each teammate commits on its own branch
  4. Lead merges each: noodle worktree merge phase-1

Sub-agent hierarchies: A lead agent working in its own worktree (branch lead-work) can spawn sub-agents with their own worktrees. Sub-agents merge back into the lead's branch, not main:

bash
# Root checkout must be on the target branch
git checkout lead-work
noodle worktree merge sub-work --into lead-work

Foundational changes: If Phase 1 is a foundation later phases need, do it on main first, commit, then create parallel worktrees. Branches start from the commit they were created at.

When not to use: sequential tasks, read-only research, single-agent work with no concurrency risk.

Conventions

  • Directory: .worktrees/ at project root (gitignored)
  • Naming: .worktrees/<branch-name>
  • Branches are ephemeral — merge back to main and delete when done
  • Brain vault is shared state — never branch it. Teammates send results back to the lead.

Stale Worktree Triage

Use noodle worktree list to check status, then:

  1. Merged (shows "safe to clean up") -> noodle worktree cleanup <name>
  2. Unmerged with commits -> report to user, let them decide merge vs discard
  3. No commits -> crashed session artifact -> noodle worktree cleanup <name>

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

Files

Just SKILL.md in .agents/skills/worktree of poteto/noodle.

Open the folder on GitHubat commit 82d2921

Compare with similar skills

Worktree 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.

Worktree compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Worktree this skillpoteto/noodle437—~1.4kAutomated safety check: PassMIT
Finishing a Development Branchobra/superpowers296k5 repos~1.9kAutomated safety check: PassMIT
Migrate Core Code to Submodulestinyhumansai/openhuman42k—~2.6kAutomated safety check: PassGPL-3.0
Finishing A Development Branchfarm-fe/farm5.6k34 repos~1.8kAutomated safety check: PassMIT
Git Worktree Cleanuplobehub/lobehub83k—~2.8kAutomated safety check: PassCustom licence
Keep Codex Fastvibeforge1111/keep-codex-fast1.6k—~3.1kAutomated safety check: PassMIT

Similar skills

  • Walks the last step of a branch: confirm tests pass, detect the git environment, ask how to integrate, carry out your choice and clean up the worktree.

    296k GitHub starsUsed in 5 repos~1.9k tokens
    DevelopmentAuto-check passed
  • Migrate Core Code to Submodules

    tinyhumansai/openhuman

    Plans and carries out moving non-host-specific code and its tests from the OpenHuman core into vendored tiny submodule libraries, then releases the submodule and re-pins the host.

    42k GitHub stars~2.6k tokensUpdated today
    DevelopmentAuto-check passed
  • A skill your agent uses when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for…

    5.6k GitHub starsUsed in 34 repos~1.8k tokens
    DevelopmentAuto-check passed
  • Git Worktree Cleanup

    lobehub/lobehub

    Audits stale Git worktrees and branches with a bundled script, classifies each one, and deletes only after you approve the exact candidates.

    83k GitHub stars~2.8k tokensUpdated today
    DevelopmentAuto-check passed
  • Keep Codex Fast

    vibeforge1111/keep-codex-fast

    A skill your agent uses when Codex feels slow or bloated, when local sessions/logs/worktrees/config have grown over time, or when a user wants safe maintenance for Codex Desktop/CLI state.

    1.6k GitHub stars~3.1k tokensUpdated 5 mo ago
    DevelopmentAuto-check passed
  • Pre-Release PR Triage

    jamiepine/voicebox

    Sorts a backlog of open pull requests into must-merge, candidate, superseded and deferred, writes a triage doc and works the merge loop before a release.

    57k GitHub stars~3.1k tokensUpdated yesterday
    DevelopmentAuto-check passed

More from poteto/noodle

All 26 skills in this repo
  • Meditate

    poteto/noodle

    Audit and evolve the brain vault — prune outdated content, discover cross-cutting principles, review skills for structural encoding opportunities.

    437 GitHub stars~1.1k tokensUpdated 6 mo ago
    Auto-check passed
  • Ruminate

    poteto/noodle

    Mine past Claude Code and Codex conversations for uncaptured patterns, corrections, and knowledge.

    437 GitHub stars~1.4k tokensUpdated 6 mo ago
    Auto-check passed
  • Ast Grep

    poteto/noodle

    Structural code search via ast-grep — use when code shape and element relationships matter, not just text.

    437 GitHub stars~531 tokensUpdated 6 mo ago
    Auto-check passed
  • Execute

    poteto/noodle

    Implementation methodology for executing tasks. An agent skill from poteto/noodle.

    437 GitHub stars~989 tokensUpdated 6 mo ago
    Auto-check passed
  • Noodle

    poteto/noodle

    Operate the Noodle CLI — explain commands, find flags, create/edit .noodle.toml config.

    437 GitHub stars~1.3k tokensUpdated 6 mo ago
    Auto-check passed
  • Plan

    poteto/noodle

    Systematic planning for medium-to-large tasks. An agent skill from poteto/noodle.

    437 GitHub stars~1.6k tokensUpdated 6 mo ago
    Auto-check passed

Categories

Questions about Worktree

What does Worktree do?

A skill your agent uses for concurrent sessions, agent team isolation, or any work needing a separate branch. Worktree is an agent skill from poteto/noodle. Use for concurrent sessions, agent team isolation, or any work needing a separate branch.

When should I use Worktree?

Worktree fits situations like: concurrent sessions; agent team isolation; any work needing a separate branch.

How do I install Worktree in Claude Code?

Run `npx skills add poteto/noodle --skill worktree -a claude-code`. Or copy the skill folder (.agents/skills/worktree in poteto/noodle) into .claude/skills/worktree in your project. Claude Code loads it when a task matches its description.

How do I install Worktree in Codex?

Run `npx skills add poteto/noodle --skill worktree -a codex`. Or copy the skill folder (.agents/skills/worktree in poteto/noodle) into .agents/skills/worktree in your project. Codex loads it when a task matches its description.

Can I use Worktree 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 poteto/noodle --skill worktree -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/worktree, .gemini/skills/worktree, .github/skills/worktree and .opencode/skills/worktree in your project.

What does Worktree need to run?

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

Does Worktree 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 Worktree 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 Worktree use?

Worktree 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 Worktree use?

About 1.4k tokens (SKILL.md is roughly 5.7k 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 Worktree?

Skills that share tags, products or a category with Worktree: Finishing a Development Branch (obra/superpowers, 296k stars), Migrate Core Code to Submodules (tinyhumansai/openhuman, 42k stars), Finishing A Development Branch (farm-fe/farm, 5.6k stars) and Git Worktree Cleanup (lobehub/lobehub, 83k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Worktree?

poteto (a GitHub user) maintains it in poteto/noodle, which has 437 GitHub stars. The repository holds 26 skills in this directory. The repository was last updated on March 19, 2026.

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