GitHub Skill
Use these scripts instead of raw gh commands for consistent error handling and structured output.
Triggers
| Phrase |
Operation |
get PR context for #123 |
Get-PRContext.ps1 |
respond to review comments |
Post-PRCommentReply.ps1 |
check CI status |
Get-PRChecks.ps1 |
add label to issue |
Set-IssueLabels.ps1 |
assign milestone |
Set-ItemMilestone.ps1 |
Decision Tree
Need GitHub data?
├─ List PRs (filtered) → Get-PullRequests.ps1
├─ PR info/diff → Get-PRContext.ps1
├─ CI check status → Get-PRChecks.ps1
├─ CI failure logs → Get-PRCheckLogs.ps1
├─ Review comments → Get-PRReviewComments.ps1
├─ Review threads → Get-PRReviewThreads.ps1
├─ Unique reviewers → Get-PRReviewers.ps1
├─ Unaddressed bot comments → Get-UnaddressedComments.ps1
├─ PR merged check → Test-PRMerged.ps1
├─ Copilot follow-up PRs → Detect-CopilotFollowUpPR.ps1
├─ Issue info → Get-IssueContext.ps1
├─ Merge readiness check → Test-PRMergeReady.ps1
├─ Latest milestone → Get-LatestSemanticMilestone.ps1
└─ Need to take action?
├─ Create issue → New-Issue.ps1
├─ Create PR → New-PR.ps1
├─ Reply to review → Post-PRCommentReply.ps1
├─ Reply to thread (GraphQL) → Add-PRReviewThreadReply.ps1
├─ Comment on issue → Post-IssueComment.ps1
├─ Add reaction → Add-CommentReaction.ps1
├─ Apply labels → Set-IssueLabels.ps1
├─ Set issue milestone → Set-IssueMilestone.ps1
├─ Set PR/issue milestone (auto-detect) → Set-ItemMilestone.ps1
├─ Assign issue → Set-IssueAssignee.ps1
├─ Resolve threads → Resolve-PRReviewThread.ps1
├─ Process AI triage → Invoke-PRCommentProcessing.ps1
├─ Assign Copilot → Invoke-CopilotAssignment.ps1
├─ Enable/disable auto-merge → Set-PRAutoMerge.ps1
├─ Close PR → Close-PR.ps1
└─ Merge PR → Merge-PR.ps1
Script Reference
PR Operations (scripts/pr/)
| Script |
Purpose |
Key Parameters |
Get-PullRequests.ps1 |
List PRs with filters |
-State, -Label, -Author, -Base, -Head, -Limit |
Get-PRContext.ps1 |
PR metadata, diff, files |
-PullRequest, -IncludeChangedFiles, -IncludeDiff |
Get-PRChecks.ps1 |
CI check status, polling |
-PullRequest, -Wait, -TimeoutSeconds, -RequiredOnly |
Get-PRCheckLogs.ps1 |
Fetch logs from failing CI checks |
-PullRequest, -MaxLines, -ContextLines |
Get-PRReviewComments.ps1 |
Paginated review comments with stale detection |
-PullRequest, -IncludeIssueComments, -DetectStale, -ExcludeStale, -OnlyStale |
Get-PRReviewThreads.ps1 |
Thread-level review data |
-PullRequest, -UnresolvedOnly |
Get-PRReviewers.ps1 |
Enumerate unique reviewers |
-PullRequest, -ExcludeBots |
Get-UnaddressedComments.ps1 |
Bot comments needing attention |
-PullRequest |
Get-UnresolvedReviewThreads.ps1 |
Unresolved thread IDs |
-PullRequest |
Test-PRMerged.ps1 |
Check if PR is merged |
-PullRequest |
Detect-CopilotFollowUpPR.ps1 |
Detect Copilot follow-up PRs |
-PRNumber, -Owner, -Repo |
Post-PRCommentReply.ps1 |
Thread-preserving replies |
-PullRequest, -CommentId, -Body |
Add-PRReviewThreadReply.ps1 |
Reply to thread by ID (GraphQL) |
-ThreadId, -Body, -Resolve |
Resolve-PRReviewThread.ps1 |
Mark threads resolved |
-ThreadId or -PullRequest -All |
Unresolve-PRReviewThread.ps1 |
Mark threads unresolved |
-ThreadId or -PullRequest -All |
Get-ThreadById.ps1 |
Get single thread by ID |
-ThreadId |
Get-ThreadConversationHistory.ps1 |
Full thread comment history |
-ThreadId, -IncludeMinimized |
Test-PRMergeReady.ps1 |
Check merge readiness |
-PullRequest, -IgnoreCI, -IgnoreThreads |
Set-PRAutoMerge.ps1 |
Enable/disable auto-merge |
-PullRequest, -Enable/-Disable, -MergeMethod |
Invoke-PRCommentProcessing.ps1 |
Process AI triage output |
-PRNumber, -Verdict, -FindingsJson |
New-PR.ps1 |
Create PR with validation |
-Title, -Body, -Base |
Close-PR.ps1 |
Close PR with comment |
-PullRequest, -Comment |
Merge-PR.ps1 |
Merge with strategy |
-PullRequest, -Strategy, -DeleteBranch, -Auto |
Issue Operations (scripts/issue/)
| Script |
Purpose |
Key Parameters |
Get-IssueContext.ps1 |
Issue metadata |
-Issue |
New-Issue.ps1 |
Create new issue |
-Title, -Body, -Labels |
Set-IssueLabels.ps1 |
Apply labels (auto-create) |
-Issue, -Labels, -Priority |
Set-IssueMilestone.ps1 |
Assign milestone |
-Issue, -Milestone |
Post-IssueComment.ps1 |
Comments with idempotency |
-Issue, -Body, -Marker |
Invoke-CopilotAssignment.ps1 |
Synthesize context for Copilot |
-IssueNumber, -WhatIf |
Set-IssueAssignee.ps1 |
Assign users to issues |
-Issue, -Assignees |
Milestone Operations (scripts/milestone/)
| Script |
Purpose |
Key Parameters |
Get-LatestSemanticMilestone.ps1 |
Detect latest semantic version milestone |
-Owner, -Repo |
Set-ItemMilestone.ps1 |
Assign milestone to PR/issue (auto-detect) |
-ItemType, -ItemNumber, -MilestoneTitle |
Reactions (scripts/reactions/)
| Script |
Purpose |
Key Parameters |
Add-CommentReaction.ps1 |
Add emoji reactions (batch support) |
-CommentId[], -Reaction, -CommentType |
Output Format
All scripts output structured JSON with Success boolean:
$result = pwsh -NoProfile scripts/pr/Get-PRContext.ps1 -PullRequest 50 | ConvertFrom-Json
if ($result.Success) { ... }
Process
This skill provides a toolkit of PowerShell scripts for GitHub operations. Use scripts directly or compose them into workflows.
Basic Usage:
- Identify the operation needed using the Decision Tree
- Find the corresponding script in the Script Reference
- Call the script with required parameters
- Parse the JSON output and check
Success field
Example Flow:
# Get PR context
$pr = pwsh scripts/pr/Get-PRContext.ps1 -PullRequest 123 | ConvertFrom-Json
# Check CI status
$checks = pwsh scripts/pr/Get-PRChecks.ps1 -PullRequest 123 | ConvertFrom-Json
# Add comment if needed
if ($checks.FailedCount -gt 0) {
pwsh scripts/pr/Post-PRCommentReply.ps1 -PullRequest 123 -Body "CI failures detected"
}
Anti-Patterns
| Avoid |
Why |
Instead |
Raw gh pr view commands |
No structured output |
Use Get-PRContext.ps1 |
Raw gh api for comments |
Doesn't preserve threading |
Use Post-PRCommentReply.ps1 |
| Replying to thread expecting auto-resolve |
Replies DON'T auto-resolve threads |
Use Resolve-PRReviewThread.ps1 after reply |
| Inline issue creation |
Missing validation |
Use New-Issue.ps1 |
| Multiple individual reactions |
88% slower |
Use batch mode in Add-CommentReaction.ps1 |
| Hardcoding owner/repo |
Breaks in forks |
Let scripts infer from git remote |
| Ignoring exit codes |
Missing error handling |
Check $LASTEXITCODE |
| Skipping idempotency markers |
Duplicate comments |
Use -Marker parameter |
See Also
| Document |
Content |
| examples.md |
Complete script examples |
| patterns.md |
Reusable workflow patterns |
| copilot-prompts.md |
Creating @copilot directives |
| copilot-synthesis-guide.md |
Copilot context synthesis |
| api-reference.md |
Exit codes, API endpoints, troubleshooting |
modules/GitHubCore.psm1 |
Shared helper functions |
Verification
Before completing a GitHub operation:
1---2name: github3description: Execute GitHub operations (PRs, issues, milestones, labels, comments, merges) using PowerShell scripts with structured output and error handling. Use when working with pull requests, issues, review comments, CI checks, or milestones instead of raw gh.4license: MIT5---6# GitHub Skill
7
8Use these scripts instead of raw `gh` commands for consistent error handling and structured output.
9
10---
11
12## Triggers
13
14| Phrase | Operation |
15|--------|-----------|
16| `get PR context for #123` | Get-PRContext.ps1 |
17| `respond to review comments` | Post-PRCommentReply.ps1 |
18| `check CI status` | Get-PRChecks.ps1 |
19| `add label to issue` | Set-IssueLabels.ps1 |
20| `assign milestone` | Set-ItemMilestone.ps1 |
21
22---
23
24## Decision Tree
25
26```text
27Need GitHub data?
28├─ List PRs (filtered) → Get-PullRequests.ps1
29├─ PR info/diff → Get-PRContext.ps1
30├─ CI check status → Get-PRChecks.ps1
31├─ CI failure logs → Get-PRCheckLogs.ps1
32├─ Review comments → Get-PRReviewComments.ps1
33├─ Review threads → Get-PRReviewThreads.ps1
34├─ Unique reviewers → Get-PRReviewers.ps1
35├─ Unaddressed bot comments → Get-UnaddressedComments.ps1
36├─ PR merged check → Test-PRMerged.ps1
37├─ Copilot follow-up PRs → Detect-CopilotFollowUpPR.ps1
38├─ Issue info → Get-IssueContext.ps1
39├─ Merge readiness check → Test-PRMergeReady.ps1
40├─ Latest milestone → Get-LatestSemanticMilestone.ps1
41└─ Need to take action?
42 ├─ Create issue → New-Issue.ps1
43 ├─ Create PR → New-PR.ps1
44 ├─ Reply to review → Post-PRCommentReply.ps1
45 ├─ Reply to thread (GraphQL) → Add-PRReviewThreadReply.ps1
46 ├─ Comment on issue → Post-IssueComment.ps1
47 ├─ Add reaction → Add-CommentReaction.ps1
48 ├─ Apply labels → Set-IssueLabels.ps1
49 ├─ Set issue milestone → Set-IssueMilestone.ps1
50 ├─ Set PR/issue milestone (auto-detect) → Set-ItemMilestone.ps1
51 ├─ Assign issue → Set-IssueAssignee.ps1
52 ├─ Resolve threads → Resolve-PRReviewThread.ps1
53 ├─ Process AI triage → Invoke-PRCommentProcessing.ps1
54 ├─ Assign Copilot → Invoke-CopilotAssignment.ps1
55 ├─ Enable/disable auto-merge → Set-PRAutoMerge.ps1
56 ├─ Close PR → Close-PR.ps1
57 └─ Merge PR → Merge-PR.ps1
58```
59
60---
61
62## Script Reference
63
64### PR Operations (`scripts/pr/`)
65
66| Script | Purpose | Key Parameters |
67|--------|---------|----------------|
68| `Get-PullRequests.ps1` | List PRs with filters | `-State`, `-Label`, `-Author`, `-Base`, `-Head`, `-Limit` |
69| `Get-PRContext.ps1` | PR metadata, diff, files | `-PullRequest`, `-IncludeChangedFiles`, `-IncludeDiff` |
70| `Get-PRChecks.ps1` | CI check status, polling | `-PullRequest`, `-Wait`, `-TimeoutSeconds`, `-RequiredOnly` |
71| `Get-PRCheckLogs.ps1` | Fetch logs from failing CI checks | `-PullRequest`, `-MaxLines`, `-ContextLines` |
72| `Get-PRReviewComments.ps1` | Paginated review comments with stale detection | `-PullRequest`, `-IncludeIssueComments`, `-DetectStale`, `-ExcludeStale`, `-OnlyStale` |
73| `Get-PRReviewThreads.ps1` | Thread-level review data | `-PullRequest`, `-UnresolvedOnly` |
74| `Get-PRReviewers.ps1` | Enumerate unique reviewers | `-PullRequest`, `-ExcludeBots` |
75| `Get-UnaddressedComments.ps1` | Bot comments needing attention | `-PullRequest` |
76| `Get-UnresolvedReviewThreads.ps1` | Unresolved thread IDs | `-PullRequest` |
77| `Test-PRMerged.ps1` | Check if PR is merged | `-PullRequest` |
78| `Detect-CopilotFollowUpPR.ps1` | Detect Copilot follow-up PRs | `-PRNumber`, `-Owner`, `-Repo` |
79| `Post-PRCommentReply.ps1` | Thread-preserving replies | `-PullRequest`, `-CommentId`, `-Body` |
80| `Add-PRReviewThreadReply.ps1` | Reply to thread by ID (GraphQL) | `-ThreadId`, `-Body`, `-Resolve` |
81| `Resolve-PRReviewThread.ps1` | Mark threads resolved | `-ThreadId` or `-PullRequest -All` |
82| `Unresolve-PRReviewThread.ps1` | Mark threads unresolved | `-ThreadId` or `-PullRequest -All` |
83| `Get-ThreadById.ps1` | Get single thread by ID | `-ThreadId` |
84| `Get-ThreadConversationHistory.ps1` | Full thread comment history | `-ThreadId`, `-IncludeMinimized` |
85| `Test-PRMergeReady.ps1` | Check merge readiness | `-PullRequest`, `-IgnoreCI`, `-IgnoreThreads` |
86| `Set-PRAutoMerge.ps1` | Enable/disable auto-merge | `-PullRequest`, `-Enable`/`-Disable`, `-MergeMethod` |
87| `Invoke-PRCommentProcessing.ps1` | Process AI triage output | `-PRNumber`, `-Verdict`, `-FindingsJson` |
88| `New-PR.ps1` | Create PR with validation | `-Title`, `-Body`, `-Base` |
89| `Close-PR.ps1` | Close PR with comment | `-PullRequest`, `-Comment` |
90| `Merge-PR.ps1` | Merge with strategy | `-PullRequest`, `-Strategy`, `-DeleteBranch`, `-Auto` |
91
92### Issue Operations (`scripts/issue/`)
93
94| Script | Purpose | Key Parameters |
95|--------|---------|----------------|
96| `Get-IssueContext.ps1` | Issue metadata | `-Issue` |
97| `New-Issue.ps1` | Create new issue | `-Title`, `-Body`, `-Labels` |
98| `Set-IssueLabels.ps1` | Apply labels (auto-create) | `-Issue`, `-Labels`, `-Priority` |
99| `Set-IssueMilestone.ps1` | Assign milestone | `-Issue`, `-Milestone` |
100| `Post-IssueComment.ps1` | Comments with idempotency | `-Issue`, `-Body`, `-Marker` |
101| `Invoke-CopilotAssignment.ps1` | Synthesize context for Copilot | `-IssueNumber`, `-WhatIf` |
102| `Set-IssueAssignee.ps1` | Assign users to issues | `-Issue`, `-Assignees` |
103
104### Milestone Operations (`scripts/milestone/`)
105
106| Script | Purpose | Key Parameters |
107|--------|---------|----------------|
108| `Get-LatestSemanticMilestone.ps1` | Detect latest semantic version milestone | `-Owner`, `-Repo` |
109| `Set-ItemMilestone.ps1` | Assign milestone to PR/issue (auto-detect) | `-ItemType`, `-ItemNumber`, `-MilestoneTitle` |
110
111### Reactions (`scripts/reactions/`)
112
113| Script | Purpose | Key Parameters |
114|--------|---------|----------------|
115| `Add-CommentReaction.ps1` | Add emoji reactions (batch support) | `-CommentId[]`, `-Reaction`, `-CommentType` |
116
117---
118
119## Output Format
120
121All scripts output structured JSON with `Success` boolean:
122
123```powershell
124$result = pwsh -NoProfile scripts/pr/Get-PRContext.ps1 -PullRequest 50 | ConvertFrom-Json
125if ($result.Success) { ... }
126```
127
128---
129
130## Process
131
132This skill provides a toolkit of PowerShell scripts for GitHub operations. Use scripts directly or compose them into workflows.
133
134**Basic Usage:**
135
1361. Identify the operation needed using the Decision Tree
1372. Find the corresponding script in the Script Reference
1383. Call the script with required parameters
1394. Parse the JSON output and check `Success` field
140
141**Example Flow:**
142
143```powershell
144# Get PR context
145$pr = pwsh scripts/pr/Get-PRContext.ps1 -PullRequest 123 | ConvertFrom-Json
146
147# Check CI status
148$checks = pwsh scripts/pr/Get-PRChecks.ps1 -PullRequest 123 | ConvertFrom-Json
149
150# Add comment if needed
151if ($checks.FailedCount -gt 0) {
152 pwsh scripts/pr/Post-PRCommentReply.ps1 -PullRequest 123 -Body "CI failures detected"
153}
154```
155
156---
157
158## Anti-Patterns
159
160| Avoid | Why | Instead |
161|-------|-----|---------|
162| Raw `gh pr view` commands | No structured output | Use `Get-PRContext.ps1` |
163| Raw `gh api` for comments | Doesn't preserve threading | Use `Post-PRCommentReply.ps1` |
164| Replying to thread expecting auto-resolve | Replies DON'T auto-resolve threads | Use `Resolve-PRReviewThread.ps1` after reply |
165| Inline issue creation | Missing validation | Use `New-Issue.ps1` |
166| Multiple individual reactions | 88% slower | Use batch mode in `Add-CommentReaction.ps1` |
167| Hardcoding owner/repo | Breaks in forks | Let scripts infer from `git remote` |
168| Ignoring exit codes | Missing error handling | Check `$LASTEXITCODE` |
169| Skipping idempotency markers | Duplicate comments | Use `-Marker` parameter |
170
171---
172
173## See Also
174
175| Document | Content |
176|----------|---------|
177| [examples.md](references/examples.md) | Complete script examples |
178| [patterns.md](references/patterns.md) | Reusable workflow patterns |
179| [copilot-prompts.md](references/copilot-prompts.md) | Creating @copilot directives |
180| [copilot-synthesis-guide.md](references/copilot-synthesis-guide.md) | Copilot context synthesis |
181| [api-reference.md](references/api-reference.md) | Exit codes, API endpoints, troubleshooting |
182| `modules/GitHubCore.psm1` | Shared helper functions |
183
184---
185
186## Verification
187
188Before completing a GitHub operation:
189
190- [ ] Correct script selected from Decision Tree
191- [ ] Required parameters provided (PR/issue number)
192- [ ] Response JSON parsed successfully
193- [ ] `Success: true` in response
194- [ ] State change verified (for mutating operations)