worktree-impl
Create a git worktree for isolated implementation after planning. Use when starting implementation or when a clean worktree is requested.
When & Why to Use This Skill
The worktree-impl skill automates the creation and management of Git worktrees, allowing developers to implement features or fixes in isolated environments. By streamlining the setup of task-specific directories, it eliminates the need for frequent stashing and reduces context-switching overhead, ensuring a clean and organized version control workflow.
Use Cases
- Parallel Feature Implementation: Create a dedicated, isolated directory to start a new feature without affecting or stashing current progress in the main working tree.
- Urgent Bug Fixing: Quickly spin up a clean environment based on the production branch to address critical issues while keeping the development workspace intact.
- Concurrent Code Comparison: Maintain multiple active branches in separate folders to run tests or compare behaviors across different versions of the codebase simultaneously.
- Automated Workspace Setup: Use the agent to handle branch naming, fetching, and directory sanitization for a standardized project structure under .worktrees/.
| name | worktree-impl |
|---|---|
| description | Create a git worktree for isolated implementation after planning. Use when starting implementation or when a clean worktree is requested. |
Git Worktree Implementation
Workflow
- Confirm the current directory is a git repo.
- Fetch latest refs:
git fetch origin. - List existing worktrees:
git worktree list. - Decide branch name.
- If a name is provided, use it.
- Otherwise infer naming from
git branch -rand propose a name for approval.
- Determine base branch:
git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'
- Create the worktree:
git worktree add -b <branch-name> .worktrees/<sanitized-name> origin/<base><sanitized-name>replaces/with-.
- Offer next actions:
cd <worktree-path> && codex- Continue in current session after
cd
Placement rules
- Place worktrees under
<repo>/.worktrees/<branch-name>/. - Keep
.worktrees/out of version control (add to.gitignoreif needed).