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
ghCLI is authenticated.- You are on the PR branch with a clean working tree.
Steps
- Locate the PR for the current branch.
- Confirm the full validation suite is green locally:
go build ./... go test ./... -count=1 go vet ./... test -z "$(gofmt -l .)" - If the working tree has uncommitted changes, commit with the
commitskill and push with thepushskill before proceeding. - Check mergeability and conflicts against main.
- If conflicts exist, use the
pullskill to fetch/mergeorigin/mainand resolve conflicts, then use thepushskill to publish the updated branch. - If a
.github/workflows/*codex*workflow exists, ensure Codex review comments are acknowledged and any required fixes are handled before merging. Otherwise, skip the Codex review wait. - Watch checks until complete.
- If checks fail, pull logs, fix the issue, commit with the
commitskill, push with thepushskill, 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.
- If you are confident you know better than the reviewer, you may proceed without asking the user, but reply inline with your rationale.
- Per-comment mode: For each review comment, choose one of: accept, clarify, or push back. Reply inline (or in the issue thread for Codex reviews) stating the mode before changing code.
- Reply before change: Always respond with intended action before pushing code changes (inline for review comments, issue thread for Codex reviews).
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
# Watch checks
if ! gh pr checks --watch; then
gh pr checks
# Identify failing run and inspect logs
# gh run list --branch "$branch"
# gh run view <run-id> --log
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 checksandgh run view --log, then fix locally, commit with thecommitskill, push with thepushskill, 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.
- If CI pushes an auto-fix commit (authored by GitHub Actions), it does not
trigger a fresh CI run. Detect the updated PR head, pull locally, merge
origin/mainif needed, add a real author commit, and force-push to retrigger CI, then restart the checks loop. - If mergeability is
UNKNOWN, wait and re-check. - Do not merge while review comments (human or Codex review) are outstanding.
Review Handling
- Human review comments are blocking and must be addressed (responded to and resolved) before requesting a new review or merging.
- If multiple reviewers comment in the same thread, respond to each comment (batching is fine) before closing the thread.
- Fetch review comments via
gh apiand reply with a prefixed comment. - Use review comment endpoints (not issue comments) to find inline feedback:
- List PR review comments:
gh api repos/{owner}/{repo}/pulls/<pr_number>/comments - PR issue comments (top-level discussion):
gh api repos/{owner}/{repo}/issues/<pr_number>/comments - Reply to a specific review comment:
gh api -X POST /repos/{owner}/{repo}/pulls/<pr_number>/comments \ -f body='[codex] <response>' -F in_reply_to=<comment_id>
- List PR review comments:
in_reply_tomust be the numeric review comment id (e.g.,2710521800), not the GraphQL node id (e.g.,PRRC_...), and the endpoint must include the PR number (/pulls/<pr_number>/comments).- 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 to the original review comment. - Implement fixes, commit, push.
- Reply with the fix details and commit sha in the same place.
- Reply with intended fixes (
Scope + PR Metadata
- The PR title and description should reflect the full scope of the change, not just the most recent fix.
- If review feedback expands scope, decide whether to include it now or defer it. You can accept, defer, or decline feedback.
- Correctness issues raised in review comments should be addressed. If you plan to defer or decline a correctness concern, validate first and explain why the concern does not apply.
- Classify each review comment as one of: correctness, design, style, clarification, scope.
- Prefer a single consolidated "review addressed" root-level comment after a batch of fixes instead of many small updates.