worktree-agent
FeaturedMandatory rules for agents in git worktree isolation.
AI & Automation 425 stars
46 forks Updated yesterday MIT
Install
Quality Score: 96/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
Skill Content
# Worktree Agent Rules
Mandatory rules for any agent dispatched with `isolation: "worktree"`.
## Rule 1: Verify Your Working Directory
On start, run `pwd`. Your path MUST contain `.claude/worktrees/`.
If your CWD is the main repo path, **STOP** and report the error.
## Rule 2: Create Feature Branch First
```bash
git checkout -b <branch-name>
```
Never commit on the default `worktree-agent-*` branch. Create your feature branch FIRST.
If `git checkout -b <branch-name>` fails with "a branch named X already exists":
```bash
# Option A: the branch has no commits beyond main — safe to reset and reuse
git branch -D <branch-name>
git checkout -b <branch-name>
# Option B: the branch is checked out in another active worktree — use a unique name
git checkout -b <branch-name>-2 # or append timestamp: $(date +%s)
```
If `git checkout -b <branch-name>` fails with "X is already used by worktree at Y":
```bash
# Branch is live in another worktree — use a unique suffix
git checkout -b <branch-name>-$(date +%s)
```
To update a branch held by another worktree (e.g. an existing PR branch): work detached from `origin/<branch>` and push with `git push origin HEAD:<branch>`. `gh pr merge`'s post-merge local-checkout errors are harmless.
## Rule 3: Use Worktree-Relative Paths
Never hardcode absolute paths from the main repo. Use `$(git rev-parse --show-toplevel)/path`.
**Exception**: Reading gitignored ADR files requires the main repo absolute path.
## Rule 4: Ignore Auto-Plan Hooks...
Details
- Author
- notque
- Repository
- notque/vexjoy-agent
- Created
- 6 months ago
- Last Updated
- yesterday
- Language
- Python
- License
- MIT
Similar Skills
Semantically similar based on skill content — not just same category
AI & Automation Listed
worktree-per-agent
Isolate an agent's work in its own git worktree branched off the default branch, so two agents never land conflicting changes on the shared checkout. Use at the start of any implementation task in a repo where others may also be working, and whenever a repo's instructions say "work in a worktree".
21 Updated today
JakeSelby AI & Automation Listed
isolated-worktree
Implement and review in a sibling git worktree created from the latest default branch. Use when launching subagents, implementing a feature, reviewing a PR, or before any repo edits so agents do not work on main/master or nest worktrees inside a checkout.
0 Updated 2 weeks ago
singleton-sd