- Home
- Skills
- Theonelee
- Theone Claude Skill
- Git Worktree Skill
git_worktree_skill_skill
- Python
0
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill theonelee/theone_claude_skill --skill git_worktree_skill- SKILL.md2.5 KB
Overview
This skill helps agents manage parallel development using git worktree. It creates independent working directories for different branches, isolates changes, and reduces conflicts in the main workspace. The skill also handles environment initialization, status sync, and safe cleanup of temporary worktrees.
How this skill works
The skill inspects the current repository state, checks whether a target branch exists, and runs git worktree commands to add or remove worktrees. It can initialize project-specific dependencies inside the new worktree (for example npm install, go mod download, or project-specific sync commands). After work completes it ensures commits and pushes are performed, then removes the worktree to free resources.
When to use it
- When multiple agents or developers must work on different branches concurrently
- When you want to isolate a risky refactor or experimental feature from the main workspace
- When CI/manual tasks require an ephemeral workspace for testing or builds
- When you need to avoid switching branches in the primary working directory
- When creating a temporary environment for debugging without affecting the main repo
Best practices
- Create worktrees outside the project root (example: ../worktrees/<branch>) to avoid accidental inclusion in repo scanning
- Always verify branch existence and use -b to create a branch when needed
- Run dependency install or environment setup inside the new worktree to avoid sharing node_modules or caches
- Commit and push changes from the worktree before removal; handle uncommitted changes explicitly to avoid data loss
- Regularly remove finished worktrees to reclaim disk space, and avoid leaving many large dependency directories active
Example use cases
- Open a worktree feat-login for a new feature, run project init commands, implement and test changes independently
- Give a bugfix task its own worktree so a CI job can run without disturbing ongoing feature work
- Spin up an ephemeral worktree to reproduce an issue against a different branch and validate a patch
- Support multiple agents: assign each agent a dedicated worktree when running parallel static analysis or refactors
FAQ
No. Git prevents checking out the same branch in multiple worktrees. Create a new branch copy or use a temporary branch for parallel work.
What if there are uncommitted changes when removing a worktree?
Handle changes by committing/pushing or stashing first. git worktree remove will fail on dirty changes unless forced; use --force with caution to avoid data loss.