| name | agent-ops-git-worktree |
| description | Manage git worktrees for isolated development. Create, list, remove, and work in worktrees. |
| category | git |
| invokes | ["agent-ops-git"] |
| invoked_by | ["agent-ops-planning"] |
| state_files | {"read":["constitution.md"],"write":["focus.md"]} |
Git Worktree Workflow
When to Use
Use git worktrees when you need to:
- Work on multiple branches simultaneously without stashing
- Isolate experimental work from main repository
- Safely test changes without affecting main working tree
- Create temporary development contexts
Preconditions
.agent/constitution.md exists
- Git repository initialized
- Worktrees directory exists:
C:\dev\temp\worktrees (or configured in constitution)
Procedure
Create Worktree
-
Create worktree with branch (one operation):
git worktree add <worktree-path> -b <branch-name>
git worktree add C:/dev/temp/worktrees/agent-ops-feat-123 feat/feature-123
-
Verify worktree:
git worktree list
ls -la <worktree-path>/.git
-
Navigate to worktree:
cd <worktree-path>
git branch --show-current
git status
git add .
git commit -m "feat: ..."
List Worktrees
git worktree list
git worktree list --porcelain
Remove Worktree
After work is complete and merged:
cd <main-repo>
git worktree remove <worktree-path>
git branch -d <feature-branch>
Worktree Cleanup
Remove stale worktrees:
git worktree list
git worktree remove <worktree-path>
Integration with Issue Tracking
When working in a worktree:
- Update
.agent/focus.md to reflect worktree location
- Track issue progress normally (updates worktree's git state)
- When committing, reference issue ID in commit message
Example Workflow
git worktree add C:/dev/temp/worktrees/agent-ops-opencode feat/opencode-bundle
cd C:/dev/temp/worktrees/agent-ops-opencode
git add .
git commit -m "feat: implement OpenCodeGenerator enhancements [FEAT-0335]"
cd C:/dev/temp/agent-ops
git merge feat/opencode-bundle
git worktree remove C:/dev/temp/worktrees/agent-ops-opencode
Scope
- ✅ Create worktrees
- ✅ List worktrees
- ✅ Remove worktrees
- ✅ Work in worktrees (normal git operations)
- ❌ Prune worktrees (use git worktree prune, which is built-in)
Notes
- Worktrees are lightweight (share same .git directory)
- Safe to delete worktree directory after removal
- No risk to main repository when working in worktree
- Perfect for feature development, bug fixes, testing
Important Rules
Never push without explicit user permission:
- Git push requires explicit user request before execution
- This is enforced by
agent-ops-git skill and applies to all workflows
- Auto-push is NEVER permitted, even for successful merges
- Always ask for confirmation before:
git push