merge-worktree
Skill14 starsChanged 7 months agoMITView on GitHub
Squash-merge the current worktree branch into the main branch (or a specified target). Analyzes git history and source code to craft a comprehensive commit message.
- Commits and pushes
4 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- wonhp1/claude-skillsedited, first seen Oct 20, 2026
- techmefr/mentistheir own version, first seen Sep 11, 2026
- genusarvicolabathos238/trifluxtheir own version, first seen Apr 1, 2026
- codefactory-co/kimoring-ai-skillsword for word, first seen Mar 17, 2026
Other versions4 projects use a version of this.
Word for word · 1
- codefactory-co/kimoring-ai-skills★ 245100% same
Edited · 1
- wonhp1/claude-skills★ 095% same
Wrote their own version · 2
- genusarvicolabathos238/triflux★ 1same name
- techmefr/mentis★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository8 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- lessonSkill
- manage-skillsSkill
- releaseSkill
- remove-worktreeSkill
- update-docsSkill
- update-wikiSkill
- verify-implementationSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 6 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
Follow these phases exactly, in order.
- Very specific: line 27
Verify worktree: Check if the current git directory is a worktree.
- Very specific: line 33
If $ARGUMENTS is provided and non-empty, use it as the target branch.
- Distinctive: line 38
Clean working tree: Run git status --porcelain.
- Very specific: line 46
Commit history: Run git log --oneline <target>..HEAD to see all commits on this worktree branch.
- Very specific: line 48
File change summary: Run git diff <target>...HEAD --stat to get an overview of what files changed and how much.
- Very specific: line 50
Full diff: Run git diff <target>...HEAD to read the complete diff.
- Very specific: line 70
Check target branch state: Run git -C <original-repo-path> log --oneline -10 <target> to see recent commits on the target branch.
- Very specific: line 72
Detect stray WIP commits: If the target branch has commits that look like auto-generated WIP commits (e.g., messages starting with wip:, …
- Distinctive: line 90
Handle conflicts: If the merge reports conflicts:
- Distinctive: line 96
If the merge succeeds (no conflicts), proceed to Phase 5.
- Distinctive: line 119
If changes span multiple types, use the dominant one
- Very specific: line 123
Always end with Co-Authored-By
- Very specific: line 137
Confirm the commit: Run git -C <original-repo-path> log --oneline -3 and show the result to the user.
- Distinctive: line 152
If anything unexpected happens at any phase, stop and explain rather than guessing.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Merge Worktree
Squash-merge the current worktree branch back into the target branch with a comprehensive, structured commit message.
Current context
- Git dir:
!git rev-parse --git-dir - Current branch:
!git branch --show-current - Recent commits:
!git log --oneline -20 - Working tree status:
!git status --short
Instructions
Follow these phases exactly, in order. Do NOT skip phases.
Phase 1: Validation
- Verify worktree: Check if the current git directory is a worktree. The output of
git rev-parse --git-dirmust contain/worktrees/. If it does not, stop immediately and tell the user:"This skill must be run from inside a git worktree. Use
/worktreeto create one first." - Identify current branch: Get the worktree branch name from
git branch --show-current. - Resolve target branch:
- If
$ARGUMENTSis provided and non-empty, use it as the target branch. - Otherwise, detect the default branch: check if
mainexists, else checkmaster. If neither exists, stop and ask the user.
- If
- Identify the original repo path: Parse the original repo root from the git-dir path. The worktree's
.gitfile points back to the main repo — usegit rev-parse --git-common-dirto find it, then derive the original repo working directory (its parent). - Clean working tree: Run
git status --porcelain. If there are uncommitted changes, stop and tell the user to commit or stash them first.
Phase 2: Research
This is the most critical phase. You must deeply understand what was done before writing any commit message.
- Commit history: Run
git log --oneline <target>..HEADto see all commits on this worktree branch. - File change summary: Run
git diff <target>...HEAD --statto get an overview of what files changed and how much. - Full diff: Run
git diff <target>...HEADto read the complete diff. Study it carefully. - Read key files: For the most significantly changed files (largest diffs, new files, deleted files), use the Read tool to understand the full context — not just the diff lines.
- Categorize changes: Mentally group all changes into categories:
- Features (new functionality)
- Fixes (bug corrections)
- Refactors (code restructuring without behavior change)
- Tests (new or updated tests)
- Docs (documentation changes)
- Config/Chore (build, CI, tooling, dependencies)
- Identify the dominant type: Determine which conventional commit type (
feat,fix,refactor,docs,chore,test) best represents the overall body of work.
Phase 3: Target branch preparation
- Get the original repo path (from Phase 1 step 4).
- Check target branch state: Run
git -C <original-repo-path> log --oneline -10 <target>to see recent commits on the target branch. - Detect stray WIP commits: If the target branch has commits that look like auto-generated WIP commits (e.g., messages starting with
wip:,auto-commit,WIP), warn the user and ask if they want to reset to the last clean commit before merging. - Fetch latest (if remote exists): Run
git -C <original-repo-path> fetch origin <target> 2>/dev/nullto ensure target is up to date with remote. Do not fail if no remote.
Phase 4: Squash merge
- Ensure target branch is checked out in the original repo:
git -C <original-repo-path> checkout <target> - Perform the squash merge:
git -C <original-repo-path> merge --squash <worktree-branch> - Handle conflicts: If the merge reports conflicts:
- List all conflicted files
- Show the conflict markers
- Stop and report to the user — do NOT attempt to auto-resolve
- Tell them to resolve conflicts in the original repo and then run the skill again
- If the merge succeeds (no conflicts), proceed to Phase 5.
Phase 5: Craft commit message and commit
Based on your Phase 2 research, write the commit message following this exact structure:
<type>: <concise summary in imperative mood, under 72 chars, no period>
<2-4 sentence paragraph explaining what was done and WHY. Focus on the
motivation and high-level approach, not implementation details.>
Changes:
- <grouped bullet points of what changed>
- <use sub-bullets for details within a group>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>Rules:
<type>must be one of:feat,fix,refactor,docs,chore,test- If changes span multiple types, use the dominant one
- Summary line: imperative mood ("add", "fix", "refactor"), no period, max 72 chars
- Body paragraph: explain the why and context, not just what
- Changes: group related items together, most important first
- Always end with
Co-Authored-By
Create the commit in the original repo using a heredoc:
git -C <original-repo-path> commit -m "$(cat <<'EOF'
<your commit message here>
EOF
)"Phase 6: Verification
- Confirm the commit: Run
git -C <original-repo-path> log --oneline -3and show the result to the user. - Report summary: Tell the user:
- The final commit hash
- The commit summary line
- Which branch it was merged into
- Remind them the worktree branch still exists — they can delete it with
git worktree remove <path>if no longer needed - Remind them to
git pushif they want to push to the remote
Important notes
- Never force-push or use destructive git operations without explicit user confirmation.
- Never skip pre-commit hooks (
--no-verify). - If anything unexpected happens at any phase, stop and explain rather than guessing.
- The commit message quality is paramount — take time in Phase 2 to truly understand the changes.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

