Land
Goals
- Ensure the PR is conflict-free with main.
- Keep CI green and fix failures when they occur.
- Squash-merge the PR once checks pass.
- Do not yield to the user until the PR is merged; keep the watcher loop running
unless blocked.
- No need to delete remote branches after merge; the repo auto-deletes head
branches.
Preconditions
gh CLI is authenticated.
- You are on the PR branch with a clean working tree.
Steps
- Locate the PR for the current branch.
- Confirm validation passes locally before any push:
npm run compile
npm run lint
npm run test:unit
- If the working tree has uncommitted changes, commit with the
commit skill
and push with the push skill before proceeding.
- Check mergeability and conflicts against main.
- If conflicts exist, use the
pull skill to fetch/merge origin/main and
resolve conflicts, then use the push skill to publish the updated branch.
- Ensure review comments (if present) are acknowledged and any required
fixes are handled before merging.
- Watch checks until complete.
- If checks fail, pull logs, fix the issue, commit with the
commit skill,
push with the push skill, and re-run checks.
- When all checks are green and review feedback is addressed, squash-merge and
delete the branch using the PR title/body for the merge subject/body.
- Context guard: Before implementing review feedback, confirm it does not
conflict with the user's stated intent or task context. If it conflicts,
respond inline with a justification and ask the user before changing code.
- Pushback template: When disagreeing, reply inline with: acknowledge +
rationale + offer alternative.
- Ambiguity gate: When ambiguity blocks progress, use the clarification
flow (assign PR to current GH user, mention them, wait for response). Do not
implement until ambiguity is resolved.
- Per-comment mode: For each review comment, choose one of: accept,
clarify, or push back. Reply inline stating the mode before changing code.
- Reply before change: Always respond with intended action before pushing
code changes.
Commands
# Ensure branch and PR context
branch=$(git branch --show-current)
pr_number=$(gh pr view --json number -q .number)
pr_title=$(gh pr view --json title -q .title)
pr_body=$(gh pr view --json body -q .body)
# Check mergeability and conflicts
mergeable=$(gh pr view --json mergeable -q .mergeable)
if [ "$mergeable" = "CONFLICTING" ]; then
# Run the `pull` skill to handle fetch + merge + conflict resolution.
# Then run the `push` skill to publish the updated branch.
fi
# Preferred: use the Async Watch Helper below.
while true; do
sleep 10
done
# Watch checks
if ! gh pr checks --watch; then
gh pr checks
exit 1
fi
# Squash-merge (remote branches auto-delete on merge in this repo)
gh pr merge --squash --subject "$pr_title" --body "$pr_body"
Async Watch Helper
Preferred: use the asyncio watcher to monitor review comments, CI, and head
updates in parallel:
python3 .codex/skills/land/land_watch.py
Exit codes:
- 2: Review comments detected (address feedback)
- 3: CI checks failed
- 4: PR head updated (autofix commit detected)
Failure Handling
- If checks fail, pull details with
gh pr checks and gh run view --log, then
fix locally, commit with the commit skill, push with the push skill, and
re-run the watch.
- Use judgment to identify flaky failures. If a failure is a flake (e.g., a
timeout on only one platform), you may proceed without fixing it.
- Ubuntu test timeouts are a known issue for this project — if tests pass on
other platforms, treat the Ubuntu timeout as a flake.
- If mergeability is
UNKNOWN, wait and re-check.
- Do not merge while review comments are outstanding.
- Do not enable auto-merge; use the watcher loop instead.
Review Handling
- Human review comments are blocking and must be addressed before merging.
- All GitHub comments generated by this agent must be prefixed with
[codex].
- If feedback requires changes:
- Reply with intended fixes (
[codex] ...) as an inline reply.
- Implement fixes, commit, push.
- Reply with the fix details and commit sha.
- Use review comment endpoints (not issue comments) to find inline feedback:
1---2name: land3description: Land a PR by monitoring conflicts, resolving them, waiting for checks, and squash-merging when green; use when asked to land, merge, or shepherd a PR to completion.4---56# Land78## Goals910- Ensure the PR is conflict-free with main.11- Keep CI green and fix failures when they occur.12- Squash-merge the PR once checks pass.13- Do not yield to the user until the PR is merged; keep the watcher loop running14 unless blocked.15- No need to delete remote branches after merge; the repo auto-deletes head16 branches.1718## Preconditions1920- `gh` CLI is authenticated.21- You are on the PR branch with a clean working tree.2223## Steps24251. Locate the PR for the current branch.262. Confirm validation passes locally before any push:27 - `npm run compile`28 - `npm run lint`29 - `npm run test:unit`303. If the working tree has uncommitted changes, commit with the `commit` skill31 and push with the `push` skill before proceeding.324. Check mergeability and conflicts against main.335. If conflicts exist, use the `pull` skill to fetch/merge `origin/main` and34 resolve conflicts, then use the `push` skill to publish the updated branch.356. Ensure review comments (if present) are acknowledged and any required36 fixes are handled before merging.377. Watch checks until complete.388. If checks fail, pull logs, fix the issue, commit with the `commit` skill,39 push with the `push` skill, and re-run checks.409. When all checks are green and review feedback is addressed, squash-merge and41 delete the branch using the PR title/body for the merge subject/body.4210. **Context guard:** Before implementing review feedback, confirm it does not43 conflict with the user's stated intent or task context. If it conflicts,44 respond inline with a justification and ask the user before changing code.4511. **Pushback template:** When disagreeing, reply inline with: acknowledge +46 rationale + offer alternative.4712. **Ambiguity gate:** When ambiguity blocks progress, use the clarification48 flow (assign PR to current GH user, mention them, wait for response). Do not49 implement until ambiguity is resolved.5013. **Per-comment mode:** For each review comment, choose one of: accept,51 clarify, or push back. Reply inline stating the mode before changing code.5214. **Reply before change:** Always respond with intended action before pushing53 code changes.5455## Commands5657```58# Ensure branch and PR context59branch=$(git branch --show-current)60pr_number=$(gh pr view --json number -q .number)61pr_title=$(gh pr view --json title -q .title)62pr_body=$(gh pr view --json body -q .body)6364# Check mergeability and conflicts65mergeable=$(gh pr view --json mergeable -q .mergeable)6667if [ "$mergeable" = "CONFLICTING" ]; then68 # Run the `pull` skill to handle fetch + merge + conflict resolution.69 # Then run the `push` skill to publish the updated branch.70fi7172# Preferred: use the Async Watch Helper below.73while true; do74 sleep 1075done7677# Watch checks78if ! gh pr checks --watch; then79 gh pr checks80 exit 181fi8283# Squash-merge (remote branches auto-delete on merge in this repo)84gh pr merge --squash --subject "$pr_title" --body "$pr_body"85```8687## Async Watch Helper8889Preferred: use the asyncio watcher to monitor review comments, CI, and head90updates in parallel:9192```93python3 .codex/skills/land/land_watch.py94```9596Exit codes:9798- 2: Review comments detected (address feedback)99- 3: CI checks failed100- 4: PR head updated (autofix commit detected)101102## Failure Handling103104- If checks fail, pull details with `gh pr checks` and `gh run view --log`, then105 fix locally, commit with the `commit` skill, push with the `push` skill, and106 re-run the watch.107- Use judgment to identify flaky failures. If a failure is a flake (e.g., a108 timeout on only one platform), you may proceed without fixing it.109- Ubuntu test timeouts are a known issue for this project — if tests pass on110 other platforms, treat the Ubuntu timeout as a flake.111- If mergeability is `UNKNOWN`, wait and re-check.112- Do not merge while review comments are outstanding.113- Do not enable auto-merge; use the watcher loop instead.114115## Review Handling116117- Human review comments are blocking and must be addressed before merging.118- All GitHub comments generated by this agent must be prefixed with `[codex]`.119- If feedback requires changes:120 - Reply with intended fixes (`[codex] ...`) as an inline reply.121 - Implement fixes, commit, push.122 - Reply with the fix details and commit sha.123- Use review comment endpoints (not issue comments) to find inline feedback:124 - List PR review comments:125 ```126 gh api repos/{owner}/{repo}/pulls/<pr_number>/comments127 ```128 - Reply to a specific review comment:129 ```130 gh api -X POST /repos/{owner}/{repo}/pulls/<pr_number>/comments \131 -f body='[codex] <response>' -F in_reply_to=<comment_id>132 ```