Attach local images or videos (screenshots, recordings) to GitHub issues, pull requests, and comments with `gh --attach`. Use before any `gh issue` or `gh pr` create, edit, or comment that carries a screenshot or recording.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Gh Attach?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/cherryhq-gh-attach)
---
name: gh-attach
description: Attach local images or videos (screenshots, recordings) to GitHub issues, pull requests, and comments with `gh --attach`. Use before any `gh issue` or `gh pr` create, edit, or comment that carries a screenshot or recording.
---
# Attaching Images and Videos to GitHub
`--attach <file>` (gh 2.99+) uploads each file and puts it into the body. It works on
`gh issue create|edit|comment` and `gh pr create|edit|comment`. `gh pr review` has no `--attach`,
so post a review's images in a `gh pr comment`. Each command's `--help` has the flag syntax.
## Check Every File First
**An upload cannot be taken back.** It is public as soon as it finishes, gh has no way to delete
it, and removing its reference from the body leaves the file at its public URL. Editing the issue,
pull request, or comment afterwards does not undo what a screenshot shows. Look at every image
yourself before uploading, and at frames extracted from each GIF or video with ffmpeg. Look for local
context: user names, home-directory paths, conversation or topic titles, browser tabs, other
windows, API keys, email addresses. Crop or recapture a file that shows any of it, or ask the user.
Wherever the user sees the body, in a preview before posting or in the report after it, list each
attachment's path with one line on what it shows.
## Place Files in the Body
Keep the files inside the repository, such as under `.context/verification/`, copying in any file from
elsewhere, and run gh from the repository root. Embed each image where it belongs in the body, and
pass the same file with `--attach`:
```markdown

```
```bash
gh issue create --title "<title>" --body-file "<body_file>" \
--attach ".context/verification/<task>/settings-error.png"
```
Write the same relative path in both places. gh pairs a reference with its file by resolving both
against the directory gh runs in, not the body file's directory. A reference that does not pair
stays a broken local path, and its file is appended to the end of the body instead. A reference
whose upload fails is posted exactly as written, so the path itself must show nothing private, such
as a user name in a home directory.
A video plays only when its reference stands alone in a paragraph. Anywhere else, such as in a table
cell, gh turns it into a link.
## Read the Outcome
Whether a URL reached stdout decides the next step:
- **Non-zero exit, no URL, and one of these errors**: nothing was posted, so retrying is safe.
`unknown flag: --attach` means gh is older than 2.99: ask the user to upgrade gh, or go on
without attachments. `attaching files requires write access to the repository` means the account
lacks `WRITE`, `MAINTAIN`, or `ADMIN` permission: go on without attachments. To go on without
them, remove the image references from the body, post without `--attach`, and tell the user to
drag the files into the issue, pull request, or comment on GitHub.
- **Non-zero exit, no URL, any other error**: the item may exist. `gh issue create`, for one,
creates the issue before it sets the issue type, and prints the URL only after that. Look the
item up by its title before posting again.
- **Non-zero exit, URL printed**: the issue, pull request, or comment exists, but uploads stopped
at the first failure and the remaining references are still local paths. Repair what was posted
instead of posting again, which would leave a duplicate. Pass every file again, since the body
file still holds the local paths:
```bash
gh issue edit "<url>" --body-file "<body_file>" --attach "<file_1>" --attach "<file_2>"
gh pr edit "<url>" --body-file "<body_file>" --attach "<file_1>" --attach "<file_2>"
# a comment: rewrite your last one
gh pr comment "<number>" --edit-last --body-file "<body_file>" --attach "<file_1>"
```