pushbag
Developer blog

Attach screenshots and videos to a PR from the CLI

6 min read

Published · Updated

On GitHub.com, attach a local screenshot or recording directly with gh pr comment --attach. Repeat the flag to send both in one comment. From the checkout for the pull request, with the captures in your working directory, run:

gh pr comment --body "Settings now keeps the selected theme after reload." \
  --attach './after-settings.png#Dark theme after reloading settings' \
  --attach ./reload.mp4

GitHub hosts the files and displays the video as a player. A screenshot and a recording for a single conversation usually need nothing else. GitHub CLI 2.99.0 introduced attachments on September 1, 2026 for GitHub.com and GitHub Enterprise Cloud. The same flag works on create, edit, and comment for issues and pull requests. Release notes · Original feature request

Place the captures in a comparison table

First decide what a reviewer should compare. For a layout change, capture the base and head revisions at the same viewport, zoom level, theme, and data state. For a behavior change, show the action and its result. Record enough of the initial state that someone can tell which control you used. Watch the recording through the end before uploading. The last frame often contains the result the reviewer needs to inspect.

Save this as review.md beside the two PNG files. You can edit the descriptions locally, including the alt text that will travel with each image.

The selected theme survives a reload. Both captures use the same account.

| Base branch | Proposed change |
| --- | --- |
| ![Settings reopens in light mode](./before-settings.png) | ![Settings reopens in dark mode](./after-settings.png) |
gh pr comment --body-file review.md \
  --attach ./before-settings.png --attach ./after-settings.png

The body file supplies the Markdown. Each attachment flag supplies a local file. GitHub CLI rewrites the matching paths to uploaded assets. A file that has no reference in the text appears at the end instead. If a screenshot ends up there while the table contains a broken image, compare the path in the table with the file you supplied. With a body file, references resolve relative to its directory first, then to the working directory. A command accepts up to 50 files. GitHub CLI comment manual

Use a comment when you want the discussion to record another round of evidence. If you are preparing the original description, use the same body and flags with gh pr create and supply the PR title. With gh pr edit --body-file, include the complete description, including the test plan and issue references you want to keep. Open the posted result and verify both columns and the recording before asking for review. GitHub CLI PR edit

Review a second revision

Suppose the first recording showed that the theme survives a reload, but review uncovered a similar problem after sign-out. For the next revision, record the sign-out path and label the comment with the short commit ID. Leave the original comparison in the conversation if a reviewer has already referred to it. Readers can then see which behavior each revision demonstrated. If the original description is the only place your team looks for evidence, update its summary and add the new capture there too.

For a test where the screen barely changes, add a sentence explaining what to watch for and when it happens. A caption such as “the selection survives the second reload” tells the reviewer more than the recording filename. Use a screenshot for a static alignment issue. It lets someone inspect the final layout without pausing a recording on one particular frame.

Check the client, host, and account

Run gh --version and gh pr comment --help on the machine that will actually post the comment. The runner image in CI can have an older binary than your laptop. If the help lacks the flag, upgrade the client or use a hosted link. If the target is GitHub Enterprise Server, the attachment feature announced for the cloud service does not cover that host. Use a file host approved for the repository’s data.

Permission to comment can also be insufficient. The CLI attachment implementation checks for write, maintain, or admin access to the target repository. For a user with read or triage access, the CLI error is attaching files requires write access to the repository. Owning the source fork does not grant write access upstream. Check the permission on the upstream repository before debugging the media encoder. Outside reporters can use a hosted URL in their comment. GitHub CLI permission check · GitHub CLI permission report

Share evidence that lives outside the PR

An HTML accessibility report with expandable details makes a poor screenshot. Attach a PNG if it explains the fix at a glance, then link the actual report so a reviewer can inspect individual findings. HTML isn’t an input to the media flag. Publish a self-contained document with an Artifacts key:

pushbag upload review.html --public --json > review-upload.json
jq -er '.[0].versionUrl' review-upload.json

Copy that URL into the description and label the link with the revision or test run. Use the numbered version when the exact evidence matters. A subsequent upload to the same artifact changes its root URL’s contents while the numbered URL still selects the original version, subject to retention and access. This also gives a GitLab or Bitbucket review, a Linear issue, and a Slack conversation one address for the same evidence. A plain hyperlink works without relying on the destination to embed HTML or play the video inline.

For external image and video artifacts, choose a plan that supports those file types. To preview a public recording in Markdown, link a still frame to the video using the version URL of each. A reviewer can identify the screen before opening a new tab. For internal captures, consider who can fetch the file independently of the repository. Making a hosted image public just to get a thumbnail can expose the entire capture.

Publish a sensitive report with --private instead. Use a text link for the signed-in owner. Another reviewer needs a deliberately shared, short-lived grant from pushbag open ARTIFACT_ID. Anyone who receives the grant can use it until expiry, so choose its audience separately from the audience for the PR. For a permanent discussion record, keep the version link and arrange access separately. Privacy and versions · PR media workflows · Comparing HTML hosts

Frequently asked questions

Can gh place each screenshot beside its caption?

Yes. Reference the local files in the Markdown body and pass each file to --attach. The CLI rewrites matching references after uploading.

Can I use a recording without making a poster?

Yes. GitHub renders a natively attached video as a player. A poster is an option for a recording hosted elsewhere.

Does a PR in a private repository make an external image private?

The host controls access to the external file. A public artifact linked from a private PR still has a public URL.