MCPInstall

worktree

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.

Installs
213
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/poteto/noodle --skill worktree
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads worktree automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

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

noodle worktree list

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

Create

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

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.

# 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:

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

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

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

noodle worktree cleanup <name>

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

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:

# 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>

FAQ

What does the worktree skill do?

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.

How do I install worktree?

Run npx skills add https://github.com/poteto/noodle --skill worktree in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/worktree/ (personal) or .claude/skills/worktree/ (project).

Which AI agents can use worktree?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is worktree safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains worktree?

It is published by poteto in poteto/noodle. It has 213 recorded installs.

More from poteto/noodle

View all →

adversarial-review

poteto/noodle

Adversarial code review using cross-model approach. Spawns reviewers on the opposing model (Claude uses Codex, Codex uses Claude) to challenge work from distinct critical lenses. Produces a synthesized verdict with findings and lead judgment. Triggers: "adversarial review".

unslop

poteto/noodle

Remove AI writing patterns from prose. Use for docs, READMEs, blog posts, any non-code text that should sound human. Triggers: "unslop", "humanize", "make this sound human", "clean up this writing", "edit for voice", "de-AI this text".

Docs & Writing907 installs

ts-best-practices

poteto/noodle

Open the skill to read its SKILL.md instructions.

debugging

poteto/noodle

Systematic root-cause debugging methodology. Use for any technical problem — errors, failures, unexpected behavior, or when stuck. Triggers: "debug", "fix this", "what's wrong", "investigate".

quality

poteto/noodle

Open the skill to read its SKILL.md instructions.

235 installs

commit

poteto/noodle

Create conventional commit messages. Use when the user says "commit this", "save changes", "git commit", asks to commit code, write a commit message, or format git history. Follows conventional commits specification.

Popular ai & agents skills

View category →

google-agents-cli-publish

google/agents-cli

This skill should be used when the user wants to "publish an agent", "publish my ADK agent", "register an agent with Gemini", "publish to Gemini" (formerly Gemini Enterprise), or needs guidance on the agents-cli publish gemini command. Also use when the user wants to "manage agents in Agent Registry", "list/update/delete registered agents", or "register an MCP server". Covers ADK vs A2A registration modes, programmatic and interactive usage, flag reference, auto-detection from deployment metadata, Agent Registry fleet management, and troubleshooting. Part of the agents-cli skills suite. Do NOT use for deployment (use google-agents-cli-deploy).

AI & Agents513.9K installs

google-agents-cli-eval

google/agents-cli

This skill should be used when the user wants to "run an evaluation", "evaluate my agent", "evaluate my ADK agent", "write an eval dataset", "analyze eval failures", "compare eval results", "optimize agent", or needs guidance on the Gemini platform eval methodology and the Quality Flywheel. Covers eval metrics, dataset schema, LLM-as-judge scoring, and common failure causes. Applies to any agents-cli project, whatever framework the agent is written in. Do NOT use for agent API code patterns (ADK: use google-agents-cli-adk-code), deployment (use google-agents-cli-deploy), or project scaffolding (use google-agents-cli-scaffold).

AI & Agents513.5K installs

skill-creator

anthropics/skills

Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.

OfficialAI & Agents416.4K installs

codex-pet

prime-skills/runcomfy-agent-skills

Codex Pet generator on RunComfy. Build a Codex-compatible Codex Pet spritesheet.webp + pet.json from a single reference image, drop it into ${CODEXHOME:-$HOME/.codex}/pets/ / and Codex picks it up as a custom Codex Pet next to the 8 built-ins. This skill produces the exact Codex Pet atlas Codex expects (1536x1872 PNG/WebP, 8 cols x 9 rows, 192x208 cells, 9 animation states — idle, running-right, running-left, waving, jumping, failed, waiting, running, review). Calls OpenAI GPT Image 2 edit ONCE via the local RunComfy CLI as runcomfy run openai/gpt-image-2/edit to produce a canonical Codex Pet pose, then assembles all 9 animation rows programmatically with ImageMagick micro-transforms — no Codex Pro, no $imagegen, no OPENAIAPIKEY required, only RUNCOMFYTOKEN. Triggers on "codex pet", "create codex pet", "make codex pet", "hatch codex pet", "/hatch image", "desktop pet codex", "codex pets", "spritesheet.webp", or any explicit ask to build a custom pet for OpenAI Codex.

AI & Agents402.1K installs

full-output-enforcement

leonxlnx/taste-skill

Overrides default LLM truncation behavior. Enforces complete code generation, bans placeholder patterns, and handles token-limit splits cleanly. Apply to any task requiring exhaustive, unabridged output.

AI & Agents401K installs

executing-plans

obra/superpowers

Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available

AI & Agents245.7K installs