Skip to content
gh --attach or uploads

gh --attach or uploads

Two ways to let a coding agent put screenshots on a pull request.

The short version #

GitHub CLI 2.99 added an --attach flag that uploads a local image or video to an issue, pull request, or comment. For an agent with a shell, gh, and push access, it is the simplest way to put one screenshot on an open pull request.

uploads covers the cases the flag does not:

  • The agent has no shell or no gh. It uploads through the MCP server.
  • The screenshots exist before the pull request does.
  • The pull request should have one comment that updates as the branch changes.
  • The file is a PDF, a log, or a zip.
  • The same setup has to work in several agents and in CI.

Side by side #

gh --attach uploads
Agent needs A shell and gh 2.99 or newer An MCP client, or a shell with the uploads CLI
Sign-in gh auth login, or a classic personal access token An uploads sign-in or token. No GitHub token
Repository access Push access Any repo you can comment on, by pasting the Markdown
Before the PR exists Keep the files on disk until gh pr create Stage on the branch. Posted when the PR opens
Later revisions Each attach adds a new image Same file name replaces the image. One comment updates
File types Images and video Images, video, PDF, zip, and text files such as logs
Image size 10 MB Set by the plan. See limits
Who can view the file In a private repo, people with repository access Anyone with the URL
Video in the PR Plays inline Poster image that links to a player page

The gh rows come from GitHub’s changelog and docs.

When gh --attach is enough #

Use the flag when all of these are true:

  • The agent runs where gh 2.99 or newer is installed and signed in.
  • The pull request or issue is already open, or the agent attaches as it creates it.
  • The files are images or video.

It is also the right choice when a screenshot from a private repository must stay private. GitHub serves those attachments only to people with access to the repository. uploads files are public to anyone with the URL.

gh pr comment 123 --body "Settings page after the change" --attach ./after.png

When to use uploads #

The agent has no shell, or no gh. --attach is a CLI flag. GitHub has no public API for attachments, and the GitHub MCP server has no upload tool. The uploads MCP server works in any MCP client, including cloud agents.

The agent’s GitHub token is not a user token. GitHub lists two token types for --attach: the OAuth token from gh auth login and a classic personal access token. uploads signs in with its own token, so it does not depend on which GitHub token the agent or CI job holds.

Screenshots come before the pull request. An agent captures as it works. uploads stages each file on the branch and posts them all when the pull request opens. See Attach artifacts to pull requests.

The branch keeps changing. Uploading the same file name again replaces the image in place, and one attachments comment lists the current set with before and after pairs.

Reviewers need more than images. PDFs, logs, CSV, JSON, and zip files go in the same comment. See files in pull requests.

You want the screenshots outside the pull request. Every file has a public URL you can paste anywhere, and your workspace keeps them searchable.

Using both #

The two work together. With the uploads GitHub App installed, an image or video attached with gh --attach is imported into your workspace. It shows up in search and in the pull request’s attachments comment next to files the agent uploaded.

Set up an agent with the CLI: Coding agents →

FAQ #

How do I give a coding agent the ability to upload screenshots to GitHub?
If the agent has a shell with GitHub CLI 2.99 or newer and push access to the repository, it can run gh pr comment with --attach. If it has no shell or no gh, or it takes screenshots before the pull request exists, connect the uploads MCP server at agents.uploads.sh/mcp or install the uploads CLI.
Does gh --attach work in a cloud agent or over MCP?
Only if the agent can run gh 2.99 or newer with an OAuth token or a classic personal access token. It is a CLI flag, not an API, so the GitHub MCP server does not have it.
Are images attached with gh --attach private?
They follow GitHub's rules for attachments, so an image attached in a private repository needs repository access to view. Files uploaded with uploads are public to anyone with the URL.
Can I use gh --attach and uploads in the same repository?
Yes. With the uploads GitHub App installed, images and video attached with gh --attach are imported into your workspace and listed in the pull request's attachments comment.