← All skills

Use Git Worktrees

Ensure an isolated workspace exists for feature work via git worktrees. Creates a worktree at the canonical location before any implementation. Single-repo work: <repo>/.worktrees/<name>/. Cross-repo or persistent: ~/.ai/worktrees/<name>/. Use at the start of any non-trivial feature or before executing implementation plans.

Class skillID skill/using-git-worktreesVersion 1.0.0Lifecycle stableAuthor convergent-systems-key
codegitworktreeisolation
Inputs
NameTypeDescription
branch_name stringThe feature branch name (kebab-case).
base_branch optionalstringThe base branch to branch from. Defaults to main.
global optionalbooleanWhen true, place at ~/.ai/worktrees/ (cross-repo/persistent). Defaults to false.
Outputs
NameTypeDescription
worktree_pathstringAbsolute path to the created worktree.
Side effects
System prompt fragment

Before starting feature work: (1) Determine the lifecycle — single-repo ephemeral → /.worktrees//; cross-repo or persistent → ~/.ai/worktrees//. (2) Create the worktree: git worktree add -b main. (3) All file writes go in the worktree — never touch the main worktree. (4) On completion: git worktree remove (use remove, not rm -rf). If a worktree already exists for this branch, use it. Never create worktrees at ad-hoc locations (../branch/, /tmp/, sibling dirs).

Attribution: convergent-systems-key. License: Apache-2.0 or as stated by the originating repository.