Dotclaude worktree
Use when starting new feature work that should happen in an isolated git worktree on its own branch.
install
source · Clone the upstream repo
git clone https://github.com/JHostalek/dotclaude
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/JHostalek/dotclaude "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/worktree" ~/.claude/skills/jhostalek-dotclaude-worktree && rm -rf "$T"
manifest:
skills/worktree/SKILL.mdsource content
input = $ARGUMENTS
Branch Name
Derive from user input (ask if missing). Default format:
<type>/<kebab-description> using conventional commit types (feat when ambiguous). Check git branch first — if the repo uses a different convention (e.g., feature/JIRA-123-desc), match it.
Show the derived name before proceeding.
Worktree Location
where{repo_root}/.claude/worktrees/{branch_slug}
replacesbranch_slug
with/-
=repo_rootgit rev-parse --show-toplevel- Ensure
exists and is in.claude/worktrees/.gitignore
Base Branch
Branch from the latest remote default, not from
HEAD — HEAD can be stale or on an unrelated branch, silently seeding the worktree with the wrong history.
- Detect default:
(fallback: trygit symbolic-ref refs/remotes/origin/HEAD | sed 's|refs/remotes/origin/||'
, thenmain
)master - Fetch:
git fetch origin {default_branch} - Create:
git worktree add -b {branch} {directory} origin/{default_branch}
If the branch already exists:
git worktree add {directory} {branch} (no -b).
After creation, symlink gitignored files so the worktree runs without a reinstall:
bash ~/.claude/skills/worktree/scripts/symlink-gitignored.sh {repo_root} {directory}
Submodules
git worktree add on a parent repo does NOT initialize submodules — their directories will be empty. Each worktree gets its own independent submodule git dir at .git/worktrees/{name}/modules/{submodule}, so submodules can be on different branches without conflicting with the original checkout.
Inside the new worktree:
- Initialize:
git -C {directory} submodule update --init - If the submodule needs a specific branch (not just the commit pinned by the parent):
git -C {directory}/{submodule} checkout {branch} - Symlink gitignored files per submodule:
bash ~/.claude/skills/worktree/scripts/symlink-gitignored.sh {repo_root}/{submodule} {directory}/{submodule}
Scope determination — before creating anything:
- Single submodule only — worktree in that submodule alone
- Parent + submodule(s) — parent worktree + submodule init inside it
- Ambiguous — ask
Output
Show: worktree path,
claude --cwd {directory} command, reminder to use /worktree-clean when done, and git worktree list.