GitHub PR Context Skill
Overview
Retrieves comprehensive GitHub Pull Request context (metadata, changed files, diffs) for code review planning and task delegation.
Prerequisites
- GitHub CLI (gh) installed and authenticated (
gh auth status)
- Python 3.8+ available in PATH
- Read access to the target repository
Instructions
- Verify prerequisites: run
gh auth status and python3 --version
- Choose the right script based on what you need:
- Full PR overview →
amia_get_pr_context.py
- Changed files list →
amia_get_pr_files.py
- Code diff →
amia_get_pr_diff.py
- Run with required params: always pass
--pr NUMBER, optionally --repo OWNER/REPO
- For diffs: add
--stat for summary or --files f1.py f2.py for specific files
- Parse output: pipe JSON to
jq; check exit codes (0=ok, 1=bad params, 2=not found, 3=API error, 4=not authed)
Checklist
Copy this checklist and track your progress:
Output
| Script |
Output |
Key Fields |
amia_get_pr_context.py |
JSON |
number, title, state, author, mergeable, files[], labels[], reviewers[] |
amia_get_pr_files.py |
JSON array |
filename, status, additions, deletions, patch (optional) |
amia_get_pr_diff.py |
Diff text or JSON stats |
Diff hunks or files_changed, insertions, deletions |
Output discipline: All scripts support --output-file <path>.
Reference Documents
PR Analysis:
- pr-metadata — PR metadata JSON structure and field extraction
- PR Metadata JSON Structure
- 1.1 Core identification fields (number, title, state)
- 1.2 Author and assignee information
- 1.3 Branch and merge information
- 1.4 Labels, milestones, and projects
- 1.5 Review and approval status
- Extracting Specific Fields
- 2.1 Getting PR title and description
- 2.2 Finding the source and target branches
- 2.3 Checking mergeable status and conflicts
- 2.4 Listing reviewers and their decisions
- Common Metadata Queries
- 3.1 Is this PR ready to merge?
- 3.2 Who needs to approve this PR?
- 3.3 What labels are applied?
- diff-analysis — Understanding and analyzing PR diffs
- Understanding Diff Output
- 1.1 Unified diff format explanation
- 1.2 File headers and hunks
- 1.3 Addition, deletion, and context lines
- File-Level Analysis
- 2.1 Identifying file types by extension
- 2.2 Detecting rename and copy operations
- 2.3 Binary file changes
- Change Statistics
- 3.1 Lines added vs deleted
- 3.2 Files by change type (added, modified, deleted)
- 3.3 Estimating review complexity
- Filtering and Focusing
- 4.1 Filtering by file path patterns
- 4.2 Ignoring generated files
- 4.3 Focusing on specific directories
Operations:
- op-get-pr-context — Full PR context retrieval operation
- op-get-pr-files — Changed files listing operation
- op-get-pr-diff — Diff retrieval operation
- op-analyze-pr-complexity — PR complexity analysis operation
Extended Guide:
See detailed-guide for full reference:
- When to Use This Skill
- Decision Tree: Which Script to Use
- Exit Codes
- Error Handling
- Integration with Integrator Agent
- Detailed Examples
Error Handling
If a script fails, check the exit code and stderr output. Common issues:
- Exit 1: Invalid parameters or missing arguments
- Exit 2-4: GitHub API errors (auth, not found, rate limit)
See the detailed guide above for detailed error scenarios.
Resources
Full reference: detailed-guide:
- When to Use This Skill
- Decision Tree: Which Script to Use
- Exit Codes
- Error Handling
- Integration with Integrator Agent
- Detailed Examples
- Get Full PR Context
- List Changed Files
- Get Diff
- Extracting Specific Information
Examples
Get PR context and extract files
python3 amia_get_pr_context.py --pr 123
python3 amia_get_pr_context.py --pr 456 --repo owner/repo-name
python3 amia_get_pr_diff.py --pr 123 --stat
1---2name: amia-github-pr-context3description: Use when retrieving PR context including metadata, diff, and changed files for code review planning. Trigger with /review-pr [PR_NUMBER]. Loaded by ai-maestro-integrator-agent-main-agent.4license: MIT5---67# GitHub PR Context Skill89## Overview1011Retrieves comprehensive GitHub Pull Request context (metadata, changed files, diffs) for code review planning and task delegation.1213## Prerequisites1415- **GitHub CLI (gh)** installed and authenticated (`gh auth status`)16- **Python 3.8+** available in PATH17- **Read access** to the target repository1819## Instructions20211. **Verify prerequisites**: run `gh auth status` and `python3 --version`222. **Choose the right script** based on what you need:23 - Full PR overview → `amia_get_pr_context.py`24 - Changed files list → `amia_get_pr_files.py`25 - Code diff → `amia_get_pr_diff.py`263. **Run with required params**: always pass `--pr NUMBER`, optionally `--repo OWNER/REPO`274. **For diffs**: add `--stat` for summary or `--files f1.py f2.py` for specific files285. **Parse output**: pipe JSON to `jq`; check exit codes (0=ok, 1=bad params, 2=not found, 3=API error, 4=not authed)2930### Checklist3132Copy this checklist and track your progress:3334- [ ] GitHub CLI authenticated35- [ ] Python 3.8+ available36- [ ] Read access to target repo confirmed37- [ ] Correct script selected for the task38- [ ] `--pr NUMBER` parameter provided39- [ ] Output parsed (JSON or diff)40- [ ] Exit codes checked4142## Output4344| Script | Output | Key Fields |45|--------|--------|------------|46| `amia_get_pr_context.py` | JSON | `number`, `title`, `state`, `author`, `mergeable`, `files[]`, `labels[]`, `reviewers[]` |47| `amia_get_pr_files.py` | JSON array | `filename`, `status`, `additions`, `deletions`, `patch` (optional) |48| `amia_get_pr_diff.py` | Diff text or JSON stats | Diff hunks or `files_changed`, `insertions`, `deletions` |4950> **Output discipline:** All scripts support `--output-file <path>`.5152## Reference Documents5354**PR Analysis:**5556- [pr-metadata](references/pr-metadata.md) — PR metadata JSON structure and field extraction57 - 1. PR Metadata JSON Structure58 - 1.1 Core identification fields (number, title, state)59 - 1.2 Author and assignee information60 - 1.3 Branch and merge information61 - 1.4 Labels, milestones, and projects62 - 1.5 Review and approval status63 - 1. Extracting Specific Fields64 - 2.1 Getting PR title and description65 - 2.2 Finding the source and target branches66 - 2.3 Checking mergeable status and conflicts67 - 2.4 Listing reviewers and their decisions68 - 1. Common Metadata Queries69 - 3.1 Is this PR ready to merge?70 - 3.2 Who needs to approve this PR?71 - 3.3 What labels are applied?72- [diff-analysis](references/diff-analysis.md) — Understanding and analyzing PR diffs73 - 1. Understanding Diff Output74 - 1.1 Unified diff format explanation75 - 1.2 File headers and hunks76 - 1.3 Addition, deletion, and context lines77 - 1. File-Level Analysis78 - 2.1 Identifying file types by extension79 - 2.2 Detecting rename and copy operations80 - 2.3 Binary file changes81 - 1. Change Statistics82 - 3.1 Lines added vs deleted83 - 3.2 Files by change type (added, modified, deleted)84 - 3.3 Estimating review complexity85 - 1. Filtering and Focusing86 - 4.1 Filtering by file path patterns87 - 4.2 Ignoring generated files88 - 4.3 Focusing on specific directories8990**Operations:**9192- [op-get-pr-context](references/op-get-pr-context.md) — Full PR context retrieval operation93 - [Purpose](#purpose)94 - [When to Use](#when-to-use)95 - [Prerequisites](#prerequisites)96 - [Input](#input)97 - [Output](#output)98 - [Steps](#steps)99 - [Step 1: Run the Context Script](#step-1-run-the-context-script)100 - [Step 2: Parse the JSON Output](#step-2-parse-the-json-output)101 - [Step 3: Use Context for Review Planning](#step-3-use-context-for-review-planning)102 - [Command Variants](#command-variants)103 - [Basic Context](#basic-context)104 - [Specific Repository](#specific-repository)105 - [Alternative: Direct gh CLI](#alternative-direct-gh-cli)106 - [Context Fields Explained](#context-fields-explained)107 - [Mergeable Status](#mergeable-status)108 - [Review Decision](#review-decision)109 - [File Status](#file-status)110 - [Example: Review Planning](#example-review-planning)111 - [Extracting Specific Information](#extracting-specific-information)112 - [Get Just File Paths](#get-just-file-paths)113 - [Get Mergeable Status Only](#get-mergeable-status-only)114 - [Get Author](#get-author)115 - [Exit Codes](#exit-codes)116 - [Error Handling](#error-handling)117 - [Related Operations](#related-operations)118- [op-get-pr-files](references/op-get-pr-files.md) — Changed files listing operation119 - [Purpose](#purpose)120 - [When to Use](#when-to-use)121 - [Prerequisites](#prerequisites)122 - [Input](#input)123 - [Output](#output)124 - [Steps](#steps)125 - [Step 1: Run the Files Script](#step-1-run-the-files-script)126 - [Step 2: Parse the Output](#step-2-parse-the-output)127 - [Step 3: Analyze File Distribution](#step-3-analyze-file-distribution)128 - [Command Variants](#command-variants)129 - [Basic File List](#basic-file-list)130 - [Include Patch Content](#include-patch-content)131 - [Specific Repository](#specific-repository)132 - [Alternative: Direct gh CLI](#alternative-direct-gh-cli)133 - [File Status Values](#file-status-values)134 - [Analyzing File Distribution](#analyzing-file-distribution)135 - [By Directory](#by-directory)136 - [By File Type](#by-file-type)137 - [By Change Magnitude](#by-change-magnitude)138 - [Example: Review Delegation](#example-review-delegation)139 - [Example: With Patch Content](#example-with-patch-content)140 - [Large PRs (>100 files)](#large-prs-100-files)141 - [Exit Codes](#exit-codes)142 - [Error Handling](#error-handling)143 - [Related Operations](#related-operations)144- [op-get-pr-diff](references/op-get-pr-diff.md) — Diff retrieval operation145 - [Purpose](#purpose)146 - [When to Use](#when-to-use)147 - [Prerequisites](#prerequisites)148 - [Input](#input)149 - [Output](#output)150 - [Steps](#steps)151 - [Step 1: Run the Diff Script](#step-1-run-the-diff-script)152 - [Step 2: Review the Output](#step-2-review-the-output)153 - [Command Variants](#command-variants)154 - [Full Diff](#full-diff)155 - [Statistics Only](#statistics-only)156 - [Specific Files](#specific-files)157 - [Combine with Other Tools](#combine-with-other-tools)158 - [Alternative: Direct gh CLI](#alternative-direct-gh-cli)159 - [Understanding Unified Diff Format](#understanding-unified-diff-format)160 - [Hunk Header Explained](#hunk-header-explained)161 - [Filtering Diff Output](#filtering-diff-output)162 - [Find Added Lines](#find-added-lines)163 - [Find Removed Lines](#find-removed-lines)164 - [Find Files with Specific Changes](#find-files-with-specific-changes)165 - [Example: Security Review](#example-security-review)166 - [Example: Test Coverage Check](#example-test-coverage-check)167 - [Large Diffs](#large-diffs)168 - [Exit Codes](#exit-codes)169 - [Error Handling](#error-handling)170 - [Related Operations](#related-operations)171- [op-analyze-pr-complexity](references/op-analyze-pr-complexity.md) — PR complexity analysis operation172 - [Purpose](#purpose)173 - [When to Use](#when-to-use)174 - [Prerequisites](#prerequisites)175 - [Input](#input)176 - [Output](#output)177 - [Complexity Factors](#complexity-factors)178 - [Steps](#steps)179 - [Step 1: Gather Metrics](#step-1-gather-metrics)180 - [Step 2: Calculate Size Category](#step-2-calculate-size-category)181 - [Step 3: Identify Sensitive Files](#step-3-identify-sensitive-files)182 - [Step 4: Assess Module Spread](#step-4-assess-module-spread)183 - [Step 5: Check Test Coverage](#step-5-check-test-coverage)184 - [Step 6: Calculate Final Score](#step-6-calculate-final-score)185 - [Step 7: Generate Review Time Estimate](#step-7-generate-review-time-estimate)186 - [Step 8: Create Delegation Recommendation](#step-8-create-delegation-recommendation)187 - [Example: Complete Analysis](#example-complete-analysis)188 - [Complexity Score Guide](#complexity-score-guide)189 - [Error Handling](#error-handling)190 - [Related Operations](#related-operations)191192**Extended Guide:**193194See [detailed-guide](references/detailed-guide.md) for full reference:195 - When to Use This Skill196 - Decision Tree: Which Script to Use197 - Exit Codes198 - Error Handling199 - Integration with Integrator Agent200 - Detailed Examples201202## Error Handling203204If a script fails, check the exit code and stderr output. Common issues:205206- **Exit 1**: Invalid parameters or missing arguments207- **Exit 2-4**: GitHub API errors (auth, not found, rate limit)208209See the detailed guide above for detailed error scenarios.210211## Resources212213Full reference: [detailed-guide](references/detailed-guide.md):214 - When to Use This Skill215 - Decision Tree: Which Script to Use216 - Exit Codes217 - Error Handling218 - Integration with Integrator Agent219 - Detailed Examples220 - Get Full PR Context221 - List Changed Files222 - Get Diff223 - Extracting Specific Information224225## Examples226227### Get PR context and extract files228229```bash230python3 amia_get_pr_context.py --pr 123231python3 amia_get_pr_context.py --pr 456 --repo owner/repo-name232python3 amia_get_pr_diff.py --pr 123 --stat233```