[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7C1DWA5A5WM2BFWGNRHN8E8":3,"skill-same:01M7C1DWA5A5WM2BFWGNRHN8E8":52},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":28,"ownerHtmlUrl":29,"ownerBlogUrl":28,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M7C1DWA5A5WM2BFWGNRHN8E8","merge-worktree",null,"Land a Meldom worktree end to end — commit through the ship card, push, merge with a merge commit, pull the main checkout, remove the worktree through `worktree_remove`, delete the remote branch, confirm. Use when the user presses \"Ship it\", says \"merge worktree\", \"land this worktree\", \"finish the worktree\", \"land my branch\", or wants a worktree's work carried all the way back into the main checkout.","meldomapp\u002Fskills","meldomapp","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F301474652?v=4","01M7C1CSB68BPWJ2SRPQ7C46S3","Meldom","01M7C1CSBT0YWKNH60MET3GEVR",0,"MIT","https:\u002F\u002Fgithub.com\u002Fmeldomapp\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fmerge-worktree\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: merge-worktree\ndescription: Land a Meldom worktree end to end — commit through the ship card, push, merge with a merge commit, pull the main checkout, remove the worktree through `worktree_remove`, delete the remote branch, confirm. Use when the user presses \"Ship it\", says \"merge worktree\", \"land this worktree\", \"finish the worktree\", \"land my branch\", or wants a worktree's work carried all the way back into the main checkout.\n---\n\n# Meldom Merge Worktree\n\nLand: commit → push → merge → pull main → remove the worktree → delete the remote branch → confirm. Run it FROM INSIDE the worktree being landed.\n\n## Finish, don't stop\n\nA landing runs to the end. A conflict, a dirty main checkout, a PR GitHub calls not mergeable, a peer landing already in flight — each is a pause you handle, then you carry on from the same phase.\n\n**Exactly two things end a landing early:**\n\n1. `worktree_remove` reports `git-failed` with `proof: 'local-only'` — commits exist on no ref that survives the removal, so removing would destroy the only copy. Report it verbatim and stop.\n2. The user cancels a ship card.\n\nNothing else qualifies. Do not widen this list.\n\n**Any conflict** — a merge, a rebase, a not-mergeable PR, a `git stash pop` — is resolved deliberately: read what each side intended, resolve every hunk, run the checks, commit, then carry on from the same phase. Never `git merge --abort`, never a forced push.\n\n**A gitlink conflict** (a `UU` on a submodule pointer) is settled by the ancestor test, never by \"the newest\":\n\n```bash\ngit -C \u003Csubmodule-path> fetch origin                               # the other side may be a commit you have never seen\ngit -C \u003Csubmodule-path> merge-base --is-ancestor \u003Cours> \u003Ctheirs>   # theirs contains ours -> take theirs\ngit -C \u003Csubmodule-path> merge-base --is-ancestor \u003Ctheirs> \u003Cours>   # ours contains theirs -> take ours\n```\n\nNeither contains the other → a real divergence: resolve it with your own reading of both sides.\n\n**A peer landing** — a merge in progress or `UU` entries in the main checkout or one of its submodules, that you did not create — is another agent's landing, never \"unrelated changes\". Wait for it in ONE shell command that re-checks every 30 seconds for up to 30 minutes, and touch nothing of theirs. There is no lock: this rule is the only thing keeping two landings out of each other's way.\n\n```bash\nM=\u003Cmain-checkout>\nbusy() { test -e \"$(git -C \"$M\" rev-parse --path-format=absolute --git-path MERGE_HEAD)\" || git -C \"$M\" status --porcelain | grep -q '^UU' \\\n  || git -C \"$M\" submodule foreach --quiet --recursive 'test -e \"$(git rev-parse --path-format=absolute --git-path MERGE_HEAD)\" && echo busy; true' | grep -q busy; }\nfor i in $(seq 60); do busy || break; sleep 30; done; busy && echo STILL-BUSY\ngit -C \"$M\" submodule foreach --quiet --recursive 'git symbolic-ref -q HEAD >\u002Fdev\u002Fnull || echo \"DETACHED: $displaypath\"'\n```\n\n`STILL-BUSY` → tell the user which merge is still open and carry on when they answer. A `DETACHED` submodule with no merge in progress is no landing: report it, and Phase 4 puts it back on its branch.\n\n## Phase 1 — Preflight\n\nONE chained Bash call from the worktree root:\n\n```bash\ngit rev-parse --show-toplevel && git rev-parse --git-common-dir --git-dir && git branch --show-current && git remote get-url origin 2>\u002Fdev\u002Fnull; test -f .gitmodules && echo HAS_SUBMODULES\n```\n\n- **Confirm this IS a worktree**: `--git-common-dir` differs from `--git-dir`. If they match, this is the main checkout — stop and say so.\n- **Superrepo**: `.gitmodules` present at toplevel. If so, list every submodule whose checked-out commit differs from the recorded pointer: `git submodule status --recursive | awk '$1 ~ \u002F^[+-]\u002F {print $2}'`.\n- **Remote per repo**: `git remote get-url origin`. A `github.com` URL with `gh auth status` succeeding → the **remote path** (Phase 3). A **local filesystem path** → the [local-origin path](#local-origin-submodules). Nothing at all → the [no-remote path](#no-remote-path).\n- **Original branch** (what this lands into): `git symbolic-ref refs\u002Fremotes\u002Forigin\u002FHEAD`, falling back to `main` → `master` → `develop`.\n\n## Phase 2 — Commit and push\n\nOne repo at a time, **every changed submodule before the superrepo** — a pointer-bump commit can only name a submodule commit that already exists on that submodule's remote.\n\n1. **Commit** — invoke the `meldom:ship` skill. That is the ship card, and it is the only way your work commits here. Nothing to commit in this repo → move to the next.\n2. **Push** — `git push -u origin \u003Cbranch>`. The first push has no upstream yet, so set one. Never force.\n\n## Phase 3 — Merge\n\nRemote path, per repo:\n\n```bash\ngh pr create --base \u003Coriginal-branch> --head \u003Cbranch>    # or reuse the open one\ngh pr merge \u003Cnumber> --merge\ngh pr view \u003Cnumber> --json state,mergeStateStatus        # state must read MERGED\n```\n\n- **A merge commit, always.** Never `--squash` and never `--rebase`: a squash mints a new commit the worktree's own checkout does not have, which is what makes a superrepo pointer stale and a worktree branch look unmerged.\n- **Never delete the branch as part of the merge.** The remote branch goes in Phase 6, after removal has confirmed the work is durable.\n- **Not mergeable** → repair it INSIDE the worktree, not on the remote: `git fetch origin \u003Cbase>`, `git merge origin\u002F\u003Cbase>`, resolve, push, then merge the PR.\n- **Blocked by required checks** → `gh pr merge \u003Cnumber> --merge --auto`, then wait in one blocking call: `gh pr checks \u003Cnumber> --watch --fail-fast --required`. It returns when every required check has passed or the first one fails; a failure is fixed inside the worktree and pushed. If it reports no checks right after a push, wait 30 seconds and run it again. After a clean exit the queued merge is landing; re-check it every 30 seconds for up to 20 minutes in one call:\n\n  ```bash\n  for i in $(seq 40); do\n    s=$(gh pr view \u003Cnumber> --json state,autoMergeRequest -q '\"\\(.state) \\(.autoMergeRequest != null)\"')\n    [ \"$s\" = \"OPEN true\" ] || break; sleep 30\n  done; echo \"$s\"\n  ```\n\n  A state of `MERGED` (either flag) → carry on. Anything else — `CLOSED`, `OPEN false` (auto-merge cancelled), or `OPEN true` after the ceiling — tell the user what it reads and carry on when they answer. These waits, like the peer-landing loop, can outlast a default command timeout: run them with a long timeout or in the background. Waiting is a pause, not an end.\n- Confirm `state: MERGED` before moving on.\n\n**Superrepo, right after a submodule merges**: move the worktree's own submodule checkout to the merged remote head before staging the pointer, so the pointer names a commit that is actually on the submodule's remote.\n\n```bash\ngit -C \u003Cworktree>\u002F\u003Csubmodule-path> fetch origin\ngit -C \u003Cworktree>\u002F\u003Csubmodule-path> checkout \u003Csubmodule-branch>\ngit -C \u003Cworktree>\u002F\u003Csubmodule-path> merge --ff-only origin\u002F\u003Csubmodule-branch>\ngit -C \u003Cworktree> add \u003Csubmodule-path>      # then commit the pointer bump and land the superrepo\n```\n\nThe pointer bump is your own commit, so it goes through `meldom:ship` like any other.\n\n## Phase 4 — Pull the main checkout\n\n**Record first, stash if dirty, pop afterwards. The user's files are never moved, deleted or excluded.**\n\n```bash\n# from the main checkout\n# The record Phase 7 compares against. Name it after THIS worktree's slug: a peer landing on the same machine\n# writes its own, and a shared filename would leave both confirming against the wrong baseline.\ngit status --porcelain > \"\u002Ftmp\u002Fmeldom-landing-\u003Cslug>.txt\"\n# anything listed? stash it, untracked included:\ngit stash push -u -m \"meldom-auto: landing \u003Cslug>\"\n\ngit pull --ff-only                                        # on its own branch, never detached\n# per initialized submodule:\ngit -C \u003Csubmodule-path> checkout \u003Cits branch> && git -C \u003Csubmodule-path> pull --ff-only\n\ngit stash pop                                             # conflict -> resolve it, then carry on\n```\n\n**Never let git re-checkout the submodules from the superrepo's recorded pointer (`git submodule update`, `--init --recursive`) in the shared main checkout.** It leaves every submodule DETACHED at that pointer, and a peer landing then merges onto no branch — the merge is reachable from no ref and the next checkout orphans it. Check out each submodule's branch and pull it instead, as above. A submodule already left detached with no merge in progress goes back on its branch before anything merges into it.\n\nThe stash is the user's own work. Pop it before the landing ends, whatever else happened, and never `git stash drop` it.\n\n## Phase 5 — Remove the worktree\n\nRemoval goes through the `worktree_remove` MCP tool (`mcp__meldom__worktree_remove`) and nowhere else. Call it yourself once the work has landed. The app also removes an agent-created worktree once its branch is merged and the worktree has been quiet for an hour, but that sweep is only a safety net.\n\n**Never `git worktree remove`, forced or not, in any form.** `--force` is what a worktree with submodules needs (git refuses outright once submodules are initialized), and it deletes each submodule's own git dir — the only copy of any submodule commit that has not reached the main checkout. The tool instead fetches every submodule's HEAD into the main checkout first, verifies it is reachable, removes the worktree, deletes its branch, and confirms both are gone.\n\nThe tool's own `force: true` is a different thing and is safe: it waives only the requirement that this chat OWN the worktree, so a chat asked to clean up a sibling worktree can. It never waives a safety check — dirty work, unsafe submodule state and local-only commits refuse with it set exactly as without it. Use it when the answer says this chat does not own the target; do not reach for raw git.\n\nRead the answer's `status`:\n\n- **`removed`** → the worktree and its branch are gone. Note whether the answer reports `merged: true`, and continue to Phase 6.\n- **`scheduled`** → everything landed, and the chat asking is still standing in that directory, so the app clears it when this turn goes idle. Continue to Phase 6 and say plainly that the directory goes at the idle boundary rather than reporting it already gone. Nothing retries that cleanup if the app restarts first, so if you later see the directory still on disk, call `worktree_remove` again — it is idempotent.\n- **`live`** → a chat is still attached; the answer's `blockers` name which. Close it and call again.\n- **`commands-running`** → the answer lists the running commands. Stop them, then call again.\n- **`not-found`** → you passed the wrong target. Correct it and call again.\n- **`git-failed`** → read the answer's `error` and its `proof`:\n  - `proof: 'local-only'` is **the one stop**. The branch has commits on no ref that survives the removal (they are listed in `localOnlyCommits`), so removing would destroy the only copy. Report the error verbatim and stop. Never work around it with raw git, and never force.\n  - Any other `git-failed` is a pause: fix exactly what the error names — uncommitted work goes back through Phase 2 — then call again.\n\nA refusal can also come back as a tool error rather than a status (an unmanaged worktree, a target that is not Meldom's, no verified authority). Report those verbatim and stop; they are for the user to resolve, not for you to route around.\n\n## Phase 6 — Delete the remote branch\n\nOnly after the PR reports `state: MERGED`, removal succeeded or was scheduled, **and that removal answer reports `merged: true`**:\n\n```bash\ngit push origin --delete \u003Cworktree-branch>\n```\n\n`merged: false` means that remote branch is the durable proof the work exists somewhere — keep it, and say it remains. A `worktree-landing-\u003Cshort sha>` branch published by the [local-origin path](#local-origin-submodules) is deleted here too, on the same condition.\n\n## Phase 7 — Confirm\n\n```bash\ngit status --porcelain | diff - \"\u002Ftmp\u002Fmeldom-landing-\u003Cslug>.txt\"\n```\n\n**Clean means no landing residue**: the main checkout's status equals what Phase 4 recorded — the stash is back and nothing of the landing is left. An empty `git status --short` is NOT the criterion; the user keeps their own untracked files there and they belong there. Also confirm the superrepo and every submodule are ON their branches, not detached:\n\n```bash\ngit symbolic-ref -q HEAD && git submodule foreach 'git symbolic-ref -q HEAD || echo \"DETACHED: $name\"'\n```\n\nThen report: what merged, what was removed, which remote branch went or stayed, and that the main checkout matches its pre-landing state.\n\n## Local-origin submodules\n\nA worktree submodule created before Meldom's GitHub-origin change has the **main checkout as its `origin`** — a local filesystem path, not a URL. Its branch can never reach GitHub on its own and carries no PR, so Phase 3's remote path does not apply. `git remote get-url origin` inside the worktree's submodule tells you which path you are on.\n\nLand that submodule through the main checkout instead:\n\n```bash\n# 1. The main checkout's submodule must be ON its branch. A merge landed on a detached HEAD is reachable from\n#    no ref, and the next checkout orphans it — losing every conflict resolution the merge recorded.\ngit -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> checkout \u003Csubmodule-branch>\n\n# 2. Bring the worktree submodule's branch across. Unforced on purpose: a recurring ticket-key slug can leave an\n#    OLD refs\u002Fheads\u002F\u003Cworktree-branch> from a previous incarnation, and forcing would overwrite it. A rejection\n#    means exactly that — land it under a name that cannot collide and merge THAT instead.\ngit -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> -c protocol.file.allow=always \\\n    fetch \u003Cworktree-path>\u002F\u003Csubmodule-path> \u003Cworktree-branch>:\u003Cworktree-branch> \\\n  || git -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> -c protocol.file.allow=always \\\n    fetch \u003Cworktree-path>\u002F\u003Csubmodule-path> \"$(git -C \u003Cworktree-path>\u002F\u003Csubmodule-path> rev-parse HEAD)\":refs\u002Fheads\u002F\u003Cworktree-branch>-landing\n\n# 3. Merge whichever ref step 2 actually created — never assume the first one succeeded.\ngit -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> merge --no-ff \u003Cworktree-branch>      # conflict -> resolve it\n\n# 4. Publish that merge commit to the submodule's REAL remote, so the superrepo pointer can name it.\nsha=$(git -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> rev-parse --short HEAD)\ngit -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> push origin HEAD:refs\u002Fheads\u002Fworktree-landing-$sha\n\n# 5. PR it, merge it with a merge commit, confirm MERGED, then fast-forward the main checkout.\ngh pr create --base \u003Csubmodule-branch> --head worktree-landing-$sha\ngh pr merge \u003Cnumber> --merge && gh pr view \u003Cnumber> --json state\ngit -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> pull --ff-only\n```\n\nThen realign the worktree's own submodule checkout to that merged head (Phase 3's realign block) before staging the pointer, and delete `worktree-landing-\u003Csha>` on the remote in Phase 6.\n\n**You are the only thing that collects that branch.** Nothing sweeps it later, so a landing abandoned between this merge and Phase 6 leaves it on the remote for good. If you find one from an earlier run (`git -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> ls-remote --heads origin 'worktree-landing-*'`), delete it once you confirm its tip is already contained in the base branch.\n\nConfirm before moving on: `git -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> symbolic-ref -q HEAD` prints a branch (not empty), and `git -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> log --oneline -1 \u003Csubmodule-branch>` shows the merge.\n\n## No-remote path\n\nNo `origin` at all for a repo, or one `gh` cannot serve: land it locally with a merge commit instead of Phase 3.\n\n```bash\n# from the main checkout — \u003Coriginal-branch> is checked out THERE, never inside the worktree\n# (git refuses to check out a branch that's already checked out in another worktree)\ncd \u003Cmain-checkout>\ngit checkout \u003Coriginal-branch>\ngit merge --no-ff \u003Cworktree-branch>     # conflict -> resolve it, then carry on\n```\n\nPhase 6 has nothing to delete for that repo. Everything else is unchanged.\n\nA superrepo on the remote path with a submodule that has **no shared remote at all** is the one extra refusal this path carries: a pointer commit may never name a commit that exists on this machine alone. Report that, naming the submodule and the reason, before any pointer is staged.\n\n## Gotchas\n\n| Trap                                                       | Fix                                                                                                                            |\n| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |\n| `git worktree remove` in any form                          | Never. `worktree_remove` is the only removal path — git's `--force` destroys submodule commits that reached no remote          |\n| `worktree_remove` says this chat does not own the target   | Retry the same call with `force: true` — it waives ownership only, never a safety check                                        |\n| Pointer bump before the submodule reaches its remote       | Land every submodule fully (Phases 2–3) before touching the superrepo                                                          |\n| Stale submodule SHA in the worktree                        | Fetch and check out the merged remote head in the worktree's submodule before staging the pointer                              |\n| The shared submodule checkout comes back detached          | Something ran a recursive submodule update in the main checkout. Check out its branch and pull, never that                     |\n| Untracked user files in the main checkout                  | `git stash push -u` before Phase 4, `git stash pop` after. Never move, delete or exclude them                                  |\n| A peer's half-done merge in the shared checkout            | Wait in the 30-second re-check loop. It is another landing, not unrelated changes                                              |\n| Squashing or rebasing the PR                               | Always `--merge`. A squash strands the worktree's own commits and makes the superrepo pointer stale                            |\n| `gh pr merge` blocked by required checks                   | Queue with `--auto`, wait on `gh pr checks --watch --fail-fast --required`. Never force past a required check                  |\n| `git checkout \u003Coriginal-branch>` fails inside the worktree | Git refuses a branch already checked out elsewhere — merge from the main checkout instead                                      |\n| `ship_review` fails with an error                          | Follow `meldom:ship`'s rule: retry the card when it was retracted or the request died. Raw `git commit` is never the way past |\n| Remote branch deleted too early                            | Only after MERGED, a successful removal, AND `merged: true`. Otherwise it is the only durable copy                             |\n\n## Edge cases\n\n| Scenario                             | Handling                                                                                          |\n| ------------------------------------ | ------------------------------------------------------------------------------------------------- |\n| Nothing to commit anywhere           | \"Nothing to land\" — go straight to Phase 4 and finish the tail                                    |\n| Already on the original branch       | Nothing to merge; still pull main, remove the worktree and confirm                                |\n| PR already exists for this branch    | Merge that one instead of creating a second                                                       |\n| Mixed remote\u002Flocal-origin submodules | Each repo follows its own path independently; the submodules-before-superrepo order still applies |\n| Worktree already removed on disk     | Nothing to remove; confirm the branch was actually merged before treating this as done            |\n\nTask: $ARGUMENTS\n","# Meldom Merge Worktree\n\nLand: commit → push → merge → pull main → remove the worktree → delete the remote branch → confirm. Run it FROM INSIDE the worktree being landed.\n\n## Finish, don't stop\n\nA landing runs to the end. A conflict, a dirty main checkout, a PR GitHub calls not mergeable, a peer landing already in flight — each is a pause you handle, then you carry on from the same phase.\n\n**Exactly two things end a landing early:**\n\n1. `worktree_remove` reports `git-failed` with `proof: 'local-only'` — commits exist on no ref that survives the removal, so removing would destroy the only copy. Report it verbatim and stop.\n2. The user cancels a ship card.\n\nNothing else qualifies. Do not widen this list.\n\n**Any conflict** — a merge, a rebase, a not-mergeable PR, a `git stash pop` — is resolved deliberately: read what each side intended, resolve every hunk, run the checks, commit, then carry on from the same phase. Never `git merge --abort`, never a forced push.\n\n**A gitlink conflict** (a `UU` on a submodule pointer) is settled by the ancestor test, never by \"the newest\":\n\n```bash\ngit -C \u003Csubmodule-path> fetch origin                               # the other side may be a commit you have never seen\ngit -C \u003Csubmodule-path> merge-base --is-ancestor \u003Cours> \u003Ctheirs>   # theirs contains ours -> take theirs\ngit -C \u003Csubmodule-path> merge-base --is-ancestor \u003Ctheirs> \u003Cours>   # ours contains theirs -> take ours\n```\n\nNeither contains the other → a real divergence: resolve it with your own reading of both sides.\n\n**A peer landing** — a merge in progress or `UU` entries in the main checkout or one of its submodules, that you did not create — is another agent's landing, never \"unrelated changes\". Wait for it in ONE shell command that re-checks every 30 seconds for up to 30 minutes, and touch nothing of theirs. There is no lock: this rule is the only thing keeping two landings out of each other's way.\n\n```bash\nM=\u003Cmain-checkout>\nbusy() { test -e \"$(git -C \"$M\" rev-parse --path-format=absolute --git-path MERGE_HEAD)\" || git -C \"$M\" status --porcelain | grep -q '^UU' \\\n  || git -C \"$M\" submodule foreach --quiet --recursive 'test -e \"$(git rev-parse --path-format=absolute --git-path MERGE_HEAD)\" && echo busy; true' | grep -q busy; }\nfor i in $(seq 60); do busy || break; sleep 30; done; busy && echo STILL-BUSY\ngit -C \"$M\" submodule foreach --quiet --recursive 'git symbolic-ref -q HEAD >\u002Fdev\u002Fnull || echo \"DETACHED: $displaypath\"'\n```\n\n`STILL-BUSY` → tell the user which merge is still open and carry on when they answer. A `DETACHED` submodule with no merge in progress is no landing: report it, and Phase 4 puts it back on its branch.\n\n## Phase 1 — Preflight\n\nONE chained Bash call from the worktree root:\n\n```bash\ngit rev-parse --show-toplevel && git rev-parse --git-common-dir --git-dir && git branch --show-current && git remote get-url origin 2>\u002Fdev\u002Fnull; test -f .gitmodules && echo HAS_SUBMODULES\n```\n\n- **Confirm this IS a worktree**: `--git-common-dir` differs from `--git-dir`. If they match, this is the main checkout — stop and say so.\n- **Superrepo**: `.gitmodules` present at toplevel. If so, list every submodule whose checked-out commit differs from the recorded pointer: `git submodule status --recursive | awk '$1 ~ \u002F^[+-]\u002F {print $2}'`.\n- **Remote per repo**: `git remote get-url origin`. A `github.com` URL with `gh auth status` succeeding → the **remote path** (Phase 3). A **local filesystem path** → the [local-origin path](#local-origin-submodules). Nothing at all → the [no-remote path](#no-remote-path).\n- **Original branch** (what this lands into): `git symbolic-ref refs\u002Fremotes\u002Forigin\u002FHEAD`, falling back to `main` → `master` → `develop`.\n\n## Phase 2 — Commit and push\n\nOne repo at a time, **every changed submodule before the superrepo** — a pointer-bump commit can only name a submodule commit that already exists on that submodule's remote.\n\n1. **Commit** — invoke the `meldom:ship` skill. That is the ship card, and it is the only way your work commits here. Nothing to commit in this repo → move to the next.\n2. **Push** — `git push -u origin \u003Cbranch>`. The first push has no upstream yet, so set one. Never force.\n\n## Phase 3 — Merge\n\nRemote path, per repo:\n\n```bash\ngh pr create --base \u003Coriginal-branch> --head \u003Cbranch>    # or reuse the open one\ngh pr merge \u003Cnumber> --merge\ngh pr view \u003Cnumber> --json state,mergeStateStatus        # state must read MERGED\n```\n\n- **A merge commit, always.** Never `--squash` and never `--rebase`: a squash mints a new commit the worktree's own checkout does not have, which is what makes a superrepo pointer stale and a worktree branch look unmerged.\n- **Never delete the branch as part of the merge.** The remote branch goes in Phase 6, after removal has confirmed the work is durable.\n- **Not mergeable** → repair it INSIDE the worktree, not on the remote: `git fetch origin \u003Cbase>`, `git merge origin\u002F\u003Cbase>`, resolve, push, then merge the PR.\n- **Blocked by required checks** → `gh pr merge \u003Cnumber> --merge --auto`, then wait in one blocking call: `gh pr checks \u003Cnumber> --watch --fail-fast --required`. It returns when every required check has passed or the first one fails; a failure is fixed inside the worktree and pushed. If it reports no checks right after a push, wait 30 seconds and run it again. After a clean exit the queued merge is landing; re-check it every 30 seconds for up to 20 minutes in one call:\n\n  ```bash\n  for i in $(seq 40); do\n    s=$(gh pr view \u003Cnumber> --json state,autoMergeRequest -q '\"\\(.state) \\(.autoMergeRequest != null)\"')\n    [ \"$s\" = \"OPEN true\" ] || break; sleep 30\n  done; echo \"$s\"\n  ```\n\n  A state of `MERGED` (either flag) → carry on. Anything else — `CLOSED`, `OPEN false` (auto-merge cancelled), or `OPEN true` after the ceiling — tell the user what it reads and carry on when they answer. These waits, like the peer-landing loop, can outlast a default command timeout: run them with a long timeout or in the background. Waiting is a pause, not an end.\n- Confirm `state: MERGED` before moving on.\n\n**Superrepo, right after a submodule merges**: move the worktree's own submodule checkout to the merged remote head before staging the pointer, so the pointer names a commit that is actually on the submodule's remote.\n\n```bash\ngit -C \u003Cworktree>\u002F\u003Csubmodule-path> fetch origin\ngit -C \u003Cworktree>\u002F\u003Csubmodule-path> checkout \u003Csubmodule-branch>\ngit -C \u003Cworktree>\u002F\u003Csubmodule-path> merge --ff-only origin\u002F\u003Csubmodule-branch>\ngit -C \u003Cworktree> add \u003Csubmodule-path>      # then commit the pointer bump and land the superrepo\n```\n\nThe pointer bump is your own commit, so it goes through `meldom:ship` like any other.\n\n## Phase 4 — Pull the main checkout\n\n**Record first, stash if dirty, pop afterwards. The user's files are never moved, deleted or excluded.**\n\n```bash\n# from the main checkout\n# The record Phase 7 compares against. Name it after THIS worktree's slug: a peer landing on the same machine\n# writes its own, and a shared filename would leave both confirming against the wrong baseline.\ngit status --porcelain > \"\u002Ftmp\u002Fmeldom-landing-\u003Cslug>.txt\"\n# anything listed? stash it, untracked included:\ngit stash push -u -m \"meldom-auto: landing \u003Cslug>\"\n\ngit pull --ff-only                                        # on its own branch, never detached\n# per initialized submodule:\ngit -C \u003Csubmodule-path> checkout \u003Cits branch> && git -C \u003Csubmodule-path> pull --ff-only\n\ngit stash pop                                             # conflict -> resolve it, then carry on\n```\n\n**Never let git re-checkout the submodules from the superrepo's recorded pointer (`git submodule update`, `--init --recursive`) in the shared main checkout.** It leaves every submodule DETACHED at that pointer, and a peer landing then merges onto no branch — the merge is reachable from no ref and the next checkout orphans it. Check out each submodule's branch and pull it instead, as above. A submodule already left detached with no merge in progress goes back on its branch before anything merges into it.\n\nThe stash is the user's own work. Pop it before the landing ends, whatever else happened, and never `git stash drop` it.\n\n## Phase 5 — Remove the worktree\n\nRemoval goes through the `worktree_remove` MCP tool (`mcp__meldom__worktree_remove`) and nowhere else. Call it yourself once the work has landed. The app also removes an agent-created worktree once its branch is merged and the worktree has been quiet for an hour, but that sweep is only a safety net.\n\n**Never `git worktree remove`, forced or not, in any form.** `--force` is what a worktree with submodules needs (git refuses outright once submodules are initialized), and it deletes each submodule's own git dir — the only copy of any submodule commit that has not reached the main checkout. The tool instead fetches every submodule's HEAD into the main checkout first, verifies it is reachable, removes the worktree, deletes its branch, and confirms both are gone.\n\nThe tool's own `force: true` is a different thing and is safe: it waives only the requirement that this chat OWN the worktree, so a chat asked to clean up a sibling worktree can. It never waives a safety check — dirty work, unsafe submodule state and local-only commits refuse with it set exactly as without it. Use it when the answer says this chat does not own the target; do not reach for raw git.\n\nRead the answer's `status`:\n\n- **`removed`** → the worktree and its branch are gone. Note whether the answer reports `merged: true`, and continue to Phase 6.\n- **`scheduled`** → everything landed, and the chat asking is still standing in that directory, so the app clears it when this turn goes idle. Continue to Phase 6 and say plainly that the directory goes at the idle boundary rather than reporting it already gone. Nothing retries that cleanup if the app restarts first, so if you later see the directory still on disk, call `worktree_remove` again — it is idempotent.\n- **`live`** → a chat is still attached; the answer's `blockers` name which. Close it and call again.\n- **`commands-running`** → the answer lists the running commands. Stop them, then call again.\n- **`not-found`** → you passed the wrong target. Correct it and call again.\n- **`git-failed`** → read the answer's `error` and its `proof`:\n  - `proof: 'local-only'` is **the one stop**. The branch has commits on no ref that survives the removal (they are listed in `localOnlyCommits`), so removing would destroy the only copy. Report the error verbatim and stop. Never work around it with raw git, and never force.\n  - Any other `git-failed` is a pause: fix exactly what the error names — uncommitted work goes back through Phase 2 — then call again.\n\nA refusal can also come back as a tool error rather than a status (an unmanaged worktree, a target that is not Meldom's, no verified authority). Report those verbatim and stop; they are for the user to resolve, not for you to route around.\n\n## Phase 6 — Delete the remote branch\n\nOnly after the PR reports `state: MERGED`, removal succeeded or was scheduled, **and that removal answer reports `merged: true`**:\n\n```bash\ngit push origin --delete \u003Cworktree-branch>\n```\n\n`merged: false` means that remote branch is the durable proof the work exists somewhere — keep it, and say it remains. A `worktree-landing-\u003Cshort sha>` branch published by the [local-origin path](#local-origin-submodules) is deleted here too, on the same condition.\n\n## Phase 7 — Confirm\n\n```bash\ngit status --porcelain | diff - \"\u002Ftmp\u002Fmeldom-landing-\u003Cslug>.txt\"\n```\n\n**Clean means no landing residue**: the main checkout's status equals what Phase 4 recorded — the stash is back and nothing of the landing is left. An empty `git status --short` is NOT the criterion; the user keeps their own untracked files there and they belong there. Also confirm the superrepo and every submodule are ON their branches, not detached:\n\n```bash\ngit symbolic-ref -q HEAD && git submodule foreach 'git symbolic-ref -q HEAD || echo \"DETACHED: $name\"'\n```\n\nThen report: what merged, what was removed, which remote branch went or stayed, and that the main checkout matches its pre-landing state.\n\n## Local-origin submodules\n\nA worktree submodule created before Meldom's GitHub-origin change has the **main checkout as its `origin`** — a local filesystem path, not a URL. Its branch can never reach GitHub on its own and carries no PR, so Phase 3's remote path does not apply. `git remote get-url origin` inside the worktree's submodule tells you which path you are on.\n\nLand that submodule through the main checkout instead:\n\n```bash\n# 1. The main checkout's submodule must be ON its branch. A merge landed on a detached HEAD is reachable from\n#    no ref, and the next checkout orphans it — losing every conflict resolution the merge recorded.\ngit -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> checkout \u003Csubmodule-branch>\n\n# 2. Bring the worktree submodule's branch across. Unforced on purpose: a recurring ticket-key slug can leave an\n#    OLD refs\u002Fheads\u002F\u003Cworktree-branch> from a previous incarnation, and forcing would overwrite it. A rejection\n#    means exactly that — land it under a name that cannot collide and merge THAT instead.\ngit -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> -c protocol.file.allow=always \\\n    fetch \u003Cworktree-path>\u002F\u003Csubmodule-path> \u003Cworktree-branch>:\u003Cworktree-branch> \\\n  || git -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> -c protocol.file.allow=always \\\n    fetch \u003Cworktree-path>\u002F\u003Csubmodule-path> \"$(git -C \u003Cworktree-path>\u002F\u003Csubmodule-path> rev-parse HEAD)\":refs\u002Fheads\u002F\u003Cworktree-branch>-landing\n\n# 3. Merge whichever ref step 2 actually created — never assume the first one succeeded.\ngit -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> merge --no-ff \u003Cworktree-branch>      # conflict -> resolve it\n\n# 4. Publish that merge commit to the submodule's REAL remote, so the superrepo pointer can name it.\nsha=$(git -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> rev-parse --short HEAD)\ngit -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> push origin HEAD:refs\u002Fheads\u002Fworktree-landing-$sha\n\n# 5. PR it, merge it with a merge commit, confirm MERGED, then fast-forward the main checkout.\ngh pr create --base \u003Csubmodule-branch> --head worktree-landing-$sha\ngh pr merge \u003Cnumber> --merge && gh pr view \u003Cnumber> --json state\ngit -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> pull --ff-only\n```\n\nThen realign the worktree's own submodule checkout to that merged head (Phase 3's realign block) before staging the pointer, and delete `worktree-landing-\u003Csha>` on the remote in Phase 6.\n\n**You are the only thing that collects that branch.** Nothing sweeps it later, so a landing abandoned between this merge and Phase 6 leaves it on the remote for good. If you find one from an earlier run (`git -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> ls-remote --heads origin 'worktree-landing-*'`), delete it once you confirm its tip is already contained in the base branch.\n\nConfirm before moving on: `git -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> symbolic-ref -q HEAD` prints a branch (not empty), and `git -C \u003Cmain-checkout>\u002F\u003Csubmodule-path> log --oneline -1 \u003Csubmodule-branch>` shows the merge.\n\n## No-remote path\n\nNo `origin` at all for a repo, or one `gh` cannot serve: land it locally with a merge commit instead of Phase 3.\n\n```bash\n# from the main checkout — \u003Coriginal-branch> is checked out THERE, never inside the worktree\n# (git refuses to check out a branch that's already checked out in another worktree)\ncd \u003Cmain-checkout>\ngit checkout \u003Coriginal-branch>\ngit merge --no-ff \u003Cworktree-branch>     # conflict -> resolve it, then carry on\n```\n\nPhase 6 has nothing to delete for that repo. Everything else is unchanged.\n\nA superrepo on the remote path with a submodule that has **no shared remote at all** is the one extra refusal this path carries: a pointer commit may never name a commit that exists on this machine alone. Report that, naming the submodule and the reason, before any pointer is staged.\n\n## Gotchas\n\n| Trap                                                       | Fix                                                                                                                            |\n| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |\n| `git worktree remove` in any form                          | Never. `worktree_remove` is the only removal path — git's `--force` destroys submodule commits that reached no remote          |\n| `worktree_remove` says this chat does not own the target   | Retry the same call with `force: true` — it waives ownership only, never a safety check                                        |\n| Pointer bump before the submodule reaches its remote       | Land every submodule fully (Phases 2–3) before touching the superrepo                                                          |\n| Stale submodule SHA in the worktree                        | Fetch and check out the merged remote head in the worktree's submodule before staging the pointer                              |\n| The shared submodule checkout comes back detached          | Something ran a recursive submodule update in the main checkout. Check out its branch and pull, never that                     |\n| Untracked user files in the main checkout                  | `git stash push -u` before Phase 4, `git stash pop` after. Never move, delete or exclude them                                  |\n| A peer's half-done merge in the shared checkout            | Wait in the 30-second re-check loop. It is another landing, not unrelated changes                                              |\n| Squashing or rebasing the PR                               | Always `--merge`. A squash strands the worktree's own commits and makes the superrepo pointer stale                            |\n| `gh pr merge` blocked by required checks                   | Queue with `--auto`, wait on `gh pr checks --watch --fail-fast --required`. Never force past a required check                  |\n| `git checkout \u003Coriginal-branch>` fails inside the worktree | Git refuses a branch already checked out elsewhere — merge from the main checkout instead                                      |\n| `ship_review` fails with an error                          | Follow `meldom:ship`'s rule: retry the card when it was retracted or the request died. Raw `git commit` is never the way past |\n| Remote branch deleted too early                            | Only after MERGED, a successful removal, AND `merged: true`. Otherwise it is the only durable copy                             |\n\n## Edge cases\n\n| Scenario                             | Handling                                                                                          |\n| ------------------------------------ | ------------------------------------------------------------------------------------------------- |\n| Nothing to commit anywhere           | \"Nothing to land\" — go straight to Phase 4 and finish the tail                                    |\n| Already on the original branch       | Nothing to merge; still pull main, remove the worktree and confirm                                |\n| PR already exists for this branch    | Merge that one instead of creating a second                                                       |\n| Mixed remote\u002Flocal-origin submodules | Each repo follows its own path independently; the submodules-before-superrepo order still applies |\n| Worktree already removed on disk     | Nothing to remove; confirm the branch was actually merged before treating this as done            |\n\nTask: $ARGUMENTS\n",{"name":5,"description":7},"main","aefb4ee105f883c49e0fe239fc6e7af5eabfccf0","skills\u002Fmerge-worktree","https:\u002F\u002Fgithub.com\u002Fmeldomapp\u002Fskills","https:\u002F\u002Fmeldom.com","https:\u002F\u002Fgithub.com\u002Fmeldomapp","Run your AI coding agents as a team. Local-first desktop app for Claude Code, Codex and OpenCode.","2026-11-14 16:57:06",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add meldomapp\u002Fskills --skill merge-worktree",{"tool":38,"command":39},"bunx","bunx skills add meldomapp\u002Fskills --skill merge-worktree",{"tool":41,"command":42},"pnpm","pnpm dlx skills add meldomapp\u002Fskills --skill merge-worktree","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmeldomapp\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fmerge-worktree\u002FSKILL.md",true,[46],{"path":47,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":50,"sourceHtmlUrl":51},"agents\u002Fopenai.yaml","REFERENCE","参考文档",97,"https:\u002F\u002Fgithub.com\u002Fmeldomapp\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fmerge-worktree\u002Fagents\u002Fopenai.yaml",[53,60,67,74,81,88],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M7C1FYKG3G9QSH4VGJ4V2R3X","writing-for-agents","Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.","https:\u002F\u002Fgithub.com\u002Fmeldomapp\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-for-agents\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M7C1FK3302JGFJMMQ0R34RZH","wizard","Generate an interactive bash wizard that walks a human through steps only they can perform. Use when provisioning infrastructure, setting up credentials or CI secrets, walking an unfamiliar third-party dashboard, or running a one-off migration or cutover. Don't invoke this for steps the agent can perform itself.","https:\u002F\u002Fgithub.com\u002Fmeldomapp\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwizard\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M7C1F9XJHRNXPCYEAZRQN5JH","wayfinder","Plan a huge chunk of work (more than one agent session can hold) as a shared map of decision tickets on your issue tracker, and resolve them one at a time until the way to the destination is clear.","https:\u002F\u002Fgithub.com\u002Fmeldomapp\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwayfinder\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M7C1F0YM1VKPJPT9JYG5QRMF","wait-what","Stop. That last message did not land: re-pitch it.","https:\u002F\u002Fgithub.com\u002Fmeldomapp\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwait-what\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M7C1EYSDDGMYAS895TABK7B3","triage","Move issues and external PRs through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.","https:\u002F\u002Fgithub.com\u002Fmeldomapp\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Ftriage\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":19},"01M7C1EVKH03P4S11WDNSFYNRR","to-tickets","Break a plan, spec, or the current conversation into a set of tracer-bullet tickets, each declaring its blocking edges, published to the configured tracker (edges as text in one file per ticket locally, or native blocking links on a real tracker).","https:\u002F\u002Fgithub.com\u002Fmeldomapp\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fto-tickets\u002FSKILL.md",[],[]]