1
---
2
name: pr-screenshots
3
description: '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.'
4
---
5
6
# PR Screenshots
7
8
Embed before/after screenshots in pull request descriptions so reviewers can see the visual change without checking out the branch.
9
10
## When to Use This Skill
11
12
Use this skill when a PR changes something visible:
13
14
- Layout, styling, CSS
15
- Charts, dashboards, data visualizations
16
- UI components, forms, modals
17
- Error messages, CLI output, log formatting
18
19
## PR Description Pattern
20
21
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.
22
23
```markdown
24
**Before** — brief description of the problem:
25
26

27
28
**After** — brief description of the fix:
29
30

31
```
32
33
Keep the text brief. A sentence or two per image describing what the reader should notice. Let the image carry most of the communication.
34
35
### Multiple changes
36
37
For PRs with several visual changes, use separate before/after pairs with headings:
38
39
```markdown
40
## Filter bar alignment
41
42
**Before** — 1px border clash between adjacent buttons:
43
44

45
46
**After** — borders overlap cleanly, hover tint added:
47
48

49
50
## Chart tooltip
51
52
**Before** — tooltip clipped at container edge:
53
54

55
56
**After** — tooltip repositions to stay visible:
57
58

59
```
60
61
## Image Sizing
62
63
- **Take screenshots at native 1x resolution** — don't resize with PIL (creates artifacts)
64
- **Control display size in HTML** when images are too large:
65
```html
66
<img src="url" width="600" alt="description">
67
```
68
- **Before/after pairs must use the same viewport width and crop** — otherwise the comparison is meaningless
69
70
## Uploading Images
71
72
### Azure DevOps
73
74
Upload images as PR attachments via the REST API:
75
76
```powershell
77
$token = az account get-access-token `
78
--resource "499b84ac-1321-427f-aa17-267ca6975798" `
79
--query accessToken -o tsv
80
81
$base = "https://{org}.visualstudio.com/{projectId}/_apis/git/repositories/{repoId}"
82
$url = "$base/pullRequests/{prId}/attachments/screenshot.png?api-version=7.1-preview.1"
83
84
# Use HttpClient — Invoke-RestMethod can corrupt binary data
85
$client = New-Object System.Net.Http.HttpClient
86
$client.DefaultRequestHeaders.Authorization = `
87
New-Object System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", $token)
88
$content = New-Object System.Net.Http.ByteArrayContent(
89
, [System.IO.File]::ReadAllBytes("screenshot.png")
90
)
91
$content.Headers.ContentType = `
92
[System.Net.Http.Headers.MediaTypeHeaderValue]::new("application/octet-stream")
93
$resp = $client.PostAsync($url, $content).Result
94
```
95
96
Reference in the PR description:
97
98
```markdown
99

100
```
101
102
**Azure DevOps gotchas:**
103
104
- **Use `{org}.visualstudio.com` NOT `dev.azure.com/{org}`** — AzDO's markdown renderer uses `.visualstudio.com`. The `dev.azure.com` format loads noticeably slower
105
- Use `POST` not `PUT` (PUT returns 405)
106
- API version must be `7.1-preview.1`
107
- Can't re-upload with the same filename — use a new name (e.g. `screenshot-v2.png`)
108
- Use `HttpClient` not `Invoke-RestMethod` — IRM can corrupt binary data
109
- Repo-relative paths don't work in PR descriptions — must use full URLs
110
- Don't commit images to the branch just for PR screenshots
111
112
### GitHub
113
114
> **⚠️ 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.
115
116
**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.
117
118
## Guidelines
119
120
1. **Capture before state BEFORE making changes** — it's easy to forget, and reconstructing the original state later is slow and error-prone
121
2. **Keep descriptions brief** — a sentence or two per image pointing out what changed is enough
122
3. **Prefer visible images over collapsed sections** — screenshots behind `<details>` tags are easy to skip
123
4. **Annotate when the change is subtle** — use the `image-annotations` skill to add callouts when the difference isn't immediately obvious
124
5. **Match viewport and crop** between before/after pairs so the comparison is meaningful
125
126
## Limitations
127
128
- GitHub image upload requires workarounds (no public API for PR description images)
129
- Azure DevOps attachment filenames can't be reused — plan naming ahead
130
- Very large images (>10MB) may not render inline on some platforms
131