Generated banner for Copilot Pr Autopilot
Generated logo for Copilot Pr Autopilot

Copilot Pr Autopilot

GitHubOfficialFirst committed by yeelam-gordonDistributed by GitHub

  • Skill
  • Workflow
  • Software development
  • MIT
  • Low risk
  • Has scripts

From the author

Copilot left 14 review comments on your PR — half are nits. Hours of fix → reply → resolve → re-request, and each round lands MORE comments. This skill runs loop engineering: auto-triggers Copilot Code Review via GraphQL (no @copilot mention), triages every open thread (Copilot, humans, advanced-security) with a fix / decline / escalate rubric, dispatches parallel fix sub-agents that obey the repo build/test/lint conventions, commits per iteration, replies+resolves citing the pushed SHA, then re-triggers until HEAD is reviewed with zero threads awaiting the agent's reply (remaining open threads are explicit hand-offs to the human — escalated declines, design tradeoffs). You merge a clean PR; the bot runs it. Trigger phrases: "address copilot comments", "run a copilot review loop", "fix this PR", "iterate on copilot feedback". Repo-agnostic, gh CLI + PowerShell. Full autopilot needs repo Triage/Write; external PR authors get single-iteration mode plus manual re-trigger (UI 🔄 or substantive-commit push).
— the description by yeelam-gordon

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

Copilot PR Autopilot is a workflow-based skill designed to handle the repetitive cycle of addressing Copilot code review comments. It automates the process of triggering reviews, triaging findings, applying fixes, running build and test commands, and verifying convergence. The skill operates in a loop, ensuring that every Copilot finding is either fixed, declined with rationale, or escalated to a human reviewer. It is designed to be repository-agnostic and relies on the GitHub CLI and PowerShell to manage PR states and interactions.

What it does

  • Automatically triggers Copilot Code Review on a pull request.
  • Triage open review threads from Copilot, humans, and security scanners.
  • Dispatches sub-agents to apply fixes while adhering to repository build and test conventions.
  • Manages the commit and push cycle for each iteration of fixes.
  • Replies to and resolves review threads based on the agent's disposition.
  • Verifies convergence to ensure all threads are addressed or appropriately escalated.

When to use it

  • When a PR is functionally complete and requires a final automated correctness pass.
  • When a previous Copilot review has left numerous open threads that need systematic triage.
  • When you want to automate the repetitive 'fix-reply-resolve' cycle of PR reviews.

Advantages

  • Reduces manual effort in resolving large volumes of nit-picky review comments.
  • Maintains a clean audit trail by creating one focused commit per iteration.
  • Ensures fixes are validated against repository-specific build and test commands.
  • Provides a structured escalation path for design tradeoffs or human-specific feedback.

Usage examples

“address copilot comments”
The agent initiates the review loop, triages existing Copilot findings, applies necessary fixes, and pushes commits until the PR is ready for review.
“run a copilot review loop”
The agent triggers a new Copilot review, waits for the results, and begins the iterative process of fixing and resolving threads.
“fix this PR”
The agent analyzes the current PR state, identifies open review threads, and executes the fix-and-verify workflow to address all actionable feedback.
“iterate on copilot feedback”
The agent performs a single iteration of the review loop, applying fixes for current Copilot comments and reporting on the status of remaining threads.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/github/copilot-pr-autopilot/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip copilot-pr-autopilot.zip -d .agents/skills

Documentation by yeelam-gordon

Copilot PR Autopilot

Drive any GitHub pull request through repeated rounds of Copilot code review until the agent has done its job — every Copilot finding has a reply from the agent (fix-acknowledgement, decline-with-rationale, or explicit escalate-to-user hand-off). Remaining open threads, if any, are deliberate hand-offs to the human merge owner — they're not loop failures. Repository-agnostic — works on any repo that has Copilot Code Review enabled, run from a machine with gh CLI installed and authenticated (see Prerequisites).

When to Use This Skill

  • The user asks to "request Copilot review" or "run a Copilot review loop" on a PR.

  • A PR is functionally complete and the user wants a final correctness pass via repeated automated review rounds.

  • A previous Copilot review on the PR has left open threads that need triage, fixing, replying, and resolving.

