跳到正文
Skillpedia
部署与云(DevOps)40k · #7342

pr-screenshots

它能做什么

这个工具可以帮你在代码项目中直观展示界面的变化。你可以在代码更新的描述中加入“修改前”和“修改后”的图片,让其他人更容易理解改动内容。

适用场景

  • ✓当你修改了网站外观(比如颜色、按钮等)的时候。
  • ✓当你制作图表或以可视化方式展示数据的时候。
  • ✓当你修复了屏幕上出现的错误的时候。

技能链接

https://github.com/github/awesome-copilot/blob/main/skills/pr-screenshots/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/github/awesome-copilot/blob/main/skills/pr-screenshots/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“添加修改前和修改后的图片,展示这个按钮的布局变化。”

每周 5 个新技能,1 分钟读完。

工作原理

你可以直接把图片插入到代码更新的描述中。对于 Azure DevOps 这类平台,有专门通过代码上传图片的方法。对于 GitHub 来说,最简单的方式是把图片放到另一个位置,然后在描述中引用它们。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

PR Screenshots

Embed before/after screenshots in pull request descriptions so reviewers can see the visual change without checking out the branch.

When to Use This Skill

Use this skill when a PR changes something visible:

  • Layout, styling, CSS
  • Charts, dashboards, data visualizations
  • UI components, forms, modals
  • Error messages, CLI output, log formatting

PR Description Pattern

Place screenshots directly in the PR description body. Avoid wrapping them in <details> collapse — reviewers are more likely to look at images they can see without clicking.

**Before** — brief description of the problem:

![before](url-to-before-image)

**After** — brief description of the fix:

![after](url-to-after-image)

Keep the text brief. A sentence or two per image describing what the reader should notice. Let the image carry most of the communication.

Multiple changes

For PRs with several visual changes, use separate before/after pairs with headings:

## Filter bar alignment

**Before** — 1px border clash between adjacent buttons:

![before-filters](url)

**After** — borders overlap cleanly, hover tint added:

![after-filters](url)

## Chart tooltip

**Before** — tooltip clipped at container edge:

![before-tooltip](url)

**After** — tooltip repositions to stay visible:

![after-tooltip](url)

Image Sizing

  • Take screenshots at native 1x resolution — don't resize with PIL (creates artifacts)
  • Control display size in HTML when images are too large:
    <img src="url" width="600" alt="description">
    
  • Before/after pairs must use the same viewport width and crop — otherwise the comparison is meaningless

Uploading Images

Azure DevOps

Upload images as PR attachments via the REST API:

$token = az account get-access-token `
    --resource "499b84ac-1321-427f-aa17-267ca6975798" `
    --query accessToken -o tsv

$base = "https://{org}.visualstudio.com/{projectId}/_apis/git/repositories/{repoId}"
$url = "$base/pullRequests/{prId}/attachments/screenshot.png?api-version=7.1-preview.1"

# Use HttpClient — Invoke-RestMethod can corrupt binary data
$client = New-Object System.Net.Http.HttpClient
$client.DefaultRequestHeaders.Authorization = `
    New-Object System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", $token)
$content = New-Object System.Net.Http.ByteArrayContent(
    , [System.IO.File]::ReadAllBytes("screenshot.png")
)
$content.Headers.ContentType = `
    [System.Net.Http.Headers.MediaTypeHeaderValue]::new("application/octet-stream")
$resp = $client.PostAsync($url, $content).Result

Reference in the PR description:

![description](https://{org}.visualstudio.com/{projectId}/_apis/git/repositories/{repoId}/pullRequests/{prId}/attachments/screenshot.png)

Azure DevOps gotchas:

  • Use {org}.visualstudio.com NOT dev.azure.com/{org} — AzDO's markdown renderer uses .visualstudio.com. The dev.azure.com format loads noticeably slower
  • Use POST not PUT (PUT returns 405)
  • API version must be 7.1-preview.1
  • Can't re-upload with the same filename — use a new name (e.g. screenshot-v2.png)
  • Use HttpClient not Invoke-RestMethod — IRM can corrupt binary data
  • Repo-relative paths don't work in PR descriptions — must use full URLs
  • Don't commit images to the branch just for PR screenshots

GitHub

⚠️ Work in progress. GitHub's drag-and-drop image upload uses internal endpoints that require browser cookies. There's no clean public API for uploading images to PR descriptions yet.

Current workaround: Commit images to a pr-assets orphan branch and reference via blob URLs (github.com/{owner}/{repo}/blob/pr-assets/{file}?raw=true). It works but is clunky — contributions for a better approach are welcome.

Guidelines

  1. Capture before state BEFORE making changes — it's easy to forget, and reconstructing the original state later is slow and error-prone
  2. Keep descriptions brief — a sentence or two per image pointing out what changed is enough
  3. Prefer visible images over collapsed sections — screenshots behind <details> tags are easy to skip
  4. Annotate when the change is subtle — use the image-annotations skill to add callouts when the difference isn't immediately obvious
  5. Match viewport and crop between before/after pairs so the comparison is meaningful

Limitations

…

常见问题

为什么要展示“修改前”和“修改后”?

这能帮助代码审阅者一眼看出具体改动了什么,无需自己把所有功能都测试一遍,从而让审阅更快、更高效。

如果图片太大会怎么样?

在某些平台上,非常大的图片可能无法正常显示。最好控制一下图片尺寸,让它们在屏幕上显示得恰到好处。

在 Azure DevOps 中,图片可以随便起文件名吗?

不可以。你不能重复使用同一个文件名再次上传图片,每次都需要使用新的名字。

详情

作者的原始描述

Embed before/after screenshots and annotated images in pull request descriptions. Covers PR description patterns, image upload for Azure DevOps and GitHub, and sizing best practices.

repo: github/awesome-copilot

热度

GitHub 星标
40k
排名
#7342
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能