cogikyo/dotfiles/worktrees
Claude Code and agent skill by cogikyo/dotfiles
- community
Checking that the SKILL.md file is still in the repository.
Use for any branch or worktree creation, switch, or removal, and for resolving `path@branch` targets; verifies checkouts and manages named safe lifecycle operations.
Install
npx vskill@latest install cogikyo/dotfiles/worktreesSKILL.md
Worktrees
Resolve checkouts, then create, verify, or remove branches and worktrees through named safe operations. Do not repurpose another work thread's checkout.
Preflight
Interpret <repository-or-worktree-path>@<branch> as a repository target by default. Split at the final @, resolve the filesystem prefix, then check the suffix as a branch or ref in that repository. Treat the complete string as a literal path only when the user marks it literal or repository evidence rejects the split. For example, ~/dotfiles@main means path ~/dotfiles and ref main; a suffix that is not a Git ref stays part of the path.
Worktrees normally live under <repository>/.worktrees/<name>. Use git worktree list --porcelain as authority for their paths and branches; directory names are only hints. A workspace root may contain several repositories without being a repository itself. Resolve each repository independently rather than carrying one sibling's branch choice into another.
For each target:
- Verify the repository root, current branch, worktree list, and staged, unstaged, and untracked changes immediately before editing, delegating, or running branch-sensitive commands.
- Reuse the worktree holding the requested branch, even when the user supplied the main repository path.
- If the supplied worktree is on another branch, locate the matching worktree instead of switching that checkout.
- If no matching worktree exists, return a creation plan for approval unless the current brief already approves that exact operation.
- Pass children the resolved repository root, exact worktree path, and verified branch or detached ref instead of unresolved
path@branchnotation. - Recheck Git state after interruptions, child returns, or signs of concurrent checkout changes.
Use these read-only checks in the resolved checkout:
An empty branch name means detached HEAD; verify its commit against the requested ref before treating it as the target.
Create an approved worktree
- Read the repository's placement and setup rules before choosing a destination.
- Confirm the existing branch, or the new branch name and explicit starting ref; do not assume the current HEAD is the intended base.
- Check that the branch is not already attached and the destination is unused, and verify the parent directory before creating any missing directories.
- Run only the approved creation form below, then verify the result in the new checkout.
Run these commands with the shell tool's working directory set to the resolved repository. The examples use an absolute $path, a local $branch, and an explicit approved $base OID for a new branch.
Attach an existing local branch:
Create a new branch from the approved base:
A remote-tracking ref or detached checkout needs an explicit branch/tracking or detached-HEAD choice; do not rely on Git guessing the intended form. Uncommitted changes stay in their original worktree; the new checkout starts from the selected committed ref.
Verify readiness
Run the target checks inside the selected worktree and confirm its absolute path, branch or commit, and entry in the worktree list agree. Identify unresolved merges or unexpected changes rather than declaring the checkout ready because creation returned success. An existing dirty worktree may be usable when its changes are understood and do not interfere with the approved scope.
Untracked context overlays, local config files, and installed dependencies are not copied from another checkout. Check the scoped instructions and repository-owned setup requirements before editing or delegating. If expected context is missing, stop and establish the authorized repair; a workspace-wide relink or install is not implied by worktree creation.
Report the repository and exact worktree path, verified branch or commit, whether it was reused or created, and any setup blocker. For creation, include the starting ref; distinguish a Git checkout that exists from one ready for the assigned work.
Recover without losing work
- If checkout reports local changes that ordinary status did not show, inspect the named paths with
git ls-files -vforskip-worktreeorassume-unchangedflags before choosing a repair. - On a branch attachment or destination collision, reread the worktree list and inspect the existing path instead of retrying with force.
- After an interrupted creation, reconcile the destination and Git metadata before issuing another add command.
- Do not clear index flags, stash, reset, clean, commit, or delete files to make an operation pass without approval for that action.
Removal requires a named approved path and inspection of tracked, untracked, and ignored files that would be lost. Require a clean worktree with no files to preserve, no active Git operation, and no other owner using it before git worktree remove -- <path>. Do not force removal; preservation work needs a separately approved action. Deleting the branch is a separate decision. Use Git's worktree operations rather than deleting a live worktree directory by hand.
Named branch lifecycle
Create a branch only with its approved name and starting OID, using git branch -- <name> <base-OID>; this does not switch the current checkout. For deletion, verify the named branch's tip, confirm it is not attached to any worktree or owned by another task, and prove its tip is reachable from the approved retained ref. Use only git branch -d -- <name>; if Git refuses, stop and report without -D, force, ref deletion, or configuration changes. Do not rename branches, switch existing checkouts, or prune or repair worktree metadata under this workflow. After each mutation, inspect branch refs, worktree list, and status and report what changed and what remains preserved.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingconfig/opencode/skills/git/worktrees/SKILL.md
Popularity
- Repository stars
- 122
- Repository forks
- 6
- 7-day trend score
- 29
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/cogikyo/dotfiles/worktrees)