Home / Market / gh image

gh image

Upload local images to GitHub and get canonical user-attachments embed URLs; use when asked to attach a screenshot to a PR, issue, or comment, or to embed before/after images in a README.

skill★ 508340 dlgithubCC-BY-4.0 content; MIT code; upstream exceptions applyInstall in CosmosUpstream Source

Documentation & Preview

--- name: gh-image description: "Upload local images to GitHub and get canonical user-attachments embed URLs; use when asked to attach a screenshot to a PR, issue, or comment, or to embed before/after images in a README." category: developer-tools risk: critical source: community source_type: community source_repo: drogers0/gh-image date_added: "2026-06-25" author: drogers0 license: MIT license_source: "https://github.com/drogers0/gh-image/blob/main/LICENSE" tags:

tools:

plugin: targets: codex: blocked claude: blocked setup: type: manual summary: "Installs and runs a third-party gh extension that needs a GitHub user_session cookie or GH_SESSION_TOKEN." docs: SKILL.md

---

Upload images to GitHub (gh-image)

GitHub has no public API for image uploads — the web UI uses an internal endpoint that mints user-attachments URLs scoped to the repo's visibility. gh-image (MIT, © drogers0) replicates that flow as a gh CLI extension, so an agent can upload a local image from the terminal and get a ready-to-embed Markdown image line back.

Overview

This skill drives gh-image to turn a local image file into a hosted GitHub user-attachments URL, then embeds that URL into a pull request, issue, or comment. It is the missing "attach a screenshot" capability for terminal agents.

When to Use This Skill

Use this skill when asked to:

How It Works

Step 1: Verify prerequisites

gh auth status                                   # gh installed & authenticated
gh extension list | grep -q 'drogers0/gh-image' \
  || gh extension install drogers0/gh-image      # review/pin the extension source first

gh-image does not use the gh token for the upload (that endpoint rejects tokens). It needs a GitHub user_session cookie, resolved in this order: --token <value> flag → GH_SESSION_TOKEN env var (use in CI/headless) → a logged-in browser's cookie store (default for local use).

Step 2: Upload

# Use an absolute path; --repo is optional inside a repo working dir.
gh image "/abs/path/screenshot.png" --repo <owner>/<repo>

gh image prints Markdown to stdout, one line per image:

![screenshot.png](https://github.com/user-attachments/assets/<uuid>)

Capture that output — it is the embeddable reference.

Step 3: Embed into the PR / issue / comment

MD="$(gh image "/abs/path/shot.png" --repo owner/repo)"
BODY="$(gh pr view <pr> --repo owner/repo --json body -q .body)"
printf '%s\n\n## Screenshots\n\n%s\n' "$BODY" "$MD" \
  | gh pr edit <pr> --repo owner/repo --body-file -

Use gh pr comment, gh issue edit, or gh issue comment with --body-file - for other targets. Always pass --body-file - (not inline --body) so multi-line bodies and special characters can't break shell quoting.

Step 4: Verify

gh pr view <pr> --repo owner/repo --json body -q .body   # confirm URL present

Examples

## Screenshots heading in the PR body.

lines into the README at the relevant section.

Best Practices

<img width="800" src="https://github.com/user-attachments/assets/<uuid>" />.

Limitations

(not scoped like a PAT) — treat it like a password; use a bot account in CI.

the session authorized at https://github.com/orgs/<org>/sso first.

visibility, so an anonymous fetch on a private repo returns 404/403 by design.

browser or GH_SESSION_TOKEN.