Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Copilot plugin for Claude Code

Use GitHub Copilot from inside Claude Code for code reviews or to delegate tasks to Copilot.

This plugin is a port of openai/codex-plugin-cc, adapted to drive the GitHub Copilot CLI (@github/copilot, v1.0.79+) instead of Codex.

How This Differs From codex-plugin-cc

  • Copilot CLI instead of Codex CLI. The plugin shells out to copilot instead of codex.
  • Process-per-job instead of a persistent app-server/broker. Copilot CLI has no daemon or JSON-RPC protocol. Every run is a one-shot, non-interactive process (copilot -p <prompt> --output-format json) that streams a JSONL event log on stdout and exits. The companion script spawns that process, parses the JSONL stream incrementally, and reduces it into a normalized result — there is no long-lived broker connection to manage.
  • Client-side structured-output parsing. Copilot CLI has no server-side structured-output enforcement, so the companion parses and schema-validates Copilot's final message as JSON itself and degrades to a raw-text rendering (with an explicit parse/validation error) when that fails.
  • Multi-model, not single-vendor. Copilot CLI supports --model auto plus BYOK (bring-your-own-key) provider models, rather than a fixed OpenAI model family. There is no Codex-style spark alias.

What You Get

  • /copilot:review for a normal read-only Copilot review
  • /copilot:adversarial-review for a steerable challenge review
  • /copilot:rescue, /copilot:transfer, /copilot:status, /copilot:result, and /copilot:cancel to delegate work, hand off sessions, and manage background jobs
  • /copilot:setup to check readiness and manage the optional stop-time review gate
  • The copilot-rescue subagent (used by /copilot:rescue)

Requirements

  • GitHub Copilot CLI (@github/copilot, v1.0.79 or later)
  • A GitHub Copilot subscription/authorization for the account or token you authenticate with
  • Node.js (the companion scripts are plain ESM .mjs)

Install

Install the Copilot CLI:

npm install -g @github/copilot

In Claude Code, add the marketplace and install the plugin:

/plugin marketplace add apappascs/copilot-plugin-cc
/plugin install copilot@github-copilot
/reload-plugins

Then run setup:

/copilot:setup

/copilot:setup reports whether Copilot is installed and authenticated. If it is missing and npm is available, it can offer to install it for you. If Copilot is installed but not authenticated, it will point you at !copilot login (see Auth below).

One simple first run:

/copilot:review --background
/copilot:status
/copilot:result

Usage

/copilot:review

Runs a normal, read-only Copilot review of your current work.

argument-hint: [--wait|--background] [--base <ref>] [--scope auto|working-tree|branch]
  • Reviews uncommitted working-tree changes by default, or a branch diff against a base ref with --base <ref>.
  • --scope auto|working-tree|branch selects the review target explicitly.
  • --wait runs it in the foreground; --background launches it as a Claude Code background task.
  • Not steerable — it does not accept custom focus text. If the raw arguments include extra text, the companion script rejects it and points you at /copilot:adversarial-review instead.
  • If neither --wait nor --background is given, Claude estimates the review size from git status/git diff --shortstat and asks you to pick, recommending background for anything beyond a tiny (1-2 file) change.

Examples:

/copilot:review
/copilot:review --base main
/copilot:review --background

Use /copilot:status to check progress and /copilot:cancel to stop a backgrounded review.

/copilot:adversarial-review

Runs a steerable review that challenges the chosen implementation, design, tradeoffs, and assumptions — not just a stricter line-by-line pass.

argument-hint: [--wait|--background] [--base <ref>] [--scope auto|working-tree|branch] [focus ...]
  • Uses the same target selection as /copilot:review (--base <ref>, --scope auto|working-tree|branch), plus --wait/--background.
  • Unlike /copilot:review, it accepts free-text focus instructions after the flags.
  • Read-only — it does not fix code.

Examples:

/copilot:adversarial-review
/copilot:adversarial-review --base main challenge whether this caching and retry design is safe
/copilot:adversarial-review --background look for race conditions and question the chosen approach

/copilot:rescue

Delegates investigation, an explicit fix request, or follow-up work to the copilot-rescue subagent, which forwards the request to a write-capable Copilot task run.

argument-hint: [--background|--wait] [--resume|--fresh] [--model <model>] [--effort <none|minimal|low|medium|high|xhigh|max>] [what Copilot should investigate, solve, or continue]
  • Defaults to foreground unless --background is given (or the subagent judges the task complicated/long-running and defaults to background itself).
  • --resume continues the most recent resumable Copilot task session for this Claude session; --fresh starts a new one. If neither is passed and a resumable session exists, Claude asks which you want via AskUserQuestion.
  • --model and --effort are passed through to the Copilot CLI run; if omitted, Copilot picks its own defaults.
  • Write-capable by default — this is the one command in the plugin that lets Copilot modify files, since it runs task, not review.

Examples:

/copilot:rescue investigate why the tests started failing
/copilot:rescue fix the failing test with the smallest safe patch
/copilot:rescue --resume apply the top fix from the last run
/copilot:rescue --model gpt-5.1-codex --effort medium investigate the flaky integration test
/copilot:rescue --background investigate the regression

You can also just ask for a task to be delegated:

Ask Copilot to redesign the database connection to be more resilient.

/copilot:transfer

Seeds a new, named, resumable Copilot session from a digest of the current Claude Code transcript, and prints a copilot --resume=<session-id> command.

argument-hint: [--source <claude-jsonl>]

Important

This is a lossy reconstruction, not a faithful session import. Unlike Codex's first-party Claude-session importer, the Copilot CLI has no native mechanism to replay a Claude transcript turn-by-turn. The companion script digests the current Claude session into a summary and seeds it as the opening prompt of a brand-new Copilot session. Exact tool calls, intermediate reasoning, and full message detail from the original session are not preserved verbatim — only what survives the digest. Do not describe this to users as an exact or complete transfer.

The plugin's SessionStart hook captures the current transcript path automatically, so --source is only needed as a manual override (and the path must resolve to a transcript the digest step can read).

Examples:

/copilot:transfer
/copilot:transfer --source ~/.claude/projects/-Users-me-repo/<session-id>.jsonl

/copilot:status

Shows active and recent Copilot jobs for the current repository, including review-gate status.

argument-hint: [job-id] [--all]

Examples:

/copilot:status
/copilot:status task-abc123

Without a job ID, output is rendered as a compact Markdown table. With a job ID, the full status detail for that job is shown.

/copilot:result

Shows the stored final output for a finished Copilot job in this repository.

argument-hint: [job-id]

Examples:

/copilot:result
/copilot:result task-abc123

Includes the verdict/summary/findings payload, file paths and line numbers as reported, the Copilot session ID and copilot --resume=<session-id> hint when available, and — since Copilot CLI has no server-side structured-output enforcement — the raw text plus parse/validation error if the final message didn't parse as valid JSON.

/copilot:cancel

Cancels an active background Copilot job in this repository.

argument-hint: [job-id]

Examples:

/copilot:cancel
/copilot:cancel task-abc123

/copilot:setup

Checks whether the local Copilot CLI is installed and authenticated, and can toggle the optional stop-time review gate.

argument-hint: [--enable-review-gate|--disable-review-gate]
  • If Copilot is missing and npm is available, offers to run npm install -g @github/copilot for you.
  • If Copilot is installed but not authenticated, points you at !copilot login (or !copilot login --host <host> for GitHub Enterprise Cloud).
  • --enable-review-gate / --disable-review-gate toggle the Stop-hook review gate described below.

Auth

The companion checks, in precedence order:

  1. COPILOT_GITHUB_TOKEN environment variable
  2. GH_TOKEN environment variable
  3. GITHUB_TOKEN environment variable
  4. A local Copilot CLI credential store (~/.copilot) or, on macOS, a Keychain entry for service copilot-cli — populated by the interactive OAuth device-code flow via copilot login

There is no dedicated copilot auth status subcommand, so this is a best-effort check; it never logs or returns the token value itself.

Note

Classic PATs (ghp_...) are not supported by Copilot CLI. If you authenticate with a personal access token, it must be a fine-grained PAT with the "Copilot Requests" permission — or use an OAuth token from copilot login instead.

For GitHub Enterprise Cloud (GHEC) data residency, authenticate against your enterprise host with:

copilot login --host <host>

Model & Reasoning

  • --model <model> selects the model for a run, including --model auto for Copilot's automatic routing, or a pinned BYOK provider model name.
  • --effort <level> selects reasoning effort. Accepted values: none, minimal, low, medium, high, xhigh, max.
  • Both flags are accepted by /copilot:review, /copilot:adversarial-review, and /copilot:rescue. Leave them unset to let Copilot choose its own defaults.

The Review Gate

/copilot:setup can enable a Stop-hook review gate that runs a targeted Copilot review of Claude's last response and blocks the stop if the review finds issues that still need fixing.

/copilot:setup --enable-review-gate
/copilot:setup --disable-review-gate

The review gate is OFF by default.

Warning

Enabling the review gate can create a runaway Claude ↔ Copilot loop and burn through usage very quickly. Each blocked stop triggers another Claude turn, which can trigger another review, and so on. Only enable it when you plan to actively monitor the session, and disable it again when you're done.

Read-Only Guarantee For Reviews

/copilot:review and /copilot:adversarial-review run Copilot with:

--allow-all-tools --deny-tool='write' --deny-tool='shell' --no-ask-user

--deny-tool always wins over --allow-all-tools. Denying the shell tool kind (not just write) is what makes this airtight — a write deny alone would not stop shell redirection tricks like sh -c "... > file".

The plugin also gathers the relevant git diff/context itself (via its own git calls) and injects it directly into the review prompt, rather than letting Copilot go read the working tree — so a review cannot modify, and does not even need to independently inspect, the working tree.

/copilot:rescue (via task) is write-capable by default and uses no deny-tool restrictions — that is the one path in this plugin where Copilot can edit files.

How It Works

  • Companion CLI (scripts/copilot-companion.mjs) — the single entry point invoked by every slash command (setup, review, adversarial-review, task, transfer, task-worker, status, result, cancel, task-resume-candidate). It resolves the review target, builds the Copilot CLI argv, spawns copilot, and renders output for both human and --json consumption.
  • Copilot CLI driver (scripts/lib/copilot.mjs) — resolves the copilot binary (project-local node_modules/.bin/copilot first, then PATH), builds the shared argv (always --allow-all-tools --no-ask-user, plus the read-only deny-tool composition for reviews), spawns the one-shot process, and streams its JSONL stdout into lib/events.mjs for incremental progress and a final reduced result.
  • Job registry (scripts/lib/state.mjs, scripts/lib/job-control.mjs, scripts/lib/tracked-jobs.mjs) — jobs are tracked per workspace root and scoped to the current Claude Code session id (captured by the SessionStart hook), so /copilot:status, /copilot:result, and /copilot:cancel only surface jobs relevant to your session/repo.
  • JSONL event reduction (scripts/lib/events.mjs) — classifies and reduces the raw Copilot session-event stream (turn start/end, tool start/complete, message, reasoning, error, abort) into progress updates and a final normalized result, since Copilot CLI has no server-side structured-output enforcement of its own.
  • Background task worker--background runs enqueue a job and launch copilot-companion.mjs task-worker --job-id <id> as a detached Claude Code background process, so /copilot:status//copilot:result//copilot:cancel can poll or stop it independently of the invoking turn.
  • Hooks (hooks/hooks.json) — SessionStart records the Claude session id and transcript path (for /copilot:transfer); SessionEnd cancels/cleans up any jobs still queued or running for that session (Copilot CLI has no persistent broker process to tear down, unlike Codex); Stop runs the optional review gate described above.

Development

Run the test suite:

npm test

Repository layout:

.claude-plugin/marketplace.json   marketplace metadata (github-copilot)
plugins/copilot/
  .claude-plugin/plugin.json      plugin metadata (copilot)
  commands/                       the 8 slash commands
  agents/copilot-rescue.md        the rescue subagent
  skills/                         internal runtime/prompting/result-handling guidance
  hooks/hooks.json                SessionStart/SessionEnd/Stop hook wiring
  prompts/                        review, adversarial-review, and stop-gate prompt templates
  schemas/                        review-output JSON schema
  scripts/                        copilot-companion.mjs + lib/*.mjs + hook entry points

License & Attribution

Licensed under Apache-2.0 (see LICENSE). This project is a derivative work of openai/codex-plugin-cc, adapted to drive the GitHub Copilot CLI instead of Codex. See NOTICE for full attribution.

About

Use GitHub Copilot from Claude Code to review code or delegate tasks. A port of openai/codex-plugin-cc.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages