Skip to Content
MeowKit
Skills

mk:worktree

Internal skill that creates, merges, lists, cleans and prunes git worktrees so parallel agents work in isolation.

Source.claude/skills/worktree/SKILL.md
Ownergit
Runtimeclaude-code
Riskmedium

What it does

mk:worktree manages git worktrees through scripts/worktree.cjs. Each parallel agent gets its own worktree so file edits do not collide. The orchestrator (mk:cook, mk:workflow-orchestrator) calls it when a complex task splits. It is not user-invocable. references/commands.md has the full option and JSON reference.

When not to use it

To plan a whole parallel team with ownership map and task queue, use mk:team-config, which calls this skill.

Actions

Run the commands as node ${CLAUDE_SKILL_DIR}/scripts/worktree.cjs <action> ... --json.

ActionWhat it does
infoReports repository state. Run it before create.
create "{agent-name}" --orchestratedCreates .worktrees/{agent-name} on branch parallel/{agent-name}-{timestamp}.
mergegit merge --no-ff {branch} into the feature branch. On conflict it stops and reports to the orchestrator, with no auto-resolve. After a clean merge, run the full test suite, then delegate a status report to project-manager in the background unless MEOWKIT_PM_AUTO=off.
remove "{agent-name}" (cleanup)Removes the worktree. Release the agent's mk:task-queue ownership first, and commit or stash uncommitted changes.
listLists worktrees.
statusShows ahead and behind divergence and dirty state, and the count of active worktrees.
prune --dry-run, then pruneCleans stale worktree metadata. Dry run first.
review-pr --pr N --remote <name> --session <id>Creates a detached worktree pinned to a PR head for assured review. Add --dry-run to validate only.
review-pr-cleanup --manifest <path>Removes a review worktree. --sweep --dry-run finds stale sessions, and --apply executes.

Before the first parallel worktree, make sure .worktrees/ is in .gitignore.

review-pr fetches pull/N/head from the PR's base remote, never a fork. It writes tasks/reviews/<session>/manifest.json and a .mewkit-review.json back-reference inside the worktree. Cleanup runs only when the manifest's nonce matches that back-reference and the target is a detached .worktrees/review-pr-* worktree, so it can never remove the main checkout or a feature worktree. Force is allowed, since review worktrees are dirty after builds.

Safety rules

  • Create worktrees only on feature branches, never on main or master.
  • Keep at most 3 active worktrees.
  • Remove worktrees after the merge. Stale ones keep their branches checked out.
  • Never force-push from a worktree. It shares .git with the main checkout.

Gotchas

  • Creation fails with BRANCH_CHECKED_OUT if the branch exists. Timestamps in orchestrated branch names prevent collisions.
  • git worktree remove fails silently when the directory was already deleted by hand. The script checks existence first.
  • Merge conflicts on SKILL.md and CLAUDE.md are common in parallel runs. Stop and report them.
  • On macOS, quote paths that contain : from skill names.

On this page