Land PR
You are in Land Mode — your job is to take an existing pull request, get it green, and land it without manual intervention. You never create a new branch or a new PR. You work exclusively on the branch and PR that already exist.
Step 1 — Parse the PR reference
The user invoked /land with arguments. Extract:
- PR number: from a bare integer (
7342) or a GitHub URL (.../pull/7342). - Extra instructions: any text after the PR number/URL — these are additional constraints or context to keep in mind while fixing.
If no PR reference was given, ask the user for one before proceeding.
Step 2 — Fetch PR metadata
Use mcp__github__pull_request_read with { owner: "dxos", repo: "dxos", pullNumber: <number> } to retrieve:
headRefName— the branch you will work on.baseRefName— usuallymain.- Current state (open/merged/closed), draft status, merge-ability.
- Title, body, labels.
If the PR is already merged or closed, tell the user and stop. If it is a draft,
run gh pr ready <number>: a draft skips the browser and e2e suites and the merge queue rejects it.
Check whether the PR belongs to a stack (GitHub native stacked PRs): the stack
map on the PR page is the test — baseRefName ≠ main is only a hint, and a
stack's bottom PR targets main. For any stack member, see Stacked PRs
below before Step 8.
Step 3 — Check out the branch locally
export PROTO_HOME="$HOME/.proto" && export PATH="$PROTO_HOME/shims:$PROTO_HOME/bin:$PATH"
git fetch origin <headRefName>
git checkout <headRefName>
Never create a new branch. If the checkout fails for any reason, diagnose and fix before continuing.
Confirm the worktree is on the right branch with git branch --show-current.
Step 4 — Sync with base branch
Merge main (or the base branch) in only when the PR conflicts with it (mergeable is
CONFLICTING) or a failure traces to a change on main. The merge queue tests the PR on top of
main, and every push to a ready PR reruns the full Check suite, so a clean branch stays as it is.
git fetch origin main
git merge origin/main --no-edit
Resolve the conflicts, then commit and push together with any CI fixes from Step 6:
git add -A
git commit -m "chore: merge main into branch"
git push -u origin <headRefName>
Never use --force or --force-with-lease. If push is rejected due to protected-branch rules, report to user and stop.
Step 5 — Assess current CI status
Use mcp__github__pull_request_read again (or search recent check runs) to understand which checks are failing.
Look specifically for the "Check" workflow — it covers build, test, lint, and fmt. Any red check is YOUR responsibility to fix.
Build a status checklist like:
## Land Status — PR #<number>
- [ ] Build passing
- [ ] Tests passing
- [ ] Lint passing
- [ ] Fmt passing
- [ ] Merge conflicts resolved
- [ ] Review comments addressed
- [ ] In merge queue
Print this checklist and keep it updated throughout the session.
Step 6 — Fix CI failures
For each failing check:
- Identify the failing job and step from CI logs.
- Reproduce locally:
- Build:
moon run <package>:build - Tests:
moon run <package>:test -- <test-file> - Lint:
moon run :lint -- --fix - Format:
pnpm format
- Apply the fix at the root cause — no casts, no
// @ts-ignore, no--no-verify. - Run the specific check locally to confirm the fix.
- Commit with a
scope: descriptionmessage. Push once, after every failing check has a fix:
each push reruns the full suite.
Prohibited shortcuts:
as any,as unknown, non-null!to silence type errors.--no-verifyto skip hooks.- Commenting out failing tests.
- Force-push.
- Modifying CI config to skip the failing step.
After each push, re-examine CI to confirm the fix landed correctly.
Step 7 — Address review comments
Use mcp__github__pull_request_read to check for unresolved review threads. For each unresolved thread:
- If the comment requests a code change and you agree, apply it.
- If you disagree or need clarification, reply explaining why.
- If already addressed by your commits, reply confirming.
Step 7.5 — Rewrite the changeset
Before enqueueing, reread the PR's .changeset/*.md against the whole diff as it stands now
(git diff origin/<baseRefName>...HEAD, the base from Step 2 — a stacked child diffs against its
parent's branch, never main). Review rounds and scope changes since the PR opened make the
body stale; when it no longer summarizes the PR, rewrite the body from scratch (never append a
sentence per fix), commit with scope: description, and push. A body that still describes the PR
stays as it is. Rules for the body and bump level: