Contexte PR GitHub

VérifiéSûr

Récupère le contexte complet des Pull Requests GitHub incluant les métadonnées, les fichiers modifiés et les diffs de code. Cela permet de comprendre la portée d'une PR avant de la réviser, de planifier la délégation de tâches selon les fichiers impactés, et de vérifier l'état de fusion (conflits, CI).

Spar Skills Guide Bot
DeveloppementIntermédiaire
6002/06/2026
Claude Code
#pull-request#code-review#diff-analysis#github-api

Recommandé pour

Notre avis

Ce skill récupère le contexte complet d'une pull request GitHub (métadonnées, fichiers modifiés, diff) pour planifier une revue de code.

Points forts

  • Produit des sorties JSON structurées pour une vue d'ensemble, la liste des fichiers et le diff unifié.
  • Gère les erreurs avec des codes de sortie explicites (0-4).
  • S'intègre facilement avec jq pour un filtrage avancé.
  • Facilite la délégation de sous-tâches grâce aux informations sur les fichiers modifiés.

Limites

  • Nécessite une authentification GitHub CLI et Python 3.8+.
  • La sortie peut être volumineuse pour les PR avec beaucoup de fichiers.
  • Ne supporte pas les commentaires ou les revues inline.
Quand l'utiliser

Utilisez ce skill lorsque vous avez besoin d'une compréhension détaillée d'une PR avant d'effectuer une revue de code ou de déléguer des tâches.

Quand l'éviter

Ne l'utilisez pas si vous ne voulez qu'un résumé rapide sans détails par fichier, ou si le dépôt n'est pas accessible via GitHub.

Analyse de sécurité

Sûr
Score qualité88/100

The skill provides instructions for using authenticated GitHub CLI to retrieve public PR metadata and diffs. No destructive operations, external data exfiltration, or obfuscated payloads are present. It only reads repository data with proper user authentication.

Aucun point d'attention détecté

Exemples

Get full PR context
/review-pr 42
List changed files
Retrieve the list of changed files for PR #42 including additions and deletions.
Get diff for specific files
Show the unified diff for PR #42 for files src/main.py and tests/test_main.py

name: amia-github-pr-context description: Use when retrieving PR context including metadata, diff, and changed files for code review planning. Trigger with /review-pr [PR_NUMBER]. license: Apache-2.0 compatibility: Requires AI Maestro installed. metadata: version: 1.0.0 author: Emasoft category: github tags: "pull-request, code-review, diff-analysis, github-api" agent: api-coordinator context: fork user-invocable: false

GitHub PR Context Skill

Overview

This skill provides tools to retrieve comprehensive context about GitHub Pull Requests. Use this skill when you need to:

  • Understand a PR before reviewing: Get the full picture of what changed, why, and how
  • Plan task delegation: Know which files changed to assign subagents appropriately
  • Analyze merge readiness: Check mergeable status, conflicts, and CI state
  • Extract specific metadata: Get author, branch names, labels, reviewers

Output

Each script produces structured output for different PR analysis needs:

| Script | Output Format | Key Fields | Use Case | |--------|---------------|------------|----------| | amia_get_pr_context.py | JSON | number, title, state, author, mergeable, files[], labels[], reviewers[] | Complete PR overview for review planning | | amia_get_pr_files.py | JSON array | filename, status, additions, deletions, patch (optional) | File-level change tracking | | amia_get_pr_diff.py | Unified diff text or JSON stats | Diff hunks or files_changed, insertions, deletions | Code change inspection |

All JSON outputs are pretty-printed and can be piped to jq for filtering.

Instructions

Follow these numbered steps to retrieve and analyze GitHub PR context:

  1. Verify prerequisites are met

    • Run gh auth status to confirm GitHub CLI authentication
    • Run python3 --version to confirm Python 3.8+ is available
    • Ensure you have read access to the target repository
  2. Identify which information you need

    • Need full PR overview? → Use amia_get_pr_context.py
    • Need only changed files list? → Use amia_get_pr_files.py
    • Need actual code diff? → Use amia_get_pr_diff.py
  3. Run the appropriate script with required parameters

    • Always provide --pr NUMBER (the PR number)
    • Optionally provide --repo OWNER/REPO (defaults to current directory's repo)
    • For diffs, optionally add --stat for summary or --files for specific files
  4. Parse the output based on your task

    • For JSON outputs: pipe to jq or parse in your code
    • For diff outputs: analyze unified diff format or statistics
    • Check exit codes (0 = success, 1-4 = various errors)
  5. Handle errors appropriately

    • Exit code 1: Fix invalid parameters
    • Exit code 2: Verify PR number and repository
    • Exit code 3: Check network, retry if rate limited
    • Exit code 4: Re-authenticate with gh auth login
  6. Extract specific information as needed

    • For metadata fields, see references/pr-metadata.md <!-- TOC: pr-metadata.md -->
      • PR Metadata JSON Structure
      • 1 Core identification fields (number, title, state)
      • 2 Author and assignee information
      <!-- /TOC -->
    • For diff analysis, see references/diff-analysis.md <!-- TOC: diff-analysis.md -->
      • Understanding Diff Output
      • 1 Unified diff format explanation
      • 2 File headers and hunks
      <!-- /TOC -->

Checklist

Copy this checklist and track your progress:

  • [ ] Verify GitHub CLI is authenticated (gh auth status)
  • [ ] Verify Python 3.8+ is available
  • [ ] Confirm read access to the target repository
  • [ ] Identify which information is needed (context/files/diff)
  • [ ] Run the appropriate script with --pr NUMBER parameter
  • [ ] Parse the JSON or diff output
  • [ ] Check exit codes and handle any errors
  • [ ] Extract specific metadata or diff information as needed

When to Use This Skill

| Scenario | Use This Skill | |----------|----------------| | Starting a code review | Yes - get full PR context first | | Need to know which files changed | Yes - use file listing script | | Want to see actual code changes | Yes - use diff retrieval script | | Need PR metadata (author, labels) | Yes - use context script | | Creating a new PR | No - use git workflow skill instead | | Commenting on a PR | Partially - get context first, then use gh CLI directly |

Decision Tree: Which Script to Use

Need PR information?
├── Need full context (metadata + files + status)?
│   └── Use: amia_get_pr_context.py
│
├── Need only the list of changed files?
│   └── Use: amia_get_pr_files.py
│
├── Need to see the actual code diff?
│   ├── Want summary statistics only?
│   │   └── Use: amia_get_pr_diff.py --stat
│   ├── Want diff for specific files?
│   │   └── Use: amia_get_pr_diff.py --files file1.py file2.py
│   └── Want full diff?
│       └── Use: amia_get_pr_diff.py

Prerequisites

  1. GitHub CLI (gh) must be installed and authenticated
  2. Python 3.8+ available in PATH
  3. Repository access - you must have read access to the repository

Verify prerequisites:

# Check gh is authenticated
gh auth status

# Check Python version
python3 --version

Script Reference Table

| Script | Purpose | Key Arguments | Output | |--------|---------|---------------|--------| | amia_get_pr_context.py | Full PR metadata and status | --pr NUMBER, --repo OWNER/REPO | JSON with metadata, files, mergeable status | | amia_get_pr_files.py | List changed files | --pr NUMBER, --repo OWNER/REPO, --include-patch | JSON array of files with status | | amia_get_pr_diff.py | Get code diff | --pr NUMBER, --repo OWNER/REPO, --stat, --files | Diff text or JSON stats |

Exit Codes (Standardized)

All scripts use standardized exit codes for consistent error handling:

| Code | Meaning | Description | |------|---------|-------------| | 0 | Success | Output is valid JSON/text | | 1 | Invalid parameters | Bad PR number, missing required args | | 2 | Resource not found | PR does not exist | | 3 | API error | Network, rate limit, timeout | | 4 | Not authenticated | gh CLI not logged in | | 5 | Idempotency skip | N/A for these scripts | | 6 | Not mergeable | N/A for these scripts |

Examples

Get Full PR Context

# Get context for PR #123 in current repo
python3 amia_get_pr_context.py --pr 123

# Get context for PR in specific repo
python3 amia_get_pr_context.py --pr 456 --repo owner/repo-name

List Changed Files

# List files changed in PR #123
python3 amia_get_pr_files.py --pr 123

# Include patch/diff for each file
python3 amia_get_pr_files.py --pr 123 --include-patch

Get Diff

# Get full diff
python3 amia_get_pr_diff.py --pr 123

# Get statistics summary only
python3 amia_get_pr_diff.py --pr 123 --stat

# Get diff for specific files only
python3 amia_get_pr_diff.py --pr 123 --files src/main.py tests/test_main.py

Reference Documents

PR Metadata Reference

For detailed information about PR metadata fields and how to extract specific information, see:

references/pr-metadata.md

Contents:

    1. 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
    1. 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
    1. 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 Reference

For detailed information about interpreting PR diffs and analyzing changes, see:

references/diff-analysis.md

Contents:

    1. Understanding Diff Output
    • 1.1 Unified diff format explanation
    • 1.2 File headers and hunks
    • 1.3 Addition, deletion, and context lines
    1. File-Level Analysis
    • 2.1 Identifying file types by extension
    • 2.2 Detecting rename and copy operations
    • 2.3 Binary file changes
    1. Change Statistics
    • 3.1 Lines added vs deleted
    • 3.2 Files by change type (added, modified, deleted)
    • 3.3 Estimating review complexity
    1. Filtering and Focusing
    • 4.1 Filtering by file path patterns
    • 4.2 Ignoring generated files
    • 4.3 Focusing on specific directories

Integration with Integrator Agent

When delegating PR review tasks, use this skill to gather context first:

1. Get PR context with amia_get_pr_context.py
2. Analyze which files changed with amia_get_pr_files.py
3. Delegate file-specific reviews to subagents based on file types
4. Aggregate results and post review summary

Error Handling

| Problem | Cause | Solution | |---------|-------|----------| | "gh: command not found" | GitHub CLI not installed | Install with brew install gh or see gh docs | | "not logged into any GitHub hosts" | gh not authenticated | Run gh auth login | | "Could not resolve to a PullRequest" | Wrong PR number or repo | Verify PR exists with gh pr view NUMBER | | Rate limit errors | Too many API calls | Wait for rate limit reset or use --retry | | Permission denied | No repo access | Verify you have read access to the repository |

For additional troubleshooting, run scripts with --verbose flag for detailed logging.

Resources

  • references/pr-metadata.md - PR metadata JSON structure and field extraction <!-- TOC: pr-metadata.md -->
    • PR Metadata JSON Structure
    • 1 Core identification fields (number, title, state)
    • 2 Author and assignee information
    <!-- /TOC -->
  • references/diff-analysis.md - Understanding and analyzing PR diffs <!-- TOC: diff-analysis.md -->
    • Understanding Diff Output
    • 1 Unified diff format explanation
    • 2 File headers and hunks
    <!-- /TOC -->
Skills similaires