github-pr-screenshot-embed
Use when embedding a screenshot or image in a GitHub PR description or comment, especially for a PRIVATE repo. Fire when the user says "the screenshot is a broken image in the PR", "embed this in the PR", "the image doesn't render for reviewers", "add a before/after image to the PR", or when a raw.githubusercontent.com link shows as a broken image. Skip for GitLab MRs: GitLab rewrites uploaded paths differently and needs its own upload step.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- github-pr-screenshot-embed
- description
- Use when embedding a screenshot or image in a GitHub PR description or comment, especially for a PRIVATE repo. Fire when the user says "the screenshot is a broken image in the PR", "embed this in the PR", "the image doesn't render for reviewers", "add a before/after image to the PR", or when a raw.githubusercontent.com link shows as a broken image. Skip for GitLab MRs: GitLab rewrites uploaded paths differently and needs its own upload step.
02 资源文件 1
- 参考文档README.md2.3 KB
03 SKILL.md 正文
Embed screenshots in a GitHub PR (private repos)
Private-repo image embeds break in one specific, silent way: the image host you pick decides whether the browser can authenticate. Get the host wrong and every reviewer sees a broken-image icon while the link looks correct to you (your browser is already authenticated).
The rule: use github.com/<owner>/<repo>/raw/<sha>/<path>, pinned to a commit
SHA. GitHub authenticates that host with the reader's browser cookies, so
anyone with repo access renders it.
Procedure
1. Commit the image into the PR branch
Commit the screenshot into the repo (e.g. under docs/screenshots/) on the PR
branch and push. You need its path and the commit SHA that contains it:
git rev-parse HEAD # the SHA to pin
2. Build the embed URL
https://github.com/<owner>/<repo>/raw/<sha>/<path-to-image>
Use it in standard markdown in the PR description or comment:
| Before | After |
|---|---|
|  |  |
Never use raw.githubusercontent.com for a private repo. That host is
token-authenticated only and never receives browser cookies, so the embed is a
broken image for every reader even though it resolves for you via a token.
3. Pin the SHA, never the branch
Use the commit SHA in the path, not the branch name. A squash-merge deletes the
branch, which 404s every branch-pinned URL, but the PR's head commit stays
reachable via refs/pull/<n>/head indefinitely, so a SHA-pinned embed
survives.
4. Verify
Two checks are runnable without a second account:
n=$(gh pr view --json number -q .number) # from the PR branch
git cat-file -e <sha>:<path-to-image> # the blob exists at the pinned SHA
gh pr view "$n" --json body -q .body | grep -c raw.githubusercontent.com # must be 0
If a reviewer still reports a broken image after both pass, ask them for the failing URL: a host or SHA typo survives every local check.
When to STOP
- The screenshot shows real customer data, real balances, KYC documents, or auth tokens. Committing an image into a repo is a durable publication: surface the concern and propose a redacted re-capture before committing.
- The repo is public and you were about to over-engineer: a plain committed image or a drag-and-drop attachment is fine; this skill's host nuance only matters for private repos.
- The user wants a drag-and-drop attachment via
gh. It is not possible: thePOST /upload/policies/assetsendpoint 422s without a real browser session, so the attachment CDN is unreachable from the CLI. Commit the image and reference it by SHA instead.