When NOT to Use This Skill

  • The PR is still under active design — wait until the structure is stable; otherwise findings churn round-over-round.

  • The user wants human reviewer feedback, not Copilot's.

Prerequisites

  • gh CLI installed and authenticated against the target repository.

  • PowerShell on PATH — Windows PowerShell 5.1+ (powershell.exe) or PowerShell 7+ (pwsh). Both are tested.

  • Copilot Code Review is the primary use case (01-request-review.ps1 uses GraphQL requestReviewsByLogin to trigger Copilot). It is NOT a hard requirement — if 01-request-review.ps1 fails because Copilot isn't enabled on the repo / account, the agent can still drive existing review threads (human, advanced-security, etc.) to completion by running steps 3–8 once as a single iteration; just skip the trigger + wait. There is no auto-detect for "Copilot unavailable" — the agent makes that decision after the trigger fails (the script can't reliably tell "Copilot disabled" from "Copilot enabled but not yet triggered" from API state alone).

Permissions: who can run the full loop

The full multi-round autopilot (steps 1 → 9 → 1) needs Triage or Write permission on the target repo, because GitHub's only public API for adding the Copilot bot as a reviewer (requestReviewsByLogin) is gated on that permission. Verified against the public REST + GraphQL surface in this PR's commit history — there is no public-API path for bot reviewers without write permission.

You are…What works
Repo collaborator with Triage / WriteFull loop: 01 triggers Copilot, 02 waits, 04–08 triage / fix / reply, loop back to 01. Hands-off.
External PR author (no write permission)01 will throw a clear actionable error. Use -SingleIteration mode: address all current findings in one pass, then either click the UI 🔄 next to Copilot, or push a substantive commit (the synchronize event auto-triggers Copilot on most repos). Then re-run 02 to verify.

In single-iteration mode the loop's convergence boolean is Converged: true iff OpenThreadsAwaitingReply == 0 (the agent's side is done). The maintainer-side re-trigger then drives any additional rounds.

Every script dot-sources scripts/_lib.ps1 which runs Assert-GhReady on load: if gh is missing OR gh auth status fails, the script halts before any work with a single actionable error message naming the install command and gh auth login. The agent should surface that message to the user verbatim and stop the loop — do not retry or work around it.

Step-by-Step Workflow

The loop: steps 1 → 2 → 3 → 4 → 5 → 6 → 7 → 8 → 9, then back to step 1 if Converged: false. Repeat the 1→9 round until step 9 returns Converged: true; only then run step 10 once and call task_complete. At every 10th round, the parent runs the round-cap recap gate before looping back — recap all prior rounds and stop if the loop has drifted out of the PR's original scope.

Each round runs steps 1–9; step 10 is a one-time cleanup after convergence. The parent agent coordinates; every sub-agent step runs in a fresh context with a bounded budget. Cross-cutting protocol (time-boxing, extension, single-iteration fallback): orchestration.md.

  1. Request review (parent) — see 01-request-review.md

  2. Wait for review (sub-agent, 20-min cap) — see 02-wait.md

  3. List + categorize open threads (sub-agent, 5 min) — see 03-list-threads.md

  4. Triage (sub-agent, 5 min per ≤5 threads) — see 04-triage.md

  5. Fix (sub-agents, parallel max 5, 5 min each) — see 05-fix.md

  6. Build + test per repo conventions (sub-agent, 10 min) — see 06-build-test.md

  7. Commit + push (parent) — see 07-commit-push.md

  8. Reply (always) + resolve (conditional) (sub-agent drafts, parent posts) — see 08-reply-resolve.md

  9. Convergence verify (sub-agent, 3 min) — see 09-convergence.md

    • Converged: false → loop back to step 1 for another round (re-trigger, wait, list, triage, fix, push, reply, re-check). Each round addresses Copilot's findings on the previous round's HEAD; the loop terminates as soon as Copilot has nothing new to say AND every open thread has a reply from the agent.

    • Converged: true → exit the loop, run step 10 once, call task_complete with the proof.

    • Every 10th round (10, 20, 30…) → run the round-cap recap gate before looping back. Recap ALL prior rounds against the PR's original scope and pick a verdict: CONTINUE, REVERT-AND-SHIP (drop drifted commits, ship the in-scope ones), or HAND-OFF (escalate to the user). This is the circuit breaker that stops a runaway bot-review loop.

  10. Cleanup outdated (parent, post-convergence, once) — see 10-cleanup.md

Convergence is computed by scripts/02-check-review-status.ps1 as a single Converged: true boolean. Do not call task_complete until it returns true; print the proof (HeadOid, LatestCopilotReview.commitOid, submittedAt) in the completion message.

Gotchas

The bundled scripts enforce the hard correctness invariants (trigger landing via copilot_work_started event id, Converged requiring HEAD-match + zero-awaiting + at-HEAD review, single-iteration fallback semantics, PR-state guard). Trust them — don't re-derive. The notes below cover decisions the scripts can't make for you:

  • Reply to every open thread; resolve only when the loop owns the disposition. For fix and decline threads, reply + resolve. For escalate-to-user threads, reply with the analysis but leave the thread OPEN (08-reply-and-resolve.ps1 -NoResolve) so the human merge owner can act on it. See 08-reply-resolve.md.

  • Copilot threads are loop-owned; human / advanced-security / other-bot threads default to escalate-to-user. Auto-resolving a human review thread can hide unaddressed concerns. See 04-triage.md for the rubric.

  • One focused commit per round, not one per PR. Bundling rounds destroys the audit trail of which finding drove which change and breaks git bisect. See 07-commit-push.md.

  • Build/test/lint with the repo's own commands (per its CONTRIBUTING / AGENTS / README / package.json / Makefile) before pushing a fix. Discovery procedure: 06-build-test.md.

  • Push back with written rationale when a Copilot finding would over-engineer the design for a hypothetical edge case. Auto-accepting every suggestion erodes the design — see the decline path in 04-triage.md.

  • Scripting traps (gh api graphql -F type-coercion, git stash push -m positional parsing, the three GraphQL traps for the reviewer mutation) are documented in references/api-quirks.md. Read before modifying any script.

Troubleshooting

IssueSolution
Script throws prerequisite missing — gh CLI is not on PATHInstall gh (winget install GitHub.cli on Windows; brew install gh on macOS; package manager on Linux; or download from https://cli.github.com). Then gh auth login. Surface the message to the user and STOP the loop — do not retry.
Script throws prerequisite missing — gh CLI is not authenticatedRun gh auth login. STOP the loop until the user completes auth.
Trigger fails or no copilot_work_started event landsPush a substantive (non-whitespace) commit — auto-assign on synchronize is the most reliable trigger. Persistent failure indicates Copilot Code Review may not be enabled on the repo / account (check repo Settings → Code & automation → Copilot, or account-level Copilot Pro/Pro+).
No new review after waiting ~10 minQuiet-period after recent dismissal or trivial-diff suppression. Push a substantive commit and retry. Do not blindly re-run 01-request-review.ps1 — it reports InFlight while Copilot is still a requested reviewer.
Outdated-but-unresolved threads in the open listExpected: unresolved state is the source of truth. Reply + resolve them like any other open thread. 10-cleanup-outdated.ps1 is only a final safety net.
Unsure whether to fix or decline a findingSee references/04-triage.md.
Need a reply phrasing for "fixed", "declined", or "drift"See the templates under templates/ — reply-fix.md, reply-decline.md, reply-drift.md, reply-partial.md.

References

Files

scripts/_lib.ps1

# Shared helpers for copilot-pr-autopilot scripts.
# Dot-source with: `. "$PSScriptRoot/_lib.ps1"`
#
# Dot-sourcing runs the prerequisite check below; if `gh` is missing or
# unauthenticated the script halts BEFORE doing any work, with a single
# actionable error message the calling agent can pattern-match on.
#
# Compatibility: Windows PowerShell 5.1+ and PowerShell 7+. Uses only
# `& gh @args 2>$tempFile` for stdout/stderr separation — avoids
# `System.Diagnostics.ProcessStartInfo.ArgumentList` which is .NET
# Core / .NET 5+ only and returns $null on .NET Framework.

# Canonical Copilot Code Review reviewer login regex.
# GraphQL exposes the login as either `copilot-pull-request-reviewer` (when
# referenced via `requestedReviewer.login`) or `copilot-pull-request-reviewer[bot]`
# (when referenced via review `author.login`), so callers must accept both.
# Centralised here so all step scripts (01 / 02 / 10) stay in sync — if the
# canonical login ever changes, change it once.
#
# Namespaced (`CopilotPrAutopilot_` prefix) + read-only because `_lib.ps1` is
# dot-sourced into the caller's scope; a bare name like `$CopilotLoginRegex`
# would risk colliding with caller-side variables. `Set-Variable -Force` lets
# us re-dot-source in the same session without erroring on the read-only flag.
# A back-compat alias `$CopilotReviewerLoginRegex` is preserved so callers
# don't have to type the prefix on every read site (and so older snapshots of
# 01/02/10 keep working).
Set-Variable -Name 'CopilotPrAutopilot_CopilotReviewerLoginRegex' `
    -Value '(?i)^copilot-pull-request-reviewer(\[bot\])?$' `
    -Option ReadOnly -Force -Scope Script
Set-Variable -Name 'CopilotReviewerLoginRegex' `
    -Value $CopilotPrAutopilot_CopilotReviewerLoginRegex `
    -Option ReadOnly -Force -Scope Script

# Prerequisite check: gh CLI installed AND authenticated.
# Fails fast with install/login instructions. Idempotent (once per
# PowerShell session).
function Assert-GhReady {
    if ($script:_GhReady) { return }

    # 1. Installed?
    $cmd = Get-Command gh -ErrorAction SilentlyContinue
    if (-not $cmd) {
        throw @'
copilot-pr-autopilot: prerequisite missing — `gh` CLI is not on PATH.

Install (one of):
  - winget install --id GitHub.cli           (Windows)
  - brew install gh                          (macOS)
  - sudo apt install gh                      (Debian/Ubuntu — see https://cli.github.com for other distros)
  - https://cli.github.com/                  (universal installer + download)

Then `gh auth login` and re-run this command.
'@
    }

    # 2. Authenticated? `gh auth status` exits non-zero when no account
    # is logged in. Capture stderr to a temp file via the `2>` redirect.
    $errFile = [IO.Path]::GetTempFileName()
    try {
        $null = & gh auth status 2>$errFile
        $ec = $LASTEXITCODE
        if ($ec -ne 0) {
            $err = ''
            if (Test-Path -LiteralPath $errFile) {
                $err = (Get-Content -Raw -LiteralPath $errFile -ErrorAction SilentlyContinue)
                if ($null -eq $err) { $err = '' }
            }
            throw @"
copilot-pr-autopilot: prerequisite missing — ``gh`` CLI is not authenticated.

Run:
  gh auth login

Then re-run this command.

``gh auth status`` reported:
  $($err.Trim())
"@
        }
    } finally {
        if (Test-Path -LiteralPath $errFile) {
            Remove-Item -LiteralPath $errFile -ErrorAction SilentlyContinue
        }
    }

    $script:_GhReady = $true
}

# Single-invocation gh wrapper. Captures stdout + stderr separately
# via the `2>` redirect to a temp file. Returns ExitCode/Stdout/Stderr
# so callers never have to re-invoke `gh` just to recover stderr, and
# never feed stderr into `ConvertFrom-Json` on success.
#
# Note on -WhatIf: PowerShell's `2>` redirect goes through Out-File,
# which respects $WhatIfPreference at the caller scope. The bundled
# `10-cleanup-outdated.ps1` therefore uses an explicit `-DryRun`
# switch instead of [CmdletBinding(SupportsShouldProcess)], so this
# helper never sees a leaked WhatIfPreference and never prints
# "Performing the operation Output to File" noise.
function Invoke-Gh {
    param([Parameter(Mandatory)][string[]]$GhArgs)

    # Cross-version safety: Windows PowerShell 5.1's native-command
    # argument passer mangles arguments that contain embedded double-quote
    # characters (long-standing bug, only fully fixed in PS 7.3+ via
    # $PSNativeCommandArgumentPassing). GraphQL queries/mutations routinely
    # embed quoted strings (comments, default values, enum-like literals
    # such as `["copilot-pull-request-reviewer"]`), so passing them as
    # command-line values (`-f field=<body>`) round-trips correctly in
    # pwsh 7 but silently mis-splits under 5.1 (e.g., gh CLI reports
    # "accepts 1 arg(s), received 7" or 'Expected type "number", but it
    # was malformed: "-pull"'). To work identically in both runtimes, any
    # `-f field=<body>` or `-F field=<body>` pair whose body contains `"`
    # is rewritten to `-F field=@<tempfile>` (the body is written to disk
    # first; `gh` reads it from the file and the value never appears on
    # the command line).
    #
    # IMPORTANT typing note (verified live with gh api graphql):
    #   * `gh -F field=@<file>` reads the file content and applies type
    #     inference (digit→Number, true/false→Boolean, null→null, else
    #     String).
    #   * `gh -f field=@<file>` does NOT expand `@<file>` — it sends the
    #     literal string `@<file>` as the value (gh's `-f` skips the @
    #     prefix entirely). So `-f` is NOT a viable tempfile carrier;
    #     the rewrite MUST use `-F`.
    #
    # Safety of the unconditional rewrite-to-`-F`:
    #   * Query bodies (large GraphQL strings) never look like Number /
    #     Boolean / null after inference, so they round-trip as String.
    #   * Reply bodies typed by humans (08-reply-and-resolve) almost
    #     never look like exactly `"true"`, `"false"`, `"null"`, or a
    #     bare digit run — and if they do AND they also contain `"`
    #     (the rewrite trigger), the resulting coercion would be a
    #     loud GraphQL `String!` type error, not silent data loss.
    # Tempfiles are cleaned up in `finally`.
    $rewritten = [System.Collections.Generic.List[string]]::new()
    $tempFiles = [System.Collections.Generic.List[string]]::new()
    for ($i = 0; $i -lt $GhArgs.Count; $i++) {
        $a = $GhArgs[$i]
        # Rewrite both `-f field=<body>` and `-F field=<body>` whose body
        # contains `"` — same PS 5.1 native-arg splitting bug applies to
        # both. The rewrite ALWAYS emits `-F` because `gh -f field=@file`
        # does not expand `@file` (only `-F` does — verified live). The
        # file content is then sent as a String GraphQL variable for any
        # body that doesn't look like a Number/Boolean/null (i.e., every
        # real-world query body and reply body in this skill).
        if (($a -eq '-f' -or $a -eq '-F') -and ($i + 1) -lt $GhArgs.Count) {
            $next = $GhArgs[$i + 1]
            $eqIdx = $next.IndexOf('=')
            if ($eqIdx -gt 0 -and $next.Substring($eqIdx + 1).Contains('"')) {
                $field = $next.Substring(0, $eqIdx)
                $body  = $next.Substring($eqIdx + 1)
                $tf = [IO.Path]::GetTempFileName()
                [void]$tempFiles.Add($tf)
                # UTF-8 without BOM so `gh` reads the body verbatim
                [IO.File]::WriteAllText($tf, $body, [System.Text.UTF8Encoding]::new($false))
                [void]$rewritten.Add('-F')
                [void]$rewritten.Add("$field=@$tf")
                $i++
                continue
            }
        }
        [void]$rewritten.Add($a)
    }

    $errFile = [IO.Path]::GetTempFileName()
    try {
        $finalArgs = $rewritten.ToArray()
        # Localise $ErrorActionPreference to 'Continue' around the native
        # `gh` call. Why: callers set `$ErrorActionPreference = 'Stop'` at
        # script scope, and under PowerShell 5.1 that combination converts
        # any line `gh` writes to stderr into a `NativeCommandError` that
        # aborts the script BEFORE we get to inspect `$LASTEXITCODE`. PS 7+
        # changed native-stderr handling and is unaffected. By keeping the
        # native call at 'Continue' we always return the
        # `@{ExitCode;Stdout;Stderr}` object on both runtimes, so callers
        # see the same structured error and can emit the same actionable
        # message (e.g. the "click UI 🔄" guidance in 01-request-review).
        $prevEAP = $ErrorActionPreference
        $ErrorActionPreference = 'Continue'
        try {
            $out = & gh @finalArgs 2>$errFile
            $ec = $LASTEXITCODE
        } finally {
            $ErrorActionPreference = $prevEAP
        }
        $err = ''
        if (Test-Path -LiteralPath $errFile) {
            $err = (Get-Content -Raw -LiteralPath $errFile -ErrorAction SilentlyContinue)
            if ($null -eq $err) { $err = '' }
        }
        # Preserve gh's stdout content without PowerShell formatting.
        # `Out-String` would append a trailing newline and apply console
        # formatting widths, which can subtly break callers that
        # regex/JSON-parse the result. `& gh` returns one array entry per
        # line (with the line terminator already stripped); we re-join with
        # "`n" and no trailing newline, so the result is content-preserving
        # but normalized to LF (not byte-identical to the original stream).
        # Callers add a trailing newline if they need one.
        $stdout = if ($null -eq $out) { '' }
                  elseif ($out -is [string]) { $out }
                  else { ($out | ForEach-Object { [string]$_ }) -join "`n" }
        [pscustomobject]@{ ExitCode = $ec; Stdout = $stdout; Stderr = $err }
    } finally {
        if (Test-Path -LiteralPath $errFile) {
            Remove-Item -LiteralPath $errFile -ErrorAction SilentlyContinue
        }
        foreach ($tf in $tempFiles) {
            if ($tf -and (Test-Path -LiteralPath $tf)) {
                Remove-Item -LiteralPath $tf -ErrorAction SilentlyContinue
            }
        }
    }
}

# Wrap ConvertFrom-Json so a non-JSON / empty stdout failure carries
# the calling $Context plus trimmed stdout/stderr — without this
# callers see a bare "Unexpected character encountered" exception
# that doesn't say which gh command produced the bad output.
# Centralised so the preview limits + format stay consistent across
# Invoke-GhGraphQL, Resolve-RepoCoords, and any future call sites.
function ConvertFrom-GhJson {
    param(
        [Parameter(Mandatory)][AllowEmptyString()][AllowNull()][string]$Stdout,
        [AllowEmptyString()][AllowNull()][string]$Stderr,
        [Parameter(Mandatory)][string]$Context,
        [int]$PreviewChars = 500
    )
    try {
        # Use -InputObject (not pipeline form `$Stdout | ConvertFrom-Json`):
        # on Windows PowerShell 5.1, returning the pipeline form from inside
        # a function preserves the parsed array as a single object rather
        # than unrolling it. Callers then see `.Count == 1` for a JSON
        # array of N items, and `$result[0]` is the inner array. The
        # parameter form returns the same parsed structure but PowerShell
        # 5.1 unrolls it correctly on function return.
        return (ConvertFrom-Json -InputObject $Stdout -ErrorAction Stop)
    } catch {
        $stdoutPreview = if ($Stdout) { $Stdout.Substring(0, [Math]::Min($PreviewChars, $Stdout.Length)) } else { '(empty)' }
        $stderrPreview = if ($Stderr) { $Stderr.Substring(0, [Math]::Min($PreviewChars, $Stderr.Length)) } else { '(empty)' }
        throw "$Context returned non-JSON: $($_.Exception.Message)`nstdout (<=${PreviewChars} chars): $stdoutPreview`nstderr (<=${PreviewChars} chars): $stderrPreview"
    }
}

# Wrapper around Invoke-Gh for `gh api graphql` that throws on either
# non-zero exit OR a GraphQL `errors` array in the response body.
# Cross-version safety for embedded quotes in queries is handled by
# Invoke-Gh's automatic `-f field=<body-with-quotes>` → tempfile rewrite.
function Invoke-GhGraphQL {
    param(
        [Parameter(Mandatory)][string[]]$GhArgs,
        [Parameter(Mandatory)][string]$Context
    )
    $r = Invoke-Gh -GhArgs (@('api','graphql') + $GhArgs)
    if ($r.ExitCode -ne 0) {
        throw "gh api graphql failed (exit $($r.ExitCode)) [$Context]: $($r.Stderr)"
    }
    $data = ConvertFrom-GhJson -Stdout $r.Stdout -Stderr $r.Stderr -Context "gh api graphql [$Context]"
    if ($data.errors) {
        # Aggregate type + path + extensions.code alongside .message so
        # callers see actionable failures without re-running with extra
        # logging. GitHub commonly returns type=NOT_FOUND / FORBIDDEN /
        # RATE_LIMITED and extensions.code=undefinedField etc.; dropping
        # them turns a clear failure ("FORBIDDEN at /repository/pullRequest")
        # into an opaque message-only string.
        $msgs = ($data.errors | ForEach-Object {
            $parts = New-Object System.Collections.Generic.List[string]
            if ($_.type) { $parts.Add("type=$($_.type)") }
            if ($_.path) { $parts.Add("path=$(($_.path) -join '/')") }
            if ($_.extensions -and $_.extensions.code) { $parts.Add("code=$($_.extensions.code)") }
            $parts.Add("message=$($_.message)")
            ($parts -join ' ')
        }) -join '; '
        throw "GraphQL errors [$Context]: $msgs"
    }
    $data
}

# Auto-resolve owner/repo from gh's local context when caller didn't pass them.
# Both-or-neither contract: passing exactly one of -Owner/-Repo is rejected,
# because mixing a caller-supplied owner with a locally-detected repo (or vice
# versa) silently constructs a non-existent or unintended `<Owner>/<Repo>` pair.
function Resolve-RepoCoords {
    param([string]$Owner, [string]$Repo)
    if ([bool]$Owner -ne [bool]$Repo) {
        throw "Resolve-RepoCoords: pass both -Owner and -Repo, or neither (got Owner='$Owner' Repo='$Repo'). Partial override would silently mix caller and local repo coordinates."
    }
    if ($Owner -and $Repo) { return @{ Owner = $Owner; Repo = $Repo } }
    $r = Invoke-Gh -GhArgs @('repo','view','--json','owner,name')
    if ($r.ExitCode -ne 0) {
        throw "gh repo view failed (exit $($r.ExitCode)): $($r.Stderr). Pass -Owner and -Repo explicitly, or run from inside a gh-detected repo."
    }
    $info = ConvertFrom-GhJson -Stdout $r.Stdout -Stderr $r.Stderr -Context 'gh repo view'
    if (-not ($info -and $info.owner -and $info.owner.login -and $info.name)) {
        throw "gh repo view returned unexpected shape (missing owner.login or name); cannot auto-resolve repo coordinates. Pass -Owner and -Repo explicitly."
    }
    @{ Owner = $info.owner.login; Repo = $info.name }
}

# Format-IsoUtcString — centralise the ISO-8601 UTC normalisation that
# 01-request-review.ps1 (events.created_at), 02-check-review-status.ps1
# (reviews.submittedAt), and 03-list-open-threads.ps1 (comments.createdAt)
# all need to perform. `ConvertFrom-Json` auto-deserialises ISO timestamps
# to `[datetime]`, whose default `.ToString()` is culture-dependent and
# NOT round-trippable as ISO-8601. Calling `.ToUniversalTime().ToString(
# 'yyyy-MM-ddTHH:mm:ssZ')` keeps the on-wire JSON contract identical to
# the value GitHub originally sent. If the value is already a string
# (e.g., gh returned a raw JSON string), we pass it through verbatim. If
# it's null or empty, we return ''.
function Format-IsoUtcString {
    param($Value)
    if ($null -eq $Value) { return '' }
    if ($Value -is [datetime]) { return $Value.ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ') }
    return [string]$Value
}

# Run the prerequisite check as a side-effect of dot-sourcing.
Assert-GhReady

Requirements and compatibility

Written for: GitHub Copilot

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Security

What our scanner noticed· Low risk

  • Scripts that your agent may run

This skill includes scripts that your agent may run. Read them before you use it.

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

First committed by
GitHub avatar of yeelam-gordonyeelam-gordon
Publisher
GitHub (Official)
Distributed by
GitHub
Source
github/awesome-copilot · skills/copilot-pr-autopilot · commit 797337f
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced
Contributors
yeelam-gordon

AutoGineer is not affiliated with or endorsed by yeelam-gordon or GitHub.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download copilot-pr-autopilot.zip