Skip to main content
skill GitHub Copilot official · GitHub

gh-attach — GitHub Copilot skill: what it does, how to install

Uploads local files to GitHub attachments, embeds them in PRs, issues, and comments, and downloads existing attachments.

Install into GitHub Copilot · Skills CLI (Vercel) All methods and platforms ↓
npx skills add github/awesome-copilot --skill gh-attach
Open on GitHub

What gh-attach does

This skill uses the gh-attach extension to upload screenshots, images, PDF files, archives, and video to GitHub user-attachments. It returns a URL that GitHub renders when pasted into a PR, issue, or comment.

Uploads require an absolute quoted file path. The -R option is optional inside a repository, while GHES uses a server, owner, and repository value. To post an attachment in a comment, the flow uses --body-file -; downloads save to an explicitly chosen destination.

Uploading relies on a browser session cookie rather than the gh token. GH_ATTACH_SESSION_TOKEN carries full account credentials, so treat it as a sensitive secret. Attachments from private repositories remain visible only to authorised viewers.

What it helps with

  • attach a screenshot to a PR
  • add an image to a GitHub issue
  • post before-and-after screenshots in a comment
  • upload a PDF or archive as a GitHub attachment
  • download an attached GitHub file

Example prompts for the agent

  • Attach this screenshot to the PR.
  • Add this image to the GitHub issue comment.
  • Download this GitHub attachment to the selected file.

How to install gh-attach

1Skills CLI (Vercel)

npx skills add github/awesome-copilot --skill gh-attach

2GitHub CLI

gh skill install github/awesome-copilot gh-attach

3Manually: put the files in place

.github/skills/gh-attach/SKILL.md

From the same set554

The whole set →
git-commit official github This skill reviews Git changes, stages related files, and creates Conventional Commits. Use it when you want an agent to make one commit or split work into separate commits. GitHub Copilot 47,165installs excalidraw-diagram-generator official github Turn a plain-language description into an Excalidraw diagram. Useful for mapping processes, system structure, and relationships between entities. GitHub Copilot 31,639installs multi-stage-dockerfile official github This skill guides GitHub Copilot in writing multi-stage Dockerfiles for different languages and frameworks. Use it when the final runtime image should contain fewer build dependencies. GitHub Copilot 29,688installs documentation-writer official github Skill that turns the agent into a technical writer following the Diátaxis framework: tutorials, how-to guides, reference, and explanation. Proposes structure before writing. GitHub Copilot 27,757installs prd official github Turns a feature idea into a structured PRD with user stories, technical requirements, and risks. Use it when planning a software feature or an AI-powered one. GitHub Copilot 24,035installs refactor official github This skill reshapes existing code without changing its external behavior. Use it for gradual cleanup of large functions, duplication, weak types, and code smells. GitHub Copilot 22,321installs java-springboot official github Gives GitHub Copilot Spring Boot development practices, from project layout to tests and security. Use it when writing or reviewing Java application code. GitHub Copilot 21,272installs create-readme official github This skill reviews a project and creates a structured README.md. Use it when the repository needs clear documentation based on its actual files and code. GitHub Copilot 19,081installs

Similar

Questions about gh-attach

How do I install gh-attach in GitHub Copilot?

Run npx skills add github/awesome-copilot --skill gh-attach, then gh skill install github/awesome-copilot gh-attach. The skill file is located at .github/skills/gh-attach/SKILL.md.

What does gh-attach do?

The skill uploads local files to GitHub user-attachments, returns their URLs, and embeds those URLs in PRs, issues, or comments. It can also download GitHub attachments.

What authentication does gh-attach use for uploads?

gh-attach uses a browser session cookie instead of the gh token. For headless use, set GH_ATTACH_SESSION_TOKEN to the user_session cookie value.

Source text

SKILL.md · MIT
---
name: gh-attach
description: 'Uploads a local file (screenshot, image, PDF, zip, video) to GitHub user-attachments, downloads GitHub user-attachments, and embeds local files in a PR, issue, or comment. Use when asked to "attach a screenshot to the PR", "add an image to the issue", "embed before/after screenshots", "attach this file", or "download this GitHub attachment". Powered by `gh-attach`.'
---

# gh-attach

`gh attach` uploads a file to GitHub's internal user-attachments endpoint (no public API exists) and prints the URL, which GitHub auto-renders (image/video/file) wherever it's pasted. The URL inherits the repo's visibility, so private-repo uploads stay private.

## Prerequisites

```sh
gh extension list | grep -q 'gh attach' || gh extension install sudosubin/gh-attach
```

Uploads use a GitHub browser session cookie, not the `gh` token. By default, `gh` must be authenticated so `gh-attach` can select the matching browser account. If the wrong account is selected, add `--browser <name> --profile <name>`. For headless use, set `GH_ATTACH_SESSION_TOKEN` to the bare `user_session` cookie value. Treat it as a full account credential.

## Steps

**1. Upload**: Use an absolute quoted path. `-R` is optional inside a repository. For GHES, use `-R host/owner/repo`. The command prints the URL on one line. GitHub auto-renders it (image/video/file), so use it as-is:

```sh
URL=$(gh attach "$FILE" -R <owner>/<repo>)
```

**2. Embed** (always `--body-file -`, e.g. `gh pr comment/edit`, `gh issue comment/edit`):

```sh
printf '## Screenshots\n\n%s\n' "$URL" | gh pr comment <pr> -R <owner>/<repo> --body-file -
```

**3. Download**: Specify the destination explicitly. Private attachments use the active `gh` token, with browser cookies as an authorization fallback:

```sh
gh attach download "$URL" -O "$FILE"
```

## Notes

- Private repo: URL renders only for authorized viewers. An anonymous fetch is expected to return 404 or 403.
- Sizing: embed `<img width="800" src="$URL">` instead of the bare URL.
- GitHub Cloud and GHES decide which file extensions and content types they accept.

© github · MIT · github/awesome-copilot

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor