# gh event listen: wait for pull request events instead of polling

> GitHub CLI v2.105.0 adds gh event listen, a preview command built on GitHub Event Streams. It blocks until a pull request gets a review, a state change, a new push, a merge conflict or a completed check suite, then prints the event as JSON, replacing polling loops in scripts and agent workflows. Access needs the Event Streams waitlist.

Published 2026-11-19 by the CodeBeast Team · https://codebeast.ai/blog/gh-event-listen-pull-request-events

GitHub CLI v2.105.0 adds [`gh event listen`](https://cli.github.com/manual/gh_event_listen), which waits for something to happen on a pull request and exits when it does. GitHub's [changelog](https://github.blog/changelog/2026-11-18-wait-for-pull-request-events-with-github-cli) frames it as a way for "you and your agents" to wait for a PR to change with one command instead of polling in a loop. If you have scripts or coding agents that sleep, call `gh pr view`, and sleep again, this is the replacement, with some preview-stage caveats.

## What shipped

The new `gh event` command group sits on top of GitHub Event Streams, which is itself in preview on github.com. It includes:

- `gh event listen`, which creates or reuses a subscription, opens the stream and prints each event to stdout as a single-line CloudEvents JSON object. Status messages go to stderr.
- `gh event subscription create`, `list`, `view` and `delete` for managing subscriptions directly.

By default `listen` exits after the first event, which makes it easy to drop into a script. Other commands now point you to it: `gh pr create`, `gh pr view`, `gh run view`, `gh run watch` and `gh api` suggest `gh event listen` instead of polling.

### Event types

| Event type | Fires when |
|---|---|
| `com.github.pull_request.review.submitted.v1` | A review is submitted |
| `com.github.pull_request.state.changed.v1` | The PR is merged, closed, reopened, marked ready or converted to draft |
| `com.github.pull_request.head.changed.v1` | The head branch changes, for example after a push |
| `com.github.pull_request.merge_conflict.v1` | The PR has a merge conflict |
| `com.github.pull_request.check_suite.status.changed.v1` | A check suite on the head commit completes |

### Flags

| Flag | What it does |
|---|---|
| `--resource <url>` | The pull request URL |
| `--event <type>` | Event type(s) to wait for; repeat the flag or separate with commas |
| `--count <n>` | Exit after this many events |
| `--follow` | Keep listening until stopped |
| `--timeout <duration>` | Give up after this long (`30s`, `10m`), exiting with status 8 |
| `--jq`, `--template` | Extract fields from each event |
| `--subscription <id>` | Reuse an existing subscription |

## Getting access

There are two gates. You need `gh` 2.105.0 or later, and your account needs access to GitHub Event Streams, which is behind a waitlist linked from the changelog. The `gh event` commands are marked as preview and may change.

The manual also says the command only works for pull requests on github.com, not GitHub Enterprise Server or GHE.com. If your code lives on either, keep your polling loop for now.

```bash
gh --version          # needs 2.105.0 or later
gh event listen --help
```

## Practical patterns

### Block until review

The simplest use is a script or agent that opens a PR and then waits for a human:

```bash
PR=https://github.com/OWNER/REPO/pull/123

gh event listen --resource "$PR" \
  --event com.github.pull_request.review.submitted.v1 \
  --timeout 30m
```

On a timeout the exit status is 8, so you can tell "nobody reviewed" apart from other failures:

```bash
gh event listen --resource "$PR" \
  --event com.github.pull_request.review.submitted.v1 --timeout 30m
status=$?
if [ "$status" -eq 8 ]; then
  echo "No review after 30 minutes"
fi
```

### Wait for CI, correctly

A common mistake is to treat one check-suite event as "CI finished". The manual is explicit that a pull request often has several check suites, each sending its own completion event. To wait for all of them, re-read the checks after each event:

```bash
until gh pr checks "$PR" >/dev/null 2>&1; do
  gh event listen --resource "$PR" \
    --event com.github.pull_request.check_suite.status.changed.v1 \
    --timeout 20m || break
done
```

`gh pr checks` exits non-zero while checks are failing or still pending, so this loop also stops on a timeout. Decide what your script should do in each case before relying on it.

### Read state after you subscribe, not before

Events are not replayed. If a review lands between your last `gh pr view` and the moment the stream opens, you won't see it as an event. The manual's advice is to read the current PR state after the status message appears on stderr. The same applies after reconnects: `listen` reconnects if the stream breaks, but events that happen while it is disconnected are lost. Treat events as a "something changed, go look" signal and fetch `data.api_url` or the PR itself for the truth.

### Subscriptions expire

Subscriptions last 24 hours and accounts have a limit on how many they can hold. Long-lived bots that `--follow` many PRs should reuse subscriptions with `--subscription` and clean up with `gh event subscription delete`.

## Why this matters for agent workflows

Coding agents spend a surprising share of their time waiting: for CI, for reviews, for a teammate to resolve a conflict. Polling burns API rate limit and, for agents, tokens and machine time on every check. A blocking command with a timeout and a clear exit code is a better primitive for both shell scripts and agent loops.

It also makes it simple to react to PR events from a script. For example, you could turn a merge conflict into a task for an agent. With a CodeBeast [automation](/docs/automations), each `POST` to its webhook becomes a board task, so a small listener can hand the conflict over:

```bash
EVENT=$(gh event listen --resource "$PR" \
  --event com.github.pull_request.merge_conflict.v1)

curl -X POST "$WEBHOOK_URL" \
  -H "X-Webhook-Secret: $WEBHOOK_SECRET" \
  -H "Idempotency-Key: $(echo "$EVENT" | jq -r .id)" \
  -F "description=Pull request $PR has a merge conflict. Rebase it on the base branch and resolve the conflict."
```

The repository, branch and harness come from the automation's settings, and the [webhook reference](/docs/task-webhook-api) covers the fields and responses.

## Open questions

The preview leaves open which plans get access once the waitlist ends, whether GitHub Enterprise Server and GHE.com will follow, and whether event types beyond pull requests are planned. There is also a small inconsistency in the manual: `--count` is listed with a default of `0`, while the text says the command exits after one event by default. Test that behaviour in your scripts before relying on it.

## Sources

- [GitHub Changelog: Wait for pull request events with GitHub CLI](https://github.blog/changelog/2026-11-18-wait-for-pull-request-events-with-github-cli)
- [GitHub CLI manual: gh event listen](https://cli.github.com/manual/gh_event_listen)

## FAQ

### Which version of GitHub CLI has gh event listen?

GitHub CLI v2.105.0 and later. The `gh event` commands are in preview, and your account also needs access to GitHub Event Streams, which is currently behind a waitlist.

### Does gh event listen work with GitHub Enterprise Server?

No. The manual says it is only available for pull requests on github.com, not on GitHub Enterprise Server or GHE.com. Teams on those deployments still need to poll, for example with `gh pr view` or `gh pr checks`.

### How do I wait for all CI checks on a pull request with gh?

Listen for `com.github.pull_request.check_suite.status.changed.v1` and run `gh pr checks` after each event. Each check suite sends its own completion event, so a single event doesn't mean every check has finished.

### What happens if gh event listen times out?

With `--timeout`, the command exits with status 8 when the time runs out before an event arrives. Scripts can check for that code to tell a timeout apart from an error.
