Xpersona
I

ia-git-worktree

CLAWHUB · Unverified

Manage Git worktrees for isolated parallel development. Use when creating, listing, switching, or cleaning up git worktrees, or when needing isolated branches for concurrent reviews or feature work.

62
Rank
84
Safety
1.9k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.9K downloads reported by the source. Last updated 10/9/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17bcar8wq0xhegs0ny6f57ypd8484bw:compound-eng-git-worktree
  1. Install using `clawhub skill install s17bcar8wq0xhegs0ny6f57ypd8484bw:compound-eng-git-worktree` in an isolated environment before connecting it to live workloads.
  2. No published capability contract is available yet, so validate auth and request/response behavior manually.
  3. Review the upstream CLAWHUB listing at https://clawhub.ai/iliaal/compound-eng-git-worktree before using production credentials.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-iliaal-compound-eng-git-worktree/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

145,640 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: ia-git-worktree
class: tool
description: >-
  Manage Git worktrees for isolated parallel development. Use when creating,
  listing, switching, or cleaning up git worktrees, or when needing isolated
  branches for concurrent reviews or feature work.
---

# Git worktree manager

**GATE: If the task runs inside an existing worktree (a worktree path is given and no create/remove/switch is requested), none of the creation flow applies: work in place and skip this skill.** To check: `git rev-parse --show-toplevel` appears as a linked entry in `git worktree list`.

## Working rules

- Preserve other sessions' branches, files, and staged work (see Ownership).
- Verify dependencies resolve first-party code from the intended worktree.
- Keep merge, push, and cleanup within user authorization; report the exact exercised checkout and resulting commit.

## Always use the manager script

Never call `git worktree add` directly; always use the `worktree-manager.sh` script.

The script handles critical setup that raw git commands don't:
1. Copies `.env`, `.env.local`, `.env.test`, etc. from main repo
2. Ensures `.worktrees` is in `.gitignore`
3. Creates consistent directory structure
4. After creation, install dependencies if detected: `package.json` → `npm install`, `composer.json` → `composer install`, `pyproject.toml` → `pip install -e .`, `go.mod` → `go mod download`

All commands use: `bash ${CLAUDE_PLUGIN_ROOT}/skills/ia-git-worktree/scripts/worktree-manager.sh <command>`. If `CLAUDE_PLUGIN_ROOT` is unset (non-Claude-Code harness), resolve the script relative to this skill's own directory.

Before creating worktrees, export a unique `WORKTREE_SESSION_ID` and retain that same value for this session's later manager calls. Example: `export WORKTREE_SESSION_ID="$(python3 -I -c 'import uuid; print(uuid.uuid4())')"`. The manager records ownership in each new worktree's Git metadata. Creation without a session ID works, but manager cleanup then refuses that tree; never adopt a previous session's ID to bypass ownership.

The manager script fetches `<base>` from `origin` into an invocation-private ref, resolves that commit, and creates the branch from its SHA, even when `origin/<base>` is absent or stale or another checkout fetches concurrently. It removes only its private ref and never checks out `<base>` in the caller's working tree. If the fetch fails (offline, no remote), it resolves the local `<base>` instead. PR review: pass the fetched PR head as `<base>`, then verify its SHA ([workflow-examples.md](./references/workflow-examples.md)). Details: [troubleshooting.md](./references/troubleshooting.md).


## Commands

| Command | Description | Example |
|---------|-------------|---------|
| `create <branch> [from]` | Create worktree + branch (default: from main) | `...worktree-manager.sh create feature-login` |
| `list` / `ls` | List all worktrees with status | `...worktree-manager.sh list` |
| `switch <name>` / `go` | Print the registered worktree's abs

_meta.json

{
  "ownerId": "kn715jrbbh71q9zncr0bqdkr8n848q1a",
  "slug": "compound-eng-git-worktree",
  "version": "5.0.1",
  "publishedAt": 1791047050560
}

references/commit-ownership.md

# Commit ownership

Read before committing when caller changes, peer changes, or an existing index may overlap the task.

