/empire-git:worktree-help [question]from empire-git
Answers questions about the empire git worktree toolkit: VSCode integration, port offsets, env files, dependency installs, and workflow tips. Useful for managing parallel branches.
Ships in empire-git. 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.
None: SKILL.md is the whole skill.
$ARGUMENTS is the user's question. If empty, MUST print the Overview section below byte-for-byte verbatim — do not paraphrase, summarize, or reorder. Otherwise, answer their question using the FAQ section as your primary reference, falling back to your knowledge of git worktrees and this plugin's setup.
Keep answers concise and practical. When relevant, include code .claude/worktrees/<branch-dir> — it's the single most useful tip for new users.
$ARGUMENTS is empty)The empire worktree skills are a toolkit for running multiple branches of the same repo in parallel, each in its own isolated git worktree, with Claude Code skills that handle the lifecycle for you.
Why it exists. Switching branches mid-task is disruptive: you stash, rebuild, lose dev server state, and risk polluting one branch's .env with another's. Worktrees give each branch its own directory, dependencies, ports, and env — so you (or a Claude agent) can spin up a parallel task without touching what you're already working on. This plugin automates the boring parts: derived ports, copied env files, dependency installs, cleanup, and merge/close flows.
Zero per-repo setup. The plugin ships with worktree-setup.sh; skills invoke it via ${CLAUDE_PLUGIN_ROOT}/scripts/ on Claude Code and a bundled scripts/ copy on other agents (e.g. Codex). Lockfiles are auto-detected (pnpm, npm, yarn, bun, uv, poetry, pipenv, bundler, cargo, go modules). The .claude/worktrees ignore entry is written to .git/info/exclude, never the repo's tracked .gitignore.
| Command | Purpose |
|---|---|
/empire-git:worktree-open [branch or description] [--base <branch>] | Create or reopen a worktree (env, deps, ports handled) |
/empire-git:worktree-list [--stale] | List active worktrees with branch, sync state, staleness |
/empire-git:worktree-merge <branch> --into <target> [--no-close] | Local git merge of one branch into another |
/empire-git:worktree-close [branch] [--push] [--force] | Push, remove the worktree, optionally delete the branch |
/empire-git:worktree-cleanup [--dry-run] | Batch cleanup of stale worktrees and orphaned branches |
/empire-git:worktree-help [question] | This help — ask any worktree question in natural language |
Ask /empire-git:worktree-help <your question> for anything specific (VSCode setup, ports, env files, merge strategy, etc.).
Inspired by @thinkvelta/claude-worktree-tools (MIT).
Q: How do I see a worktree in VSCode?
Open it as its own window: code .claude/worktrees/<branch-dir>. The main repo's Source Control panel won't show worktree changes — that's by design (worktrees are excluded). Alternative: File → Add Folder to Workspace for a multi-root setup.
Q: Why is .claude/worktrees/ in .git/info/exclude?
Required. Worktrees are git's own checkout mechanism, not nested repos. Without an exclude entry, git would try to track the worktree's files as content of the parent repo. The plugin writes to .git/info/exclude (per-clone, not committed) so the host repo's tracked .gitignore stays untouched.
Q: What's the typical workflow?
/empire-git:worktree-open <task> → code .claude/worktrees/<branch-dir> → work & commit → /empire-git:worktree-close --push (or /empire-git:worktree-merge to fold into another branch first). Use /empire-git:worktree-list to see everything in flight.
Q: How do port offsets work?
Each worktree gets a deterministic 0–99 offset derived from its path. Same branch → same offset (bookmarkable). Different worktrees → near-zero collision odds. The script prints the offset on completion. If your app needs to read it, set PORT_OFFSET in the worktree's .env (manually or via your own post-setup hook) — the plugin no longer mutates .env automatically.
Q: What happens to .env files?
All .env* files are copied from the main repo into the worktree, preserving directory structure (monorepo-friendly). On --reopen, they're re-copied so worktrees pick up changes from the main repo. Symlinked .env files are skipped.
Q: How does dependency install work?
The script auto-detects the package manager from lockfiles in the worktree root: pnpm-lock.yaml → pnpm install --frozen-lockfile, yarn.lock → yarn install --frozen-lockfile, bun.lockb/bun.lock → bun install --frozen-lockfile, package-lock.json → npm ci, uv.lock → uv sync, poetry.lock → poetry install, Pipfile.lock → pipenv install --deploy, Gemfile.lock → bundle install, Cargo.lock → cargo fetch, go.sum → go mod download. No lockfile = skip.
Q: When should I use /empire-git:worktree-merge instead of opening a PR?
Two cases: batching small fixes (merge several tiny worktrees into one branch, open one PR), and branch decomposition (split a big feature into sub-worktrees, fold them back into the parent, then open one PR from the parent). For everything else, just /empire-git:worktree-close --push and PR normally.
Q: Can I run multiple worktrees at once?
Yes — that's the whole point. Each has isolated deps, ports, and env. Run /empire-git:worktree-list to see them all. A common pattern: one worktree for your main task, others for parallel Claude agents working on smaller things.
Q: How do I update dependencies in a worktree?
Run your normal install command inside the worktree directory (pnpm install, bun install, etc.). The worktree has its own node_modules — installs don't affect the main repo or other worktrees.
Q: What if I forget about a worktree?
/empire-git:worktree-list --stale shows worktrees with no recent activity. /empire-git:worktree-cleanup batch-removes stale ones (use --dry-run first to preview).
Q: Is the main repo affected when I work in a worktree?
No. The main repo's working directory, branch, and dev server are untouched. Only the shared .git directory is updated when you commit (which is the same as any branch switch).
Q: How do I delete a branch and its worktree completely?
/empire-git:worktree-close <branch> --force removes the worktree and deletes the local branch. Add --push first if you want to push before tearing down.
What SKILL.md sets; muted values are Claude Code's defaults
haikuThree short reads, in order
git-worktree, vscode-integration, parallel-branches, git-workflow, faq
Other plugins' skills for the same job
npx claudepluginhub marcoskichel/empire --plugin empire-git12 skills in this plugin
/activity-reportGenerate a concise activity report of the user's GitHub work over a period, grouped by area or feature instead of PR by PR. Use when user says "activity report", "weekly report", "what did I do this week", "what did I ship", "work summary", "summarize my week", "status update for my manager", "what did <user> ship", or `/empire-git:activity-report [start-date] [end-date] [author]`.
/pr-comment-replyRender the canonical reply text for a PR review comment. Use when drafting, writing, or posting a "PR comment reply", "review comment reply", "reply to this comment", "respond to this review comment", "answer the reviewer", "reply on the PR thread", or any text bound for `gh api` review-thread replies, `gh pr comment`, or a GitHub review comment box. Triggers on "reply to the comment", "answer this review comment", "respond to the reviewer", "draft a reply", "post a reply on the PR". Outputs plain text for the caller to post unchanged.
/pr-descriptionRender the canonical PR description body. Use when drafting, writing, updating, or regenerating a "PR description", "PR body", "pull request description", "pull request body", "PR summary", "PR template", "GitHub PR body", or any text bound for `gh pr create --body`, `gh pr create --body-file`, `gh pr edit --body`, `gh pr edit --body-file`, or a GitHub PR template. Triggers on "draft a PR", "write the PR", "summarize this branch for review", "regenerate PR body". MUST be invoked before any `gh pr create --body*` or `gh pr edit --body*` per empire-git rules. Outputs markdown for stdin.
/pr-mergeGate then merge a single pull request safely. Use when the user says "merge this PR", "merge the PR", "land this", "ship this PR", "merge when green". Verifies CI is green (investigates and attempts a fix when red), rebases and resolves conflicts when the branch is behind, triages unresolved review threads intelligently (resolve, fix, or ask — never blindly block), then merges and deletes the branch. Fast-forwards the local base checkout (e.g. updates `master`) when it is checked out.
/pr-merge-stackMerge an entire stack of dependent PRs bottom-up: merge the base PR, pull the base branch, rebase the next PR onto it, wait for CI, merge, repeat until the stack is empty. Use when the user says "merge the stack", "merge pr stack", "land the stack", "merge all these PRs", "merge the chain", "ship the whole stack", or names several stacked PRs to merge in order. Infers the stack from conversation; asks when it can't. Offers admin merge (skip review requirements) up front — CI must still pass either way.
/pr-review-postPost a GitHub PR review (verdict + inline comments) in one API call. Use when posting, submitting, or publishing a "PR review", "code review", "review with inline comments", "approve the PR", "request changes", or any payload bound for `gh api repos/*/pulls/*/reviews`. Triggers on "post the review", "submit the review", "publish the review comments", "approve this PR", "request changes on the PR", "leave a review". MUST be used for any review POST so comments and verdict land atomically. Never posts without the caller's confirmed verdict.