gh-ghent — Agentic PR Monitoring
Prerequisite: gh extension install indrasvat/gh-ghent
All commands require: --pr <N> --format json --no-tui
Get PR number: gh pr view --json number -q.number
First Command After PR Creation Or Review-Fix Push
PR=$(gh pr view --json number -q .number)
gh ghent status --pr $PR --await-review --solo --logs --format json --no-tuiThis is the single blessed command for PR review handling. Use it:
- immediately after PR creation
- again after every push that addresses review or CI feedback
It waits for CI, performs bounded review monitoring, and returns everything in one response:
- threads with
is_bot - checks with log excerpts
- reviews
review_monitoris_merge_ready
Drop --solo for org repos with required review policies. Always include --await-review when review comments may still arrive. Do not switch to bare --watch after the first cycle if review comments still matter — --watch is CI-only and can miss follow-up bot comments. Drop --logs only on narrow re-checks where CI failure detail is definitely not needed.
Response Shape (status)
{
"is_merge_ready": false,
"comments": {
"threads": [{"id": "PRRT_...", "path": "foo.go", "line": 42,
"comments": [{"author": "coderabbitai", "is_bot": true, "body": "..."}]}],
"unresolved_count": 2,
"bot_thread_count": 2,
"unanswered_count": 1
},
"checks": {
"overall_status": "pass",
"checks": [{"name": "CI", "conclusion": "success", "annotations": [], "log_excerpt": ""}]
},
"reviews": [{"author": "alice", "state": "APPROVED"}],
"review_monitor": {
"phase": "settled",
"confidence": "high",
"activity_count": 3,
"wait_seconds": 154
}
}Decision Order
Act on the first matching condition — fix it, then re-run status:
- Exit code 2 → auth / rate limit / not-found error. Fix credentials.
checks.overall_status == "failure"→ Fix CI. Log excerpts and annotations are inline.checks.overall_status == "pending"→ Re-run the samestatus --await-reviewcommand. Do not switch to--watchwhile review comments may still appear.comments.unanswered_count > 0→ Bot sweep (see below).comments.unresolved_count > 0→gh ghent resolve --pr <N> --allreview_monitor.phase == "timeout"orreview_monitor.confidence == "low"→ Treat result as provisional. If you just pushed fixes, re-run the samestatus --await-reviewcommand after the push settles.is_merge_ready == trueandreview_monitor.confidence!= "low"→ Merge / stop.
Anti-Footgun Rule
When review comments may still arrive:
- use
gh ghent status --await-review... - after every fix push, use
gh ghent status --await-review...again - do not switch to
gh ghent checks --watch - do not switch to
gh ghent status --watch
Bare --watch is only for CI-only waiting when review state is irrelevant.
Bot Sweep (when unanswered_count > 0)
The status already contains the full threads — no second call needed.
- Read threads from
comments.threads[]wherecomments[0].is_bot == true - Fix code → push
- Per thread:
gh ghent reply --pr <N> --thread PRRT_... --body "Fixed" --resolve - Re-check with the same command:
gh ghent status --pr <N> --await-review --solo --logs --format json --no-tui - Repeat until
is_merge_ready == trueandreview_monitor.confidence!= "low"
Solo Mode
Add --solo only when the repo owner is the authenticated user on a personal (non-org) repo. Never auto-add for org repos. If merge readiness is false only because approval is missing on a personal repo, retry with --solo.
Commands
| Command | Purpose | Key Flags |
|---|---|---|
status | Full PR status + merge readiness | --logs, --watch, --await-review, --quiet, --compact, --solo |
comments | Unresolved review threads | --bots-only, --humans-only, --unanswered, --group-by |
checks | CI status + annotations | --logs, --watch |
resolve | Resolve/unresolve threads | --thread, --all, --file, --author, --unresolve, --dry-run |
reply | Reply to a thread | --thread, --body, --body-file, --resolve |
Exit Codes
| Command | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
status | merge-ready | not ready | error | — | — |
comments | no unresolved | has unresolved | error | — | — |
checks | all pass | failure | error | pending | — |
resolve | all success | partial failure | total failure | — | — |
reply | posted | thread not found | error | — | reply ok, resolve failed |
Exit 2 = auth failure, rate limit, or resource not found.
Other Patterns
# Merge-readiness gate (silent exit 0 if ready, exit 1 + full output if not)
gh ghent status --pr <N> --quiet --solo
# Drill-down: bot threads only
gh ghent comments --pr <N> --bots-only --unanswered --format json --no-tui
# Group by file for batch fixing
gh ghent comments --pr <N> --group-by file --format json --no-tui
# Compact status (minimal tokens for polling loops)
gh ghent status --pr <N> --compact --format json --no-tuiReferences
- Command Reference — all flags, full output schemas
- Agent Workflows — step-by-step patterns
- Exit Codes — branching logic
- Review Cycle Example — read, fix, resolve, reply walkthrough
- CI Monitor Example — watch CI, extract errors, fix, re-check