Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)40k · #7342

pr-screenshots

Skill này làm gì

Công cụ này giúp thể hiện trực quan một thay đổi trong dự án mã. Bạn có thể thêm ảnh 'trước' và 'sau' vào mô tả cập nhật mã để người khác dễ hiểu thay đổi hơn.

Khi nào nên dùng

  • ✓Khi bạn thay đổi giao diện của một website (màu sắc, nút bấm, v.v.).
  • ✓Khi bạn tạo biểu đồ hoặc hiển thị dữ liệu trực quan.
  • ✓Khi bạn sửa một lỗi xuất hiện trên màn hình.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/github/awesome-copilot/blob/main/skills/pr-screenshots/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Thêm ảnh trước và sau để thể hiện thay đổi bố cục của nút này.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Bạn chèn ảnh trực tiếp vào mô tả cập nhật mã. Với các nền tảng như Azure DevOps, có cách tải ảnh lên bằng mã riêng. Với GitHub, cách dễ nhất là thêm ảnh vào một vị trí riêng rồi tham chiếu đến chúng.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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

…

Câu hỏi thường gặp

Vì sao việc thể hiện 'trước' và 'sau' lại quan trọng?

Điều này giúp người review mã thấy chính xác cái gì đã thay đổi mà không phải tự kiểm thử mọi thứ, làm việc review nhanh và hiệu quả hơn.

Điều gì xảy ra nếu ảnh quá lớn?

Ảnh quá lớn có thể không hiển thị đúng trên một số nền tảng. Nên kiểm soát kích thước để ảnh vừa khít màn hình.

Tôi có thể dùng tên tệp ảnh bất kỳ trên Azure DevOps không?

Không, bạn không thể dùng lại cùng một tên tệp để tải ảnh lên lần nữa. Bạn cần dùng một tên mới mỗi lần.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
40k
Vị trí xếp hạng
#7342
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự