Files
agent-skills/commands/merge.md
T
naps62andClaude Opus 5 ef1b00c573 fix(merge): pick forge, leave worktree to aoe
The command hardcoded `gh pr merge`, which fails on the Gitea repos, and
deleted the worktree that Agent of Empires owns — stranding the session
and removing the directory it runs in.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-16 15:32:41 +00:00

2.3 KiB

Merge a branch from the worktree. If you're currently working on a worktree, assume that's the one I'm referring to.

Start by committing any staged and unstaged changes. I may have made changes to the worktree manually. Then merge back the new main branch, since I may have made changes to it.

Language specific:

Rust

Ensure cargo check is happy. Ensure clippy is happy. clean up any new warnings.

Typescript

Ensure tsc is happy.

Merging

Pick the forge before running anything:

  • remoteHost from .claude/tracker.json (or legacy .claude/linear.json) if set (github / gitea).
  • Else infer from git remote get-url origin: github.com → github; anything else (e.g. git.naps.pt) → gitea.

Merge server-side when a PR exists, so the forge marks it "merged" and not "closed".

github:

gh pr merge --squash

gitea: there is no tea CLI on this machine — use the REST API. BASE is remoteBaseUrl from config (or the origin host), REPO is <owner>/<repo> from origin, $GITEA_TOKEN comes from the environment (source ~/.env.claude if missing). Header auth only — never put the token in a URL.

N=$(curl -sS -H "Authorization: token $GITEA_TOKEN" \
  "$BASE/api/v1/repos/$REPO/pulls?state=open&head=<owner>:<branch>" | jq -r '.[0].number')
curl -sS -X POST -H "Authorization: token $GITEA_TOKEN" -H "Content-Type: application/json" \
  "$BASE/api/v1/repos/$REPO/pulls/$N/merge" -d '{"Do":"squash"}'

No PR on either forge (the /yolo flow pushes without one): merge locally instead — checkout the default branch, git merge <branch> --no-edit, push.

Cleanup

Check whether Agent of Empires owns this worktree first. aoe session current resolves from the tmux environment, not the cwd, so confirm the session's Path is actually this worktree:

S=$(aoe session current -q) && aoe session show "$S" | grep Path
  • The path matches this worktree → aoe owns the worktree and the branch. Do not run git worktree remove or delete the branch; that strands the session and deletes the directory you are running in. Report the merge, then hand me the command and stop:

    aoe remove <session> --delete-worktree --delete-branch
    
  • No session, or the path points elsewhere → the worktree is plain git. Delete the local worktree and branch yourself.