integrate-worktree

Merges finished git worktree branches into main, closes worktrees, and runs post-merge quality checks.

1.1k|165|Updated Aug 18, 2014
One-click install
npx skills add https://github.com/crowi/crowi --skill integrate-worktree
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: integrate-worktree
Source: https://github.com/crowi/crowi/tree/main/.claude/skills/integrate-worktree
Command: npx skills add https://github.com/crowi/crowi --skill integrate-worktree

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

When multiple agents or developers work in parallel git worktrees, folding a finished branch back into main involves many error-prone manual steps: conflict resolution, dependency installs, type/test/lint gates, worktree cleanup, and stale spec file removal. This Skill automates that entire integration workflow so nothing is forgotten.

Core Features & Use Cases

  • End-to-end merge pipeline: Verifies a clean worktree, acquires a main write lock, merges with --no-ff, resolves conflicts, and runs build, type-check, test, lint, and selective e2e gates before committing.
  • Safe worktree teardown: Stops dev/watch processes (next dev, tsx watch, turbo) to avoid ENOTEMPTY failures, closes the worktree via the gw wrapper, deletes the merged branch, and optionally closes the matching tmux window.
  • Post-merge hygiene: Runs a simplify pass with mandatory adversarial review before committing refactors, cleans up stale spec/task files, advances serial kickoff chains, and triggers docs refresh at drain points.
  • Use Case: After a parallel agent finishes a feature in worktree 'page-bookmark', run the skill with that identifier to merge it into main, verify all checks pass, close the worktree, and hand off to the next chained feature.

Quick Start

Integrate the finished worktree named page-bookmark into main and clean everything up.

Frequently Asked Questions about integrate-worktree

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I merge a git worktree branch into main safely?

Verify the worktree is clean, acquire a write lock on main, merge with --no-ff --no-commit, resolve conflicts, then run type-check, tests, and lint before creating the merge commit. This Skill automates that full sequence including worktree removal afterward.

Why does git worktree remove fail with Directory not empty?

Running dev servers like next dev --turbopack or tsx watch keep writing to the worktree directory while git tries to delete it, causing ENOTEMPTY errors. Stop all bundler and watcher processes whose working directory is inside the worktree before removal.

What checks should run before creating a merge commit?

Run pnpm install if package.json or pnpm-lock.yaml changed, then type-check, unit tests, and lint for affected packages, plus selective e2e tests when e2e specs changed. Verify MERGE_HEAD still exists right before committing so the commit has two parents.

Can this Skill push the merged main branch to origin?

No. The workflow is strictly local: it merges, closes the worktree, and cleans up, but pushing to origin always waits for explicit user instruction. It also handles only one worktree per invocation.

What happens if type-check fails after resolving merge conflicts?

The merge is aborted with git merge --abort and the cause is analyzed. Often the worktree branch is missing dependencies or violates newer lint rules, in which case the fix belongs in the worktree before re-merging.