Command Palette

Search for a command to run...

Back to skills
skill № 49591

worktree

Use when isolating coding work, creating agent Git worktrees, or finishing owned task protection with the native worktree manager. Preserve assigned checkouts…

FreeNo executable scripts
lanejby lanej★ 41 GitHub stars

Install worktree in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

About this skill

Agent worktrees

Use the native worktree manager for agent-created checkouts. New allocations live at <primary-repository>/.worktrees/<agent>-<8-hex>/, before a task name exists. Never fall back to a temporary directory or another allocator when the manager is missing or fails; report the failure and identify dotfiles make install as the supported installer.

Reuse assigned checkouts

Keep explicit user-selected, host-managed and preassigned checkouts, including Codex App, Codex CLI and Claude assignments. Continue there without nesting another checkout or claiming its task/lease ownership. An explicitly requested independent task may allocate from the primary repository.

Create

Read repository location constraints. The manager resolves the primary checkout even when invoked from a linked worktree, requires the default destination to be ignored, and rejects symlink redirection. Do not pass --path to bypass the agent placement convention.

worktree create --agent codex --owner-id "<full-allocation-or-agent-identity>" --json

Use the actual client slug, such as codex, claude or pi. Supply an available full owner identity; do not invent a native session ID before startup. Omit --branch for an automatically named branch or provide a fresh descriptive name. Use --base REF when the task specifies a base; otherwise the manager uses local HEAD without fetching. Task and branch descriptions may change without renaming the checkout.

Read the schema_version, command and result envelope. Retain the full id, path, branch, agent, optional owner_id and lifecycle state through handoffs. Work only at the returned path. A nonzero result can still identify a surviving protected task after a Git hook failure; inspect worktree status --json before retrying. Missing confirmation is unknown, not rollback. Do not allocate a second checkout to work around an uncertain result.

Finish and cleanup

Finish only task protection this task owns, after preserving commits on a named branch or verified remote ref and confirming no active session, process or pending work needs its protection. Inspect tracked, untracked and valuable ignored files. Keep protection when completion or ownership is uncertain.

worktree finish "<full-task-id>" --json

Verify the returned task identity and finished state. Finishing keeps the checkout and branches. Preview and explicitly prune a finished checkout when its files and activity checks permit removal:

worktree prune --worktree "<returned-path>"
worktree prune --worktree "<returned-path>" --apply

Do not use --force for routine cleanup. Preserve pre-existing and other agents' checkouts. Follow the shared cleanup procedure before removal and report any retained path with its concrete reason.

Full SKILL.md on GitHub

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

FAQ

What does the worktree skill do?

Use when isolating coding work, creating agent Git worktrees, or finishing owned task protection with the native worktree manager. Preserve assigned checkouts and prune explicitly.

How do I install the worktree skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the worktree skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare worktree with