agentleFS
89jobrien89jobrien/godmode/skills/merge/SKILL.md

godmode:merge

Skill1 starsChanged 57 days agoMITView on GitHub

Use when the user wants to merge a branch, integrate changes, resolve conflicts, create a PR, squash-merge a feature branch, or clean up a worktree after work is done. Handles single-branch merges, PR creation and merge via gh, squash workflows, worktree cleanup, push rejection recovery, and godmode task state sync. Trigger on "merge", "merge this", "open a PR", "squash and merge", "clean up worktree", "/merge", or any variant of integrating a branch into main.

  • Commits and pushes

The file

Show its rules and text

We split this skill into the rules it gives an agent

22 rules. About 0 are common, 15 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈15

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Before doing anything, gather state:

    line 22
  2. Distinctive:

    If only remote has new commits: continue to Direct-merge mode.

    line 65
  3. Distinctive:

    If both sides diverged: resolve conflicts, then push.

    line 66
  4. Distinctive:

    Never force-push to main.

    line 67
  5. Distinctive:

    If main has advanced since the branch was cut, review those commits first.

    line 83
  6. Distinctive:

    Read both sides — understand the intent, do not pick mechanically.

    line 107
  7. Distinctive:

    If merge becomes too complex, show git diff HEAD before considering abort.

    line 113
  8. Very specific:

    If no upstream: git push -u origin $(git branch --show-current) Never use --no-verify.

    line 130
  9. Very specific:

    If mergeStateStatus is not CLEAN, report the blockage and stop.

    line 200
  10. Very specific:

    Default: --merge (preserves merge commit, matches --no-ff)

    line 204
  11. Distinctive:

    After a successful merge, check if the source branch was a worktree:

    line 219
  12. Distinctive:

    If the merged branch appears as a worktree path, remove it:

    line 225
  13. Distinctive:

    Only do this after confirming the branch is fully merged:

    line 232
  14. Very specific:

    If a godmode task is associated with this branch, mark it done:

    line 242
  15. Very specific:

    If no task ID is known, check .ctx/godmode/tasks.yaml for tasks in running state that match the branch name or scope.

    line 248
  16. Very specific:

    If main..<branch> is non-empty, the merge did not complete.

    line 262
  17. Distinctive:

    If a PR was created instead of merged, print the PR URL.

    line 274
  18. Distinctive:

    If escalating to the user, state exactly what is blocked and what decision is needed.

    line 275
  19. Very specific:

    Never --no-verify. Let hooks run.

    line 282
  20. Distinctive:

    Never force-push main. Feature branches only, explicit user instruction required.

    line 283
  21. Distinctive:

    Never abort a merge without showing git diff HEAD first.

    line 284
  22. Distinctive:

    Never rebase branches with merge commits.

    line 285

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

godmode:merge — Branch Integration Agent

General-purpose merge agent. Covers single-branch merges, PR-based workflows, squash mode, worktree cleanup, and godmode task state sync. For merging multiple parallel agent branches produced by a wave, use godmode:wave-integration instead.

Step 0 — Assess the situation

Before doing anything, gather state:

git branch --show-current
git status --short
git log --oneline -5
git worktree list

Then determine the mode (see decision table below). If the user gave explicit instructions, follow them. If ambiguous, pick the most conservative option and state your choice.

Mode decision table

SituationMode
User said "open a PR" or "create PR"PR-create
PR already open on this branchPR-merge
User said "squash" or "squash and merge"Squash
Multiple branches to integrate (wave)→ defer to godmode:wave-integration
Single feature branch, no PRDirect-merge
Push was rejectedRejection-recovery → then re-run appropriate mode

Mode: Rejection-recovery

git push 2>&1
Output containsCauseAction
non-fast-forward / fetch firstRemote has commits you don't haveFetch, integrate, retry
rejected ... (stale info)Force-push neededAsk user — feature branches only
Permission deniedAuth failureCheck SSH key / 1Password agent
git fetch origin
git log --oneline HEAD..origin/<branch>   # commits on remote you don't have
git log --oneline origin/<branch>..HEAD   # your commits not yet on remote

If only remote has new commits: continue to Direct-merge mode. If both sides diverged: resolve conflicts, then push. Never force-push to main.


Mode: Direct-merge

Integrate the current feature branch into main.

1. Fetch and check divergence

git fetch origin
git log --oneline main..HEAD              # commits to merge
git log --oneline HEAD..origin/main       # new commits on main since branch

If main has advanced since the branch was cut, review those commits first.

2. Choose merge strategy

git log --oneline --merges main..HEAD     # check for merge commits on branch
  • Branch has merge commits → use git merge --no-ff (never rebase)
  • Branch is clean linear history → git merge --no-ff is still the default
  • User explicitly requested rebase → git rebase main (only if no merge commits)

3. Merge

git checkout main
git pull
git merge --no-ff <branch> -m "feat(<scope>): merge <branch>"

4. Resolve conflicts (if any)

For each conflicted file:

  1. Read both sides — understand the intent, do not pick mechanically.
  2. Produce a merged result that preserves both intents.
  3. git add <file>

Complete: git merge --continue

If merge becomes too complex, show git diff HEAD before considering abort. Never abort without showing the user what would be lost.

5. Test

taskit test run

Fix failures (up to 3 attempts) before pushing. Escalate if not resolved.

6. Push

git push

If no upstream: git push -u origin $(git branch --show-current) Never use --no-verify.


Mode: Squash

Collapse all branch commits into one before merging, producing a clean linear history on main.

git checkout main
git pull
git merge --squash <branch>

This stages all changes but does not commit. Write a single conventional commit summarizing the entire branch:

git commit -m "feat(<scope>): <summary of entire branch>

Squashed from <branch>:
- <key change 1>
- <key change 2>"

Then push as normal.

When to use squash: Feature branches with noisy WIP commits, branches from orca-strait/parallel agents where individual commits are scaffolding artifacts, or when the user explicitly requests it.

When not to use squash: Branches where individual commits carry meaningful history (e.g., a multi-phase refactor where each commit represents a reviewable step).


Mode: PR-create

Open a pull request for the current branch.

git push -u origin $(git branch --show-current)

gh pr create \
  --title "<conventional commit title>" \
  --body-file - <<'EOF'
## Summary
- <bullet 1>
- <bullet 2>

## Test plan
- [ ] taskit test run passes
- [ ] clippy clean
EOF

Print the PR URL when done. Do not merge — leave that to the user or a subsequent /merge call.


Mode: PR-merge

Merge an open PR via gh.

First, check the PR state:

gh pr view --json number,title,mergeable,mergeStateStatus,reviewDecision

If mergeStateStatus is not CLEAN, report the blockage and stop.

Choose merge style:

  • Default: --merge (preserves merge commit, matches --no-ff)
  • Squash requested: --squash
  • Rebase requested: --rebase (only if no merge commits on branch)
gh pr merge <number> --merge --delete-branch

--delete-branch removes the remote branch after merge. Pair with worktree cleanup below if this was a worktree branch.


Worktree cleanup

After a successful merge, check if the source branch was a worktree:

git worktree list

If the merged branch appears as a worktree path, remove it:

git worktree remove <path> --force
git branch -d <branch>

Only do this after confirming the branch is fully merged:

git log --oneline main..<branch>   # must be empty

Task state sync

If a godmode task is associated with this branch, mark it done:

godmode task done <task-id> --commit $(git rev-parse HEAD) --notes "merged <branch> into main"

If no task ID is known, check .ctx/godmode/tasks.yaml for tasks in running state that match the branch name or scope.


Verification

After any merge:

git log --oneline main..<branch>   # must be empty — branch fully merged
git log --oneline -3               # shows merge commit at tip

If main..<branch> is non-empty, the merge did not complete. Investigate before reporting done.


Report

One-line summary when complete:

merged: <branch> -> main | <sha> | [conflicts: N files] [worktree: removed] [task: <id> done]

If a PR was created instead of merged, print the PR URL. If escalating to the user, state exactly what is blocked and what decision is needed.


Key rules

  • git branch --show-current before every commit — stop if on main unexpectedly.
  • Never --no-verify. Let hooks run. Identify and fix failures; do not bypass.
  • Never force-push main. Feature branches only, explicit user instruction required.
  • Never abort a merge without showing git diff HEAD first.
  • Never rebase branches with merge commits.
  • Worktree cleanup only after verifying git log --oneline main..<branch> is empty.
  • For multi-branch wave integration, use godmode:wave-integration.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.