1. Resolve any missing manager setup (`.worktrees` ignore entry) before the caller-state snapshot. Record the caller's HEAD, exact staged and unstaged patches, untracked paths, and index state before editing. Establish which complete changes belong to the task. Stop writers before taking the snapshot or committing.
2. For wholly owned files, inspect their complete proposed working-tree patch against HEAD. A pathspec commit (`git commit -- <paths>`) records those entire files; use it only when every included hunk is task-owned. New files require staging first. Verify the exact committed patch with `git show --format=fuller --binary --no-ext-diff --no-textconv <commit>` and confirm unrelated staged intent remains intact.
3. For mixed hunks or unclear whole-file ownership, create a clean session-owned checkout from the captured caller HEAD through the manager. Construct an owned patch against that baseline: exclude caller/peer hunks and include required additions, deletions, modes, and binary changes. Do not copy the complete dirty file or apply the caller's whole diff.
4. Apply only that patch in the isolated checkout. Inspect its exact staged patch, confirm every hunk is owned and the index contains no unrelated paths, run the applicable checks there, and commit normally in that checkout. Verify the exact committed patch against the captured baseline.
5. Retain the resulting commit SHA and branch for authorized integration. Confirm the caller's HEAD, original staged and unstaged patches, untracked files, and index are unchanged. Do not push the caller's branch as though it contains the isolated commit. Report the actual committed checkout and branch.

An alternate-index commit that advances the caller's HEAD while retaining the old normal index leaves staged reversals of the task's changes. Use the isolated-checkout path when caller state must remain intact; integrate only after arranging its preservation under the user's authority. If the attributable patch cannot be separated safely, finish independent work and report the ownership conflict.

## Publish the actual commit

`git -C <repo> push <remote> HEAD:<branch>` resolves HEAD in that checkout, not the worktree that was edited. Pushing from the main checkout can therefore overwrite the feature branch with the main checkout's commit. `--force-with-lease` checks the remote branch's old value, not which commit HEAD names. Resolve the SHA in the edited checkout, push it explicitly, and confirm the remote ref with `git ls-remote`. Two branches updated to one SHA or an unrelated pushed subject indicate a possible checkout mix-up.

references/hooks-and-excludes.md

# Hooks and Local Excludes

## Hook Safety Under Husky

Installing hooks into `.git/hooks/` silently fails on any repo that uses Husky. Husky sets `core.hooksPath` (typically to `.husky/_`) and git ignores `.git/hooks/` entirely when that config is non-empty. The hook file lands on disk, is executable, is correct, and is dead. Invisible failure until someone asks why the post-merge behavior isn't running.

### Detection rule before writing any hook

```bash
hooks_path=$(git -C "$repo" config --get core.hooksPath)
```

- Empty output: write to `$(git rev-parse --git-common-dir)/hooks/<name>` as usual.
- `.husky/_` (or any path containing `husky.sh` / `h` trampoline): Husky v9 setup. Write to `.husky/<name>`; do NOT include the v8-era `. "$(dirname "$0")/_/husky.sh"` line (v9 prints a deprecation warning if you do).
- Unrecognized non-empty value: refuse to write the hook and surface the path to the user. Silent writes to the wrong location waste debug cycles later.

### Worktree-safe hook body

`.git/hooks/` lives in the common git dir and runs for every worktree of the clone. A hook installed once fires across all trees. Two rules to stay safe:

1. Resolve the invoking worktree's root inside the hook body with `git rev-parse --show-toplevel`, not a hardcoded path. Hardcoding means the last `install-hooks` invocation wins for every worktree.
2. Guard the tool invocation with an existence check on the tool's per-tree state dir. Siblings without your tool's setup must no-op, not spawn a failing background process per git op.

```sh
#!/bin/sh
root="$(git rev-parse --show-toplevel 2>/dev/null)" || exit 0
[ -d "$root/.my-tool" ] || exit 0
( cd "$root" && my-tool index ) >>"$root/.my-tool/hook.log" 2>&1 &
exit 0
```

Redirect to a log file inside the tool's state dir, not `/dev/null`; silent failures produce stale state you only notice hours later.

## Local Excludes: .git/info/exclude vs .gitignore

Tooling artifacts (local index dirs, hook helpers, per-developer scratch files) belong in `.git/info/exclude`, NOT in the tracked `.gitignore`.

- `.gitignore` is content: tracked, shared with the team, reviewed in PRs. Adding a personal tooling rule there pollutes a shared file. On foreign repos (upstream projects, third-party clones) the rule either rides into a PR by accident or sits as a dirty working tree forever.
- `.git/info/exclude` is local: untracked, lives in the common git dir, shared across every worktree of the clone. Same syntax and semantics as `.gitignore` without the leakage.

### Resolving the path correctly under worktrees

Don't hardcode `$repo/.git/info/exclude`. In a worktree, `.git` is a file (gitlink), not a directory. Use git itself:

```bash
exclude=$(git -C "$repo" rev-parse --git-path info/exclude)
```

### Idempotent append

```bash
line="/.my-tool/"
mkdir -p "$(dirname "$exclude")"
grep -qxF "$line" "$exclude" 2>/dev/null || printf '\n# my-tool\n%s\n' "$line" >> "$exclude"
```

`grep -qxF` matches the exact line with no regex 

references/troubleshooting.md

# Troubleshooting & Technical Details

## Troubleshooting

### "Worktree already exists"

The script offers to print its path. This does not transfer ownership or change the caller's working directory.

### "Cannot remove worktree: it is the current worktree"

Run cleanup with the main checkout as workdir. Obtain its path from `list`; `git rev-parse --show-toplevel` inside a linked checkout returns that linked checkout, not the main one.

```bash
env -C "$main_checkout" bash ${CLAUDE_PLUGIN_ROOT}/skills/ia-git-worktree/scripts/worktree-manager.sh cleanup feature-name
```

### Lost in a worktree?

See where you are:

```bash
bash ${CLAUDE_PLUGIN_ROOT}/skills/ia-git-worktree/scripts/worktree-manager.sh list
```

### .env files missing in worktree?

If a worktree was created without .env files (e.g., via raw `git worktree add`), copy them:

```bash
bash ${CLAUDE_PLUGIN_ROOT}/skills/ia-git-worktree/scripts/worktree-manager.sh copy-env feature-name
```

Use the main path shown by `list` for commands aimed at the main checkout:

```bash
env -C "$main_checkout" git status --short
```

### Cleanup refuses a tree

Supply explicit names and the `WORKTREE_SESSION_ID` set before creation. Do not reuse another session's token. Preserve any dirty, untracked, or ignored files, including copied environment files and dependencies; arrange their disposition under user authority before retrying. A locked tree remains protected by Git. A clean tree from this session can be removed after confirming no process uses it.

### Tree-scanning tests fail with phantom offenders?

A worktree under `.worktrees/` is a full second checkout inside the repository. `.gitignore` hides it from Git, not from a test that walks the tree with `rglob` or `find`, so a hygiene test reports offenders that repeat known-good files under the worktree prefix, and CI never reproduces the failure. Check `git worktree list` before debugging one. Remove only this session's clean trees through the manager, or run the suite from a checkout that contains no nested worktree; for parallel suites, create the worktrees outside the repository.

---

## Branch from a fresh remote base (manager-script behavior)

Do not run these steps manually; the script runs them. Read only when debugging the resolved fetched commit or the local-ref fallback.

When creating a worktree's branch from the default branch (`main`/`master`), the local base may be ahead of `origin/<base>` due to another session, worktree, or background task. Branching from local HEAD silently carries those unrelated commits into the new feature branch and the eventual PR. Checking out `<base>` in the caller's working tree to update it first is worse: it silently switches the user's active branch out from under them, which is why the script never does that.

The script's actual sequence (fetch-only, never checks out the caller's branch):

```bash
fetch_marker=$(mktemp "${TMPDIR:-/tmp}/whetstone-fetch.XXXXXXXXXX")
fetch_ref="refs/whetstone/fetch/${f

Sponsored

Ads related to ia-git-worktree and adjacent AI workflows.