gh-image
它能做什么
这个工具可以把你电脑上的图片上传到 GitHub,并生成一个链接,方便在任何地方查看。它适合用来给 GitHub 上的项目添加截图或图片。
适用场景
- ✓当你想在 GitHub 的拉取请求(PR)中添加图片时。
- ✓当你想在 GitHub 的 issue 或评论中加入图片时。
- ✓当你想在 README 文件里展示某个东西的修改前后效果时。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/skills/gh-image/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“把这张截图附加到我的 PR 上。”
每周 5 个新技能,1 分钟读完。
工作原理
这个工具会把图片上传到 GitHub,并返回一个特殊链接。然后,你可以把这个链接插入到想要的位置,比如 PR 描述或评论里。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
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:
- "Attach a screenshot to the PR" or "add an image to the PR description"
- "Put this image in the issue" / "comment with these screenshots"
- "Show the test results / before-and-after in the PR"
- Embed any local image into GitHub Markdown without leaving the terminal
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:

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
- Attach a CleanShot screenshot to PR #42: upload the file, append it under a
## Screenshotsheading in the PR body. - Embed before/after images in a README: upload both, paste the two Markdown lines into the README at the relevant section.
Best Practices
- Resolve globs to absolute paths first; quote paths with spaces/Unicode.
- For display sizing, embed an HTML tag instead of bare Markdown:
<img width="800" src="https://github.com/user-attachments/assets/<uuid>" />. - In CI, set
GH_SESSION_TOKENfrom a dedicated bot account.
Limitations
- Session cookie required. A
user_sessioncookie grants full account access (not scoped like a PAT) — treat it like a password; use a bot account in CI. - Write access to the target repo is required; orgs that enforce SAML SSO need
the session authorized at
https://github.com/orgs/<org>/ssofirst. - Private-repo images stay private: the
user-attachmentsURL inherits repo visibility, so an anonymous fetch on a private repo returns 404/403 by design. - Windows + Chrome 127+ cannot read cookies (library limitation) — use another
browser or
GH_SESSION_TOKEN. - The skill embeds the Markdown itself;
gh-imageonly prints the URL.
常见问题
我的电脑上需要安装 GitHub 吗?
需要。你要先安装 gh 工具并完成配置,这样才能在终端里使用 GitHub。
这个工具怎么知道要上传哪张图片?
你在发出请求时,需要提供图片在电脑上的准确文件路径。
图片存放在哪里?
图片会上传到 GitHub,并与你的仓库可见性设置保持一致。
详情
作者的原始描述
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.
热度
- GitHub 星标
- 48k
- 排名
- #6277
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。