The next productivity gain is in the waiting
A coding agent can write a patch quickly and still waste the next half-hour repeatedly asking whether CI finished or a reviewer responded. Each query consumes orchestration work, API requests and sometimes model context without advancing the change. GitHub's November 18 release of event commands for its CLI addresses that unglamorous gap. Starting with gh 2.105.0, an enabled account can subscribe to pull-request changes and let the terminal wait for a relevant event rather than run another polling loop.
This is not a new code-generation model. It is infrastructure for a better AI-assisted development workflow: implement, submit, wait, inspect fresh evidence, then decide. For a senior engineer, that separation matters more than another autonomous loop. An event should wake the assistant, not authorize a merge. The practical opportunity is to reduce supervision overhead while retaining explicit ownership of correctness, security and release decisions.
What the tool actually does
GitHub CLI is the open-source gh command-line client for GitHub. Its new gh event command family integrates GitHub Event Streams, a public-preview service that delivers pull-request changes over Server-Sent Events. Unlike a webhook integration, a laptop-based listener does not need an internet-accessible callback endpoint. It opens an outbound connection, receives a notification and can fetch the current resource state through GitHub's API. That fits terminal agents, local review assistants and short-lived engineering scripts.
The listener prints one CloudEvent JSON object per line to standard output. Status messages go to standard error, keeping machine-readable output separate from operational diagnostics. By default it exits after the first event, which fits an agent that waits for a command to finish before continuing. You can instead request several events or maintain a continuous stream. The feature changes how work resumes; it does not perform code review, test execution or policy evaluation itself.
Availability is a prerequisite, not a detail
The commands require gh 2.105.0 or later, but installing a recent binary is not sufficient. Event Streams access is being enabled through a waitlist. The service and CLI commands are in preview and may change. Support is currently limited to pull requests on github.com, not GitHub Enterprise Server or GHE.com. Check that boundary before proposing it as the standard waiting mechanism for an enterprise estate.
Enablement also follows the authentication identity. A user token requires that user's account to be enabled. For an installation token, enablement applies to the user, organization or enterprise where the app is installed; that does not automatically enable members' personal tokens. GitHub documents user and installation tokens, with read access to the target pull request, but not an app authenticating as itself. A 403 stating that event subscriptions are not enabled is an access condition to resolve, not an invitation to retry indefinitely.
Install or upgrade without changing your trust model
Start at the official CLI site and its installation links. On macOS, Homebrew users can install with brew install gh or upgrade an existing installation with brew upgrade gh. On Windows, the usual WinGet package is winget install --id GitHub.cli; use your package manager's upgrade path if already installed. For Linux, follow the distribution-specific instructions in the official repository, or use an official release archive. A distribution package can lag the required version.
Run gh --version, then gh auth login --hostname github.com and gh auth status. Confirm the authenticated identity and repository access before troubleshooting subscriptions. Read gh event --help and gh event listen --help against your installed version. Do not broaden token permissions just to make a preview work, print tokens in logs, or give a listening assistant merge rights it does not otherwise need. Installation, feature enablement and authorization are three separate checks.
Your first bounded listener
After access is enabled, replace the owner, repository and pull-request number in this documented command pattern: gh event listen --resource https://github.com/OWNER/REPO/pull/123 --event com.github.pull_request.review.submitted.v1 --timeout 30m. It waits for the next matching review event and exits. The timeout is a work budget, not a declaration that review failed. If the timeout expires first, the documented exit status is 8. Handle that outcome separately from successful delivery and authentication or network failures.
For ongoing observation, add --follow; for a bounded number of notifications, use --count. Keep stderr visible because it reports attachment to the stream. The examples here are documentation-based integration patterns, not a claim that a live authenticated subscription was tested for this article. Pilot them on a noncritical pull request under your own enabled identity. Start with observation only, confirm events arrive, and add agent actions after the operational behavior is understood.
Subscribe to the state changes your workflow needs
The currently documented types cover submitted reviews, pull-request state changes, head changes, merge conflicts and completed check suites. Their identifiers are com.github.pull_request.review.submitted.v1, com.github.pull_request.state.changed.v1, com.github.pull_request.head.changed.v1, com.github.pull_request.merge_conflict.v1 and com.github.pull_request.check_suite.status.changed.v1. Repeat --event or provide comma-separated types. Select the smallest set that covers the transitions your assistant can usefully handle.
A notification is deliberately thin. Its data.api_url points to the changed object: a review, pull request or check suite. Fetch that object to learn what happened. A state-change notification does not by itself distinguish merged from closed, and a review notification is not synonymous with approval. Check-suite events include a conclusion, but that is the conclusion of one suite. A type name is a trigger for investigation, not a substitute for reading the evidence.
Close the startup race before trusting silence
There is no historical replay. Changes that happened before attachment are not delivered, and GitHub also documents a short window immediately after subscription creation in which events can be missed. Reading the pull request and only then opening the stream leaves a race: a review or push can happen between those operations. The safe integration pattern is to attach first, observe the CLI's listening status message, and then fetch the current pull-request state.
For an agent supervisor, this means managing the listener and initial read together rather than invoking a blocking command and assuming prior observations remain current. Reconcile again after each attachment or reconnection. If you cannot reliably coordinate readiness in your wrapper, keep the first integration observational and document that limitation. Silence means no matching event has been delivered on the open connection; it does not prove that nothing changed, that checks passed or that a reviewer is withholding approval.
Use case one: resume a CI repair with evidence
Consider an agent that fixes a failing test, pushes a small branch update and opens a pull request. Subscribe to completed check suites and head changes. After attachment, record the current head commit and read the check state. When a suite event arrives, fetch the current required checks, identify any failing job and retrieve its relevant logs. The assistant can classify the failure, propose a focused correction and explain which test would demonstrate the repair. A human still decides whether the diagnosis justifies a code change.
Do not treat the first successful suite as a green pipeline. Pull requests commonly have several suites, reruns produce additional events, and REST-created commit statuses are not covered by check-suite notifications. Use gh pr checks and the repository's actual required-check policy, fetching statuses separately where needed. A head change invalidates conclusions tied to the previous commit. Before presenting a release-ready summary, bind every claimed result to the current head SHA and distinguish passing, pending, skipped and missing requirements.
Use case two: prepare the response to a human review
A terminal assistant can wait for a submitted review, fetch it and turn the feedback into a small work plan: confirmed defect, clarification request, stylistic preference or architectural disagreement. Ask it to map each proposed change to the relevant file and test, then stop for human approval before implementing ambiguous requests. This reduces the cost of reconstructing context when feedback arrives while keeping negotiation about product behavior and design with the people responsible for the system.
The event does not establish that the review came from a trusted approver or that every comment is safe to execute. Reviewer text, code snippets and links are untrusted input. Do not allow a comment to override repository instructions, request credentials or run arbitrary shell commands. Fetch the review state and identity, compare them with the team's review policy, and preserve a visible unresolved-feedback list. Also distinguish review comments from general conversation comments: GitHub currently documents no events for ordinary comments in the pull-request conversation tab.
Use case three: stop working against a stale branch
Head-change events are useful when a human and an assistant share a pull request or several agents prepare related work. A new push should prompt the supervisor to refresh the branch, compare the current SHA with the agent's recorded base, and invalidate stale test evidence. If the assistant is editing a worktree, it should not blindly reset or overwrite it. First record local changes and ask whether the new upstream work changes the task boundary.
This gives the assistant a useful interrupt without turning it into a concurrent author with unlimited authority. For example, an engineer may push a schema correction while the agent is updating tests. The agent should explain the overlap, refresh its plan and rerun affected validation rather than continue polishing the old assumption. Merge-conflict notifications can similarly trigger diagnosis, but they are not immediate conflict detectors: GitHub notes that conflict detection follows someone viewing or requesting the pull request. Keep ordinary Git integration checks.
Use case four: build a review-ready handoff
A useful higher-level workflow combines the relevant events into an engineering handoff rather than an automatic merge. When CI changes or a review arrives, refresh a compact summary containing the current head, outstanding human feedback, required-check status, known risks and the next owner. The assistant can prepare the text and supporting links. The developer decides whether to request another review, revise the implementation or schedule the release.
Keep the handoff idempotent: the same observed state should produce the same suggested action, not another comment, another commit or another notification. Store the last summarized head and feedback state, and update only when something meaningful changes. This avoids replacing polling noise with event-driven noise. For teams working across time zones, the gain is a clearer restart point: the next person sees what is verified, what changed since the last summary and exactly which judgment still requires a human.
Reconnections, duplicates and ordering are normal
The CLI reconnects if a stream breaks, but events that occur while disconnected are not replayed. GitHub also documents duplicate and out-of-order delivery. Build around current-state reconciliation, not an assumption that the stream is a durable, perfectly ordered audit log. On receipt, fetch the referenced resource and compare it with the current pull-request head and your recorded work state. Deduplicate actions, not merely displayed event lines, because two notifications can legitimately lead to the same resulting state.
Separate observing from mutating. A listener can enqueue a refresh; a controller evaluates policy; an explicitly authorized step performs a change. That architecture makes reconnects and repeated notifications much less dangerous. It also allows a bounded fallback state read after a disconnect or timeout. If the business requirement is guaranteed event history, select an integration architecture that actually provides it rather than silently treating this preview stream as a durable queue. No replay is a design constraint, not an edge case.
Subscriptions need lifecycle management
A subscription covers one pull request and expires after 24 hours. The documented limit is 100 active subscriptions for each user, app and installation token. The CLI can reuse a matching subscription and recreate one when it expires, but exiting a listener does not delete its subscription. Use gh event subscription list, create, view and delete to inspect and manage them. Allocate listeners to active work instead of subscribing indiscriminately to every historical pull request.
Close the open stream before deleting its subscription: deletion currently does not close an already open connection. For CI-based controllers, account for token lifetime as well. Installation tokens expire after an hour; GitHub advises refreshing them before reconnecting, while a job's GITHUB_TOKEN cannot be renewed. Clean up subscriptions created by the job before it finishes. Assign one owner for listener lifecycle, cancellation and cleanup so that abandoned agent sessions do not gradually consume the account's subscription capacity.
Failure handling should preserve the human decision
Classify failures before reacting. A 401 calls for checking or refreshing authentication; a 403 for disabled access is not fixed by backoff; a 422 can mean invalid event types or exhausted subscription capacity. Temporary service errors need bounded retries and the documented Retry-After delay where supplied. For a timeout, fetch current state once, report that the waiting budget ended and give the developer a clear choice to resume later. Never translate missing notifications into successful validation.
Apply the same discipline to the agent's own output. Preserve the command outcome, last attachment time, latest observed head and outstanding checks. Redact secrets and avoid storing full private review text unnecessarily. If the listener fails while a release decision is pending, show that uncertainty explicitly and leave established branch protections and required human approvals intact. An unreliable convenience layer must not weaken the repository's authoritative merge controls or quietly expand the assistant's credentials.
Measure a better workflow, not an impressive demo
The plausible productivity gains are fewer redundant status requests, less repeated context rebuilding and faster resumption after relevant feedback. These are workflow hypotheses, not benchmark results established by the release. Compare a bounded pilot with your existing approach. Record status requests per pull request, elapsed time between feedback and useful action, unnecessary agent wakeups, missed-state incidents and the engineer's time spent supervising waiting. Include subscription and recovery maintenance in the cost.
Do not optimize event latency while ignoring incorrect responses. A fast assistant that repairs the wrong commit or mistakes a comment for approval creates more review work. Track how often its suggested next action is accepted and how often the human has to correct a stale assumption. Start with a small, representative repository and an observation-only controller, then add one supervised response workflow. Expand only if the evidence shows lower coordination effort without degraded verification or a larger operational burden.
A practical adoption checklist
- Verify CLI version, enabled identity, supported host and read-only access before wiring an agent into the stream.
- Attach the listener, confirm readiness, then fetch current state; reconcile again after reconnecting.
- Treat events as wakeups, fetch evidence, and bind check results and review decisions to the correct head.
- Handle timeouts, duplicate delivery, missing replay, subscription expiry and cleanup explicitly.
- Keep test policy, branch protections, sensitive actions and final release authority under human control.
The immediate recommendation is modest: try gh event listen as a bounded waiting primitive for one supervised AI workflow. If access is unavailable, retain a rate-limited state-checking fallback or your existing integration rather than blocking the team. The meaningful upgrade is not that an agent can wait forever. It is that the engineer can delegate the mechanics of waiting, recover the right evidence when work resumes and still make the decision that matters.