Generated banner for Gh Attach
Generated logo for Gh Attach

Gh Attach

GitHubOfficialFirst committed by sudosubinDistributed by GitHub

  • Skill
  • Tool integration
  • Software development
  • MIT
  • No issues found

From the author

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`.
— the description by sudosubin

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

gh-attach is a tool that bridges the gap between local files and GitHub's internal user-attachments system. It allows users to upload various file types like images, PDFs, and videos to GitHub, receive a renderable URL, and embed these files directly into GitHub issues, pull requests, or comments. The tool handles the complexities of GitHub's attachment endpoints, ensuring that files uploaded to private repositories remain private and accessible only to authorized users.

What it does

  • Uploads local files to GitHub user-attachments and returns a shareable URL.
  • Downloads existing GitHub attachments to a local destination.
  • Supports embedding uploaded files into PRs, issues, or comments via standard CLI commands.
  • Handles authentication through browser session cookies or environment variables.
  • Supports repository-specific uploads and GitHub Enterprise Server configurations.

When to use it

  • When you need to attach screenshots or logs to a pull request for review.
  • When you want to add visual documentation or media to a GitHub issue.
  • When you need to retrieve a file that was previously attached to a GitHub discussion.
  • When you need to include before-and-after visual comparisons in your development workflow.

Advantages

  • Enables direct integration of local media into GitHub's web interface.
  • Maintains repository privacy settings for all uploaded attachments.
  • Automates the process of generating renderable URLs for GitHub comments.
  • Provides a consistent command-line interface for managing file attachments.

Usage examples

“Attach the screenshot located at ./debug.png to pull request #123 in my repository.”
The agent uploads the image, receives the GitHub attachment URL, and posts it as a comment on the specified pull request.
“Download the attachment from this URL to my local folder as report.pdf.”
The agent uses the tool to fetch the file from the provided GitHub attachment URL and saves it locally as report.pdf.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/github/gh-attach/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip gh-attach.zip -d .agents/skills

Documentation by sudosubin

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

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:

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

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

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:

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.

Files

Requirements and compatibility

Written for: GitHub Copilot

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs a command-line tool

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

First committed by
GitHub avatar of sudosubinsudosubin
Publisher
GitHub (Official)
Distributed by
GitHub
Source
github/awesome-copilot · skills/gh-attach · commit 797337f
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced
Contributors
sudosubin

AutoGineer is not affiliated with or endorsed by sudosubin or GitHub.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download gh-attach.zip