/dev10x-coding:git-worktreefrom dev10x-coding
Creates git worktrees for clean workspace isolation during feature development. Supports native session switching, external IDE-isolated worktrees, and automatic Herdr mode.
Ships in dev10x-coding. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
This skill follows references/task-orchestration.md patterns.
Create a task at invocation, mark completed when done:
REQUIRED: Create a task at invocation. Execute at startup:
TaskCreate(subject="Create git worktree", activeForm="Creating worktree")Mark completed when done: TaskUpdate(taskId, status="completed")
Announce: "Using dev10x-coding:git-worktree skill to create an isolated workspace."
The branch name is needed by both paths. Follow project naming conventions:
git branch -a for the pattern used (e.g. janusz)username/TICKET-ID/slugusername/TICKET-ID/worktree-name/slug
(worktree name = basename of the worktree directory, e.g. app-pos-7)Herdr first (GH-1617). Run printenv HERDR_ENV. When it prints
1, the session runs inside Herdr: take Path C without asking —
read references/herdr-path.md and follow
it end-to-end. Path C always starts and briefs an agent, never sends
keys to clear input it did not write, and hands the brief over through
a file rather than as prompt text. Skipping the mode gate is
deliberate: inside Herdr the workspace is the isolation (GH-1617).
Otherwise, present the two options with AskUserQuestion:
EnterWorktree tool switches CWD
immediately; all subsequent git commands and skills (commit, dev10x-coding:gh-pr-create,
branch:groom) work without flags; worktree lives inside .claude/worktrees/
(excluded from hook copies and .gitignore)../.worktrees/<project>-NN
outside the project; IDE won't cross-index sibling worktrees; requires closing
this session and opening a new one in the worktree directoryContinue to Path A or Path B based on the choice.
Read .git/hooks/post-checkout (or .husky/post-checkout) if it exists.
If it handles worktree setup adequately (uv sync, yarn install, env copy),
skip to Step A2.
If missing or incomplete, detect project type and propose the appropriate
template from the Hook Templates section below. Present to the user for
approval before writing. The hook must always ensure .claude exists —
either by copying from the source repo or creating an empty scaffold.
Session config seeding (GH-705, ADR-0018). Durable preferences
live in the global ~/.config/Dev10x/friction.yaml, outside every
repo and therefore already shared by every worktree — nothing needs
copying into a new checkout. Templates instead exclude Dev10x/
from the .claude/ copy, so no stale per-repo state (a legacy
config.yaml, an auto-advance doubt-sink) rides across, and then run
the seed to ensure the global friction.yaml and the self-ignoring
.claude/Dev10x/.gitignore exist:
# >>> Dev10x session-seed (ADR-0018) >>>
if command -v dev10x >/dev/null 2>&1; then
dev10x session seed || true
elif command -v uvx >/dev/null 2>&1; then
uvx dev10x session seed || true
fi
# <<< Dev10x session-seed (ADR-0018) <<<
The seed is idempotent — it leaves present files untouched — so it
needs no existence guard, and a missing dev10x CLI is non-fatal.
This block previously guarded on a per-repo
.claude/Dev10x/session.yaml; ADR-0018 retired that file, so nothing
creates it and the guard matched on every checkout (GH-1001). The
shipped templates/post-checkout-python-uv.sh is the reference
implementation.
When the project already has an adequate post-checkout hook, do NOT
overwrite it — augment it idempotently: read the hook, and only if
the Dev10x session-seed marker is absent, inject the block
above just before the hook's final cleanup/exit (inside the all-zeros
SHA guard if one exists). A hook that already contains the marker is
left untouched, so re-running this skill never duplicates the block.
When the project uses Husky, detect the version before creating the worktree:
package.json contains "husky": { "hooks": ... }.husky/_/husky.sh existsFor Husky v4 projects, worktrees lack node_modules until
yarn install completes, causing git hooks to fail. Check
~/.huskyrc and create it if missing:
# ~/.huskyrc — bootstrap for Husky v4 in worktrees
if [ ! -d "node_modules" ]; then
echo "huskyrc: node_modules missing, skipping husky hook"
exit 0
fi
For Husky v5+ projects, no ~/.huskyrc is needed.
After writing any hook file, always set executable permissions:
chmod +x .husky/post-checkout # or .git/hooks/post-checkout
Call the native EnterWorktree tool:
name: use the branch slug (e.g. fix-railway-deployment)After EnterWorktree runs the session CWD is the new worktree. All
subsequent Bash calls, git commands, and skills operate inside it.
The session is now in the worktree. Resume the calling skill's next step (ticket status, job story, summary). No restart needed.
CWD & push discipline (GH-474 #6): Although the session CWD is the
worktree, prefer absolute paths in Bash calls — a cd X in one call
does not persist to the next, so cd subdir; <relative-path> patterns
break when the CWD resets between calls. For pushing, raw git push is
hook-blocked on this worktree; use Skill(dev10x-coding:git) (which wraps
push_safe) instead of git push directly.
Default pattern: ../.worktrees/<project-basename>-NN
Calculate the next available path.
Primary (MCP tool): Call mcp__plugin_dev10x_cli__next_worktree_name
with cwd=<absolute repo path>.
It returns {"path": "<calculated-path>"} and never prompts for
approval.
Pass base_dir to override the ../.worktrees parent.
Fallback (script): Only when the MCP server is unavailable:
${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/next-worktree-name.sh
Ask user to confirm (AskUserQuestion):
<calculated-path> (Recommended)Same as Step A1 — read, verify, and propose a template if needed. See Hook Templates section below.
Primary (MCP tool): Call mcp__plugin_dev10x_cli__create_worktree
with branch=<branch-name>, path=<worktree-path> and
cwd=<absolute path of the target repo>.
Pass base (e.g. origin/develop) to start the new branch from a
specific ref; omit it to branch from the repo's current HEAD.
The result carries worktree_path, and the tool also seeds the new
worktree's safe permission defaults (seeded_permissions).
Fallback (script): Only when the MCP server is unavailable:
${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/create-worktree.sh \
<worktree-path> <branch-name> [base-ref] [repo-root]
base-ref to branch from the repo-root's current HEAD; pass it
(e.g. origin/develop) to start the new branch from a specific ref.repo-root when already inside the target repo.repo-root when the CWD differs from the target repo."") to
skip base-ref while still supplying repo-root (GH-960).The post-checkout hook fires automatically after the worktree is
created, on either path.
${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/setup-session-end-hook.sh <worktree-path>
This writes a SessionEnd hook into <worktree-path>/.claude/settings.local.json
that prompts the user to remove the worktree when the new session ends.
Claude Code sessions have a fixed CWD. cd inside a Bash call does not
persist, so every subsequent git command would need git -C <path> and
skills like dev10x-coding:gh-pr-create (whose verify-state.sh runs plain git) would fail.
Print this message and stop — do not continue with ticket workflow steps:
✅ Worktree ready
Path: <worktree-path>
Branch: <branch-name>
Close this session and open a new one in the worktree:
cd <worktree-path> && claude
Copy the command above, close this session, then paste it in your terminal.
The new session will have the correct CWD and all skills will work normally.
Chosen automatically in Step 2, never offered as a choice. Create the
worktree with herdr worktree create --no-focus, confirm the
post-checkout setup ran, start a Claude agent named after the ticket,
and send it a short prompt that points at a brief file. Full steps,
the read-before-prompt rule, and why the brief goes through a file:
references/herdr-path.md.
Templates for projects that lack a post-checkout hook.
git worktree add passes 0000000000000000000000000000000000000000 as $1
(previous HEAD) when creating a new worktree. Guard on this value — do NOT
use [ -f .git ] which fires on every branch checkout inside any worktree:
if [ "$1" = "0000000000000000000000000000000000000000" ]; then
# new worktree — run setup
fi
| Check | Template |
|---|---|
uv.lock or pyproject.toml exists | Template A (Python/uv) |
package.json + .husky/ directory | Template B (Node + Husky) |
package.json without Husky | Template C (Node, no Husky) |
A project can match multiple templates (e.g. Django + SvelteKit). Apply all.
| Condition | Write to |
|---|---|
Husky present (prepare script or .husky/ dir) | .husky/post-checkout (tracked) |
| No Husky | .git/hooks/post-checkout (untracked, local only) |
Husky overwrites .git/hooks/ on every yarn/npm install. Writing to
.git/hooks/post-checkout in a Husky project means changes are silently lost.
Source: templates/post-checkout-python-uv.sh
Copies .env, development.secrets.env, .claude/ (excluding WIP), .idea/,
and runs uv sync.
After creating a Python/uv worktree, run dev10x-coding:ide-normalize to fix
stale PyCharm .idea/ module-name references, disable
ADD_CONTENT_ROOTS / ADD_SOURCE_ROOTS flags (which conflict with editable
installs — see PEP 660 / PYTHONPATH conflict),
and detect the PyCharm uv-SDK FLAVOR_DATA gap that causes ModuleNotFoundError
on first launch.
.husky/post-checkout)Source: templates/post-checkout-node-husky.sh
Copies .env, .claude/ (excluding WIP), and runs yarn install --frozen-lockfile.
For monorepos (yarn workspaces), run yarn install --frozen-lockfile from
the repo root — this installs all workspace packages in one pass.
.git/hooks/post-checkout)Source: templates/post-checkout-node.sh
Copies .env, .claude/ (excluding WIP), and runs yarn install or npm ci.
Make executable: chmod +x .git/hooks/post-checkout
Never symlink node_modules — a symlink means yarn add/remove in any
worktree mutates the shared directory. Always run yarn install --frozen-lockfile
(fast via Yarn's hardlink cache).
The SessionEnd hook installed by Path B prompts:
This session used worktree at
<path>. Remove it? [y/N]
If yes: git worktree remove <path>
If no: the worktree persists for future sessions.
That prompt covers one worktree per session and never fires for
herdr-created (Path C) or crew/fanout worktrees. To sweep every
worktree whose work has merged, run dev10x-coding:git-worktree-prune: it
classifies them all in one call, asks once, and keeps anything dirty,
unpushed or open.
Manual removal of a single clean worktree:
git worktree remove <path>
git worktree list # list all worktrees
If EnterWorktree fails (e.g., due to a hook error), it may leave
a partial worktree and orphan branch. Clean up manually:
git worktree remove <worktree-path> --force
git branch -D <worktree-branch>
Common failure causes:
node_modules (see Step A1b)--immutable not --frozen-lockfilechmod +x after writing)Symptom: uv run /full/path/.venv/bin/python manage.py … crashes with
ModuleNotFoundError: No module named 'collections.abc'.
Causes (may be compounding):
PyCharm uv-SDK FLAVOR_DATA gap — PyCharm auto-creates an SDK entry
with empty FLAVOR_DATA="{}", missing UV_VENV_PATH / UV_TOOL_PATH.
Result: PyCharm constructs the wrong launch command. Fix: run
dev10x-coding:ide-normalize (Step 5) or follow the manual recipe in
../ide-normalize/references/pycharm-uv-sdk-gap.md.
ADD_CONTENT_ROOTS / ADD_SOURCE_ROOTS injecting PYTHONPATH — These
run-config defaults activate sitecustomize bootstrappers (New Relic,
DataDog APM, etc.) that crash under uv-managed Python. Fix: run
dev10x-coding:ide-normalize (Step 3) to set both flags to false.
Background: ../ide-normalize/references/pep660-pythonpath-conflict.md.
Quick fix: dev10x-coding:ide-normalize addresses both causes.
evals/evals.json (opens in a new tab)references/herdr-path.md (opens in a new tab)scripts/create-worktree.sh (opens in a new tab)scripts/next-worktree-name.sh (opens in a new tab)scripts/session-end-cleanup.sh (opens in a new tab)scripts/setup-session-end-hook.sh (opens in a new tab)templates/post-checkout-node-husky.sh (opens in a new tab)templates/post-checkout-node.sh (opens in a new tab)templates/post-checkout-python-uv.sh (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub dev10x-guru/dev10x-claude --plugin dev10x-coding40 skills in this plugin
/ci-reviewdev10x-coding:ci-reviewUse when a change to a Claude CI review prompt, args file, reviewer agent or CLI pin needs checking before it merges — so you read what the CI code review and PR hygiene check would post on a real PR, with nothing reaching GitHub unless you choose, after reading the report, to share it as one marked replica comment. TRIGGER when: "what would the CI review say", replaying the Claude CI review locally, verifying a review prompt or model change on a PR. DO NOT TRIGGER when: self-reviewing a branch with no PR (use dev10x-coding:review), or reviewing someone's PR and posting (use dev10x-coding:gh-pr-review).
/fanoutdev10x-coding:fanoutProcess multiple independent work items as a worktree-isolated swarm — each item runs the full dev10x-coding:work-on lifecycle inside its own background Agent with isolation="worktree" (under Herdr, its own Herdr workspace and agent). Honors dependencies, minimizes conflicts, auto-advances by default. TRIGGER when: 2+ independent work items need parallel processing (PRs, issues, tickets). DO NOT TRIGGER when: single task or sequential dependency chain (use dev10x-coding:work-on); already running as a swarm child (see recursive-fanout guard).