Skip to content

PR Agent

Shane Neuville edited this page Jan 29, 2026 · 8 revisions

The PR Agent validates fixes through automated testing, explores alternatives using multiple AI models, and synthesizes everything into actionable recommendations.

%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#1e1e2e', 'primaryTextColor': '#cdd6f4', 'primaryBorderColor': '#45475a', 'lineColor': '#6c7086', 'secondaryColor': '#313244', 'tertiaryColor': '#181825'}}}%%
flowchart LR
    subgraph validate ["🧪 VALIDATE"]
        direction TB
        V1[Read PR context]
        V2[Find or create tests]
        V3[Verify tests catch bug]
        V1 --> V2 --> V3
    end
    
    subgraph explore ["🤖 EXPLORE"]
        direction TB
        E1[Analyze proposed fix]
        E1 --> E2a[GPT-5.2]
        E1 --> E2b[Claude Opus]
        E1 --> E2c[Gemini Pro]
        E2a --> E3[Test each fix]
        E2b --> E3
        E2c --> E3
    end
    
    subgraph synthesize ["📊 SYNTHESIZE"]
        direction TB
        S1[Compare all results]
        S2[Build consensus]
        S3[Generate review]
        S1 --> S2 --> S3
    end
    
    validate --> explore --> synthesize
    
    style validate fill:#1e1e2e,stroke:#89b4fa,stroke-width:2px,color:#cdd6f4
    style explore fill:#1e1e2e,stroke:#cba6f7,stroke-width:2px,color:#cdd6f4
    style synthesize fill:#1e1e2e,stroke:#a6e3a1,stroke-width:2px,color:#cdd6f4
Loading

Every fix is tested. The agent doesn't theorize—it implements each approach, runs tests, and reports what works.


Quick Start

Recommended: Use Plan Mode First

For the best results, start in plan mode to create and review a detailed plan before execution:

  1. Enter plan mode: Press Shift+Tab or use /plan
  2. Request a review plan:
    /plan review PR #12345 - create a detailed plan for the review
    
  3. Review the plan: Copilot will create a structured plan. Review the steps and make adjustments.
  4. Exit plan mode: Press Shift+Tab to switch back to execution mode
  5. Execute the plan:
    proceed with the plan
    

This workflow gives you control over the review approach before any actions are taken.

Direct Invocation (Alternative)

If you prefer to start immediately without planning:

# Start GitHub Copilot CLI
copilot

# Invoke the PR agent
/agent pr

# Then ask it to work on an issue or PR
please fix issue #12345
please review PR #67890

Trigger Phrases

Phrase Description
"Fix issue #XXXXX" Works whether or not a PR exists
"Work on issue #XXXXX" Investigate and implement a fix
"Review PR #XXXXX" Review an existing PR with independent analysis
"Continue working on #XXXXX" Resume from where you left off

Phase Details

Phase 1: Pre-Flight

Typical time: ~2-5 minutes

Context gathering only - no code analysis, no fix opinions, no running tests.

  • Create state file in CustomAgentLogsTmp/PRState/pr-XXXXX.md
  • Read issue description and comments
  • Document platforms affected
  • Identify files changed (if PR exists)
  • Note disagreements and edge cases from comments

Phase 2: Tests

Typical time: ~5-15 minutes (longer if creating new tests)

Ensure reproduction tests exist - tests must be verified to FAIL.

  • Check if tests already exist in PR
  • If not, create them using the write-ui-tests or write-xaml-tests skill
  • Verify tests compile
  • Verify tests FAIL (reproduce the bug)

Phase 3: Gate ⛔

Typical time: ~5-10 minutes

Mandatory checkpoint - must pass before continuing.

  • For PRs: Verify tests FAIL without fix, PASS with fix
  • For Issues: Confirm tests were verified to fail in Phase 2
  • Uses verify-tests-fail-without-fix skill

If Gate fails, stop and fix the tests before proceeding.

Phase 4: Fix

Typical time: ~10-30 minutes (varies by complexity)

Explore independent alternatives using the try-fix skill.

Even when a PR already has a fix, Phase 4 requires running try-fix to:

  1. Generate independent fix ideas (without looking at PR's solution)
  2. Test alternatives empirically
  3. Compare with PR's fix

The PR's fix is already validated by Gate. The try-fix skill explores if there's something better.

Phase 5: Report

Typical time: ~2-5 minutes

Deliver the result:

  • For PRs: Write review with APPROVE or REQUEST CHANGES
  • For Issues: Create a new PR with the fix

Skills Used

Skill Purpose
write-ui-tests Creates UI tests for issues following MAUI conventions
write-xaml-tests Creates XAML unit tests for parsing/compilation issues
verify-tests-fail-without-fix Verifies tests catch bugs (auto-detects mode)
try-fix Proposes and tests independent fix approaches
pr-build-status Retrieves Azure DevOps build status for PRs

State Tracking

The agent maintains state in CustomAgentLogsTmp/PRState/pr-XXXXX.md files. This allows:

  • Resuming interrupted sessions
  • Tracking progress across phases
  • Recording fix attempts and their outcomes

When NOT to Use

Task Use Instead
Just run tests manually sandbox-agent
Only write tests without fixing write-tests-agent
Quick manual validation sandbox-agent

File Locations

File Purpose
.github/agents/pr.md Phases 1-3 (Pre-Flight, Tests, Gate)
.github/agents/pr/post-gate.md Phases 4-5 (Fix, Report)
.github/skills/try-fix/SKILL.md Fix exploration skill
.github/skills/write-ui-tests/SKILL.md UI test creation skill
.github/skills/write-xaml-tests/SKILL.md XAML test creation skill
.github/skills/verify-tests-fail-without-fix/SKILL.md Test verification skill

Related Documentation

Clone this wiki locally