worktree-task

Creates and cleans up git worktrees for isolated per-task branches.

Updated Jul 23, 2026
One-click install
npx skills add https://github.com/serhii-baksheiev/create-agent-rig --skill worktree-task-serhii-baksheiev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: worktree-task
Source: https://github.com/serhii-baksheiev/create-agent-rig/tree/main/.agents/skills/worktree-task
Command: npx skills add https://github.com/serhii-baksheiev/create-agent-rig --skill worktree-task-serhii-baksheiev

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Concurrent sessions or agents working in the same repository overwrite each other's edits when they share a single working tree. This Skill enforces a one-task-one-branch workflow by giving every task its own git worktree, and it handles the full cleanup after the branch is merged. ## Core Features & Use Cases - Worktree creation off the remote default branch: Fetches origin and branches from origin/HEAD so work never starts from a stale local copy, with a consistent <type>/<slug> branch naming convention. - Post-merge cleanup: Removes the worktree, prunes metadata, deletes local and remote branches, and handles leftover directories. - Concurrency gotcha handling: Documents failure modes like stale working directories creating nested worktrees, removal failing while a shell sits inside the worktree, and the rule against touching another session's worktree. - Use Case: An unattended agent run and a manual session both need to modify the same repo; each starts its task in .claude/worktrees/<slug> so their edits never collide. ## Quick Start Ask the agent to start a new task in its own git worktree branched off the remote default branch before making any code changes.

Frequently Asked Questions about worktree-task

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a git worktree for a new task branch?

Change to the repository root with an absolute path, run git fetch origin, then git worktree add -b <type>/<slug> .claude/worktrees/<slug> origin/HEAD. Verify with git worktree list that the path sits directly under .claude/worktrees/.

How do I remove a git worktree after merging a pull request?

Change directory out of the worktree first, then run git worktree remove with --force, followed by git worktree prune. Delete the local branch with git branch -D and the remote branch with git push origin --delete if the merge did not already remove it.

Why does git worktree remove fail while my shell is inside it?

Git refuses to remove a worktree while a process holds it open, including your own shell or a watcher holding node_modules. Change directory out first; if the directory survives, run git worktree prune and delete the leftover directory manually.

When should I use a git worktree instead of just a branch?

Use a worktree whenever anything else might touch the repo concurrently, such as an unattended agent run or a second session. A single attended session on a quiet repo can use a plain branch; the branch discipline is mandatory, the worktree is not.

Why does a new worktree fail with module resolution errors?

A fresh worktree starts with an empty node_modules directory, so dependencies are missing. Install dependencies inside the worktree before running tests, otherwise the failure appears as a confusing module-resolution error.