# GitHub Copilot Agent Mode & GitHub MCP

> Orchestrate autonomous coding inside VS Code, delegate GitHub Issues to Copilot Coding Agent, automate PR code reviews, and wire the official GitHub MCP Server with repo-wide custom instructions.

- **Topic:** [Product & Design Teams](https://twelve-pages.com/topics/product-and-design)
- **Web Edition:** https://twelve-pages.com/guides/product-and-design/github-copilot-agent-mode-and-mcp
- **Printable 12-Page PDF:** https://twelve-pages.com/guides/product-and-design/github-copilot-agent-mode-and-mcp/GitHub_Copilot_Agent_Mode_and_MCP_Complete_How_To_Guide.pdf (946 KB)
- **Version:** v1.0 (Updated 2026-11)
- **Reading Time:** 12 minutes (12 pages)
- **Authorship:** AI-authored under human editorial direction & print QA (https://twelve-pages.com/editorial)
- **Tags:** VS Code Agent Mode · Cloud Coding Agent · GitHub MCP Server · Custom Instructions · Copilot Code Review · Enterprise Governance

## Core Takeaways

- **Autonomous IDE Loops:** Plan multi-file edits, run tests, inspect diagnostics, and self-heal failures synchronously inside VS Code Agent Mode.
- **Async Issue-to-PR:** Assign scoped GitHub Issues to @copilot to spin up ephemeral Actions sandboxes, run CI, and open review-ready PRs.
- **Zero-PAT GitHub MCP:** Connect api.githubcopilot.com/mcp/ over OAuth 2.1 + PKCE with scoped X-MCP-Toolsets and read-only guardrails.

## 1. Three Surfaces, One Agentic Graph: How Copilot Executes

Modern GitHub Copilot is no longer just inline autocomplete. It is a coordinated engineering fabric combining synchronous IDE execution (VS Code Agent Mode), asynchronous cloud delegation (Copilot Coding Agent on GitHub Actions), and standardized tool connectivity via the official GitHub MCP Server.

**Golden Rule: Scope, Guard, Verify**

### Architecture: Local Agent Mode vs. Cloud Coding Agent vs. GitHub MCP

All three execution surfaces read the same repository instruction files (`.github/copilot-instructions.md` and `AGENTS.md`), ensuring consistent architecture, lint rules, and test verification whether an engineer is pair-programming live or delegating backlog tickets overnight.

#### L When to Stay Local (VS Code Agent Mode)

Use Agent Mode when requirements are exploratory, you need rapid visual feedback on a local dev server, or you want interactive diff review across complex cross-cutting refactors. Think of it as a **senior pair programmer** sharing your keyboard and terminal.

#### C When to Delegate Async (Cloud Coding Agent)

Assign issues to `@copilot` for well-scoped backlog work: unit test coverage, bug fixes with repro steps, dependency migrations, or docs updates. It runs in an isolated GitHub Actions sandbox and opens a Draft PR while you stay in flow.

## 2. Choosing the Right Copilot Plan & Execution Mode

Matching the task to the right execution mode preserves both developer focus and monthly GitHub AI Credits (which replaced legacy premium request counting across plans in June 2026). Avoid launching heavy cloud sandboxes for quick inline edits, and avoid manual Ask chat for multi-file refactors.

### Copilot Execution Mode Decision Matrix

| Execution Mode | Surface | Autonomy & Capabilities | Ideal Use Cases |
| --- | --- | --- | --- |
| **Ask Mode** | VS Code, JetBrains, Web | Read-only Q&A; explains code and searches `#codebase`. Zero file writes. | Onboarding to modules, debugging stack traces, reviewing SQL queries. |
| **Edit Mode** | VS Code, JetBrains | Scoped diffs on user-selected files only; no shell execution or autonomous loops. | Deterministic edits across 2–5 known files (props, TypeScript types, JSDoc). |
| **Agent Mode** | VS Code (GA), JetBrains, CLI | Autonomous synchronous loop: edits files, runs shell commands, calls MCP tools, self-fixes. | End-to-end features, complex refactors, failing test triage, live API wiring. |
| **Coding Agent** | GitHub Actions Cloud | Async issue-to-PR sandbox with ephemeral runner, firewall allowlist, self-review, security scan. | Well-scoped backlog tickets, flaky tests, CRUD endpoints, dependency upgrades. |
| **Code Review** | GitHub PRs & Rulesets | Agentic diff analysis (Lite / Balanced / Max) on Actions; leaves inline suggestions. | Automated first-pass PR screening via branch rulesets before human review. |

### Late-2026 Plans, Pricing & AI Credit Tiers

| Plan Tier | Price (USD) | Included Usage & Model Access | Key Governance & Agent Features |
| --- | --- | --- | --- |
| **Copilot Free** | $0 / mo | Entry completions & limited monthly AI credits for chat and Agent Mode trials. | Personal repos only; standard public code filter. |
| **Copilot Pro** | $10 / mo (Free Edu) | Core monthly AI credit pool; base completions; Claude Sonnet, GPT, & Gemini access. | Full Agent Mode, Coding Agent, Code Review, Remote GitHub MCP. |
| **Copilot Pro+** | $39 / mo | 4x–5x Pro usage (~$70 credits); frontier models (Claude Opus, GPT-5.x High, Fusion). | High-throughput autonomous sessions & Max-depth PR reviews. |
| **Copilot Max** | $100 / mo | Highest individual AI credit allowance for full-time multi-agent IDE/CLI workflows. | Priority capacity without mid-sprint credit ceilings. |
| **Business** | $19 / seat / mo | Per-seat AI credits + org overage budgets; policy-governed multi-model picker. | Content exclusions, IP indemnity, audit logs, MCP toggles. |
| **Enterprise** | $39 / seat / mo (GHE) | Expanded per-seat AI credit pool & custom org knowledge bases. | Enterprise MCP Registry, network routing, SIEM streaming. |

#### Billing Note (June 2026+): AI Credits + Actions Minutes

Since June 1, 2026, GitHub transitioned from legacy premium requests to unified **GitHub AI Credits** (existing annual plans remain grandfathered until renewal). On **private repositories**, Coding Agent and Code Review consume AI Credits *plus* standard Actions runner minutes; public repositories remain free of Actions billing.

## 3. Inside VS Code Copilot Chat: 7-Control Agent Mode Tour

VS Code Copilot Chat transforms into an autonomous workbench the moment you switch the mode selector to Agent. Mastering these seven HUD controls prevents runaway edits, keeps token overhead lean, and makes terminal execution safe.

VS Code — Copilot Chat (Agent Mode) • repo: acme/billing-api

MCP: 2 Connected Branch: feat/idempotency

PROMPT + CONTEXT ATTACHMENTS copilot-instructions.md (auto)

#file:webhooks.ts #github/get_issue /add-idempotency

"Implement Stripe webhook idempotency keys from Issue #418, add Vitest unit tests, and verify CI passes."

AGENT WORKING SET & DIFF CHECKPOINT 3 files edited • +114 / -12

• src/api/webhooks.ts +62 -8 [Keep | Undo]
 • src/db/idempotency.ts +28 -0 [Keep | Undo]
 • tests/webhooks.test.ts +24 -4 [Keep | Undo]

TERMINAL TOOL APPROVAL Awaiting Confirmation

$ pnpm vitest run tests/webhooks.test.ts

Allow Once Allow in Workspace Skip

MODE & MODEL CONTROLS

Mode Selector Agent ▾

Model Picker Claude Sonnet 4.5 ▾

MCP Toolsets 14 Tools Active

CLOUD HANDOFF & DELEGATION

Escalate long-running test matrices or follow-up refactors directly to Copilot Coding Agent on GitHub Actions.

Delegate to Cloud Agent Open Draft PR

**Live Telemetry:** 4/25 tool iterations • 0 TS diagnostics • Checkpoint #2 saved

#### 1 Mode Switcher (Agent / Plan / Edit / Ask)

Start ambiguous features in **Plan Mode** to generate an editable Markdown execution plan, then switch to **Agent Mode** to execute file writes and tests.

#### 2 Unified Model Picker

Hot-swap between Claude Sonnet/Opus, GPT-5.x, and Gemini Pro mid-thread without losing workspace context or MCP tool state.

#### 3 MCP Tools Drawer ()

Toggle individual MCP servers and toolsets on/off per session. Keeping active tools under **35** maximizes tool-calling accuracy.

#### 4 Context Chips & Slash Prompts

Attach exact files (`#file`), terminal output (`#terminalSelection`), or repo prompt files (`/add-endpoint`) to ground the first turn.

#### 5 Working Set & Checkpoint Rollback

Every Agent turn creates a restore checkpoint. Review inline hunks with **Keep / Undo** before staging commits so no silent regressions slip in.

#### 6 Terminal Auto-Approval Rules

Configure `chat.tools.terminal.autoApprove` in `settings.json` to allow read-only commands (`git status`, `vitest`, `pytest`) while blocking destructive shells (`rm`, `git push -f`).

#### 7 Cloud Agent Handoff

Click **Delegate to Cloud Agent** to package your current thread, branch context, and acceptance criteria into an async GitHub Actions session.

**Pro Tip:** Cap runaway loops by setting `"chat.agent.maxRequests": 25` in VS Code User Settings.

## 4. Persistent Repo Memory: Instructions, Globs & Prompt Files

Repeating coding conventions in every chat prompt wastes time and AI credits. Version-controlled instruction files turn your repository into a self-documenting contract automatically injected into VS Code Agent Mode, Cloud Coding Agent, Copilot CLI, and Code Review.

*[Illustration: Isometric translucent blueprint layers illuminated by sky blue and emerald circuit pathways converging into a central geometric core]*

**Layered Context Architecture:** Combine one concise repo-wide baseline (`.github/copilot-instructions.md` or `AGENTS.md`) with path-scoped `.instructions.md` glob files and reusable `.prompt.md` workflows so agents load only relevant rules.

### The 4-Tier GitHub Copilot Instruction Hierarchy

| File Path Pattern | Scope & Trigger | Honored By | Best Content to Put Inside |
| --- | --- | --- | --- |
| `.github/copilot-instructions.md` | Always-on (Repo-wide) | VS Code, JetBrains, Coding Agent, Code Review | Tech stack, exact build/lint/test commands, directory layout, non-negotiable conventions (<150 lines). |
| `.github/instructions/*.instructions.md` | Path-scoped via YAML `applyTo` | VS Code Agent Mode, Coding Agent, Code Review | Domain-specific rules: React component patterns, SQL migration safety, Terraform module guards. |
| `AGENTS.md` (root or subdir) | Cross-agent standard | Coding Agent, Code Review, Copilot CLI, Codex | Portable engineering handbook shared across Copilot and third-party agents; nearest file wins in monorepos. |
| `.github/prompts/*.prompt.md` | On-demand `/slash` command | VS Code Copilot Chat & Agent Mode | Repeatable multi-step SOPs: scaffolding an API route, writing E2E specs, auditing PR accessibility. |

Path-Scoped Rule: `.github/instructions/api.instructions.md`

```
<code><span class="ck-hdr">---</span>
<span class="ck-key">applyTo:</span> <span class="ck-str">"src/api/**/*.ts,src/routes/**/*.ts"</span>
<span class="ck-hdr">---</span>
<span class="ck-cmt"># API Route Engineering Standards</span>
- Validate all inputs with Zod schemas in `src/schemas/`.
- Return typed `Result<T, ApiError>`; never throw raw strings.
- Every POST/PUT mutation MUST enforce `Idempotency-Key`.
- Run `pnpm vitest run src/api` before completing any edit.</code>
```

Reusable Workflow: `.github/prompts/new-endpoint.prompt.md`

```
<code><span class="ck-hdr">---</span>
<span class="ck-key">mode:</span> <span class="ck-str">"agent"</span>
<span class="ck-key">tools:</span> [<span class="ck-str">"codebase"</span>, <span class="ck-str">"terminal"</span>, <span class="ck-str">"github/get_issue"</span>]
<span class="ck-hdr">---</span>
1. Read the linked GitHub Issue acceptance criteria.
2. Scaffold route, Zod schema, and Vitest integration test.
3. Run `pnpm typecheck && pnpm test:api` and fix errors.
4. Summarize changed files and curl verification example.</code>
```

#### Context Hygiene Rule: Keep Always-On Files Under 150 Lines

Although GitHub removed the legacy 4,000-character cap on Code Review custom instructions in June 2026, bloated 700-line instruction files dilute attention and inflate token burn on every turn. Move framework-specific rules into path-scoped `.instructions.md` globs so they load only when matching files are touched.

## 5. Wiring github/github-mcp-server: Remote OAuth & Toolsets

The official Go-based GitHub MCP Server exposes GitHub Issues, Pull Requests, Actions logs, and Code Security alerts directly to Copilot Agent Mode. Its GA remote endpoint (https://api.githubcopilot.com/mcp/) authenticates via OAuth 2.1 + PKCE—eliminating static Personal Access Tokens on developer laptops.

Recommended: Remote OAuth (`.vscode/mcp.json`)

```
<code>{
  <span class="ck-key">"servers"</span>: {
    <span class="ck-key">"github"</span>: {
      <span class="ck-key">"type"</span>: <span class="ck-str">"http"</span>,
      <span class="ck-key">"url"</span>: <span class="ck-str">"https://api.githubcopilot.com/mcp/"</span>,
      <span class="ck-key">"headers"</span>: {
        <span class="ck-hdr">"X-MCP-Toolsets"</span>: <span class="ck-str">"repos,issues,pull_requests,actions"</span>,
        <span class="ck-hdr">"X-MCP-Readonly"</span>: <span class="ck-str">"false"</span>,
        <span class="ck-sec">"X-MCP-Lockdown"</span>: <span class="ck-str">"true"</span>
      }
    }
  }
}</code>
```

Streamable HTTP OAuth 2.1 Auto-Login Header Toolset Filter Lockdown Guard

Air-Gapped / GHES Fallback: Local Docker

```
<code>{
  <span class="ck-key">"inputs"</span>: [{
    <span class="ck-key">"id"</span>: <span class="ck-str">"gh_pat"</span>, <span class="ck-key">"type"</span>: <span class="ck-str">"promptString"</span>, <span class="ck-key">"password"</span>: <span class="ck-hdr">true</span>
  }],
  <span class="ck-key">"servers"</span>: {
    <span class="ck-key">"github-local"</span>: {
      <span class="ck-key">"command"</span>: <span class="ck-str">"docker"</span>,
      <span class="ck-key">"args"</span>: [<span class="ck-str">"run"</span>, <span class="ck-str">"-i"</span>, <span class="ck-str">"--rm"</span>, <span class="ck-str">"-e"</span>, <span class="ck-str">"GITHUB_PERSONAL_ACCESS_TOKEN"</span>,
        <span class="ck-str">"ghcr.io/github/github-mcp-server"</span>, <span class="ck-str">"--toolsets=repos,issues"</span>],
      <span class="ck-key">"env"</span>: { <span class="ck-key">"GITHUB_PERSONAL_ACCESS_TOKEN"</span>: <span class="ck-str">"${input:gh_pat}"</span> }
    }
  }
}</code>
```

### Official GitHub MCP Toolsets & Remote Scoping Reference

| Toolset Name | Single-Toolset URL | High-Value Tools Exposed | Recommended Access Policy |
| --- | --- | --- | --- |
| `repos` | `/mcp/x/repos` | `get_file_contents`, `search_code`, `list_commits`, `create_branch`, `push_files` | Enable by default; pair with branch protection on `main`. |
| `issues` | `/mcp/x/issues` | `get_issue`, `list_issues`, `create_issue`, `add_issue_comment`, `search_issues` | Enable for sprint triage, bug repro lookup, and ticket updates. |
| `pull_requests` | `/mcp/x/pull_requests` | `get_pull_request`, `get_pull_request_diff`, `create_pull_request`, `list_review_comments` | Enable for local PR prep, review-comment fixes, and diff audits. |
| `actions` | `/mcp/x/actions` | `list_workflow_runs`, `get_job_logs`, `rerun_failed_jobs`, `list_artifacts` | Essential for CI auto-healing loops inside VS Code Agent Mode. |
| `code_security` | `/mcp/x/code_security` | `list_code_scanning_alerts`, `get_code_scanning_alert`, `list_dependabot_alerts` | Enable for security sprints; pair with `X-MCP-Readonly: true`. |
| `users` / `orgs` | `/mcp/x/users` | `get_me`, `search_users`, `list_org_teams` | Optional; exclude unless automating CODEOWNERS or team routing. |

#### Context-Window Hygiene: Scope Your Toolsets

Never load every GitHub MCP tool at once. Filtering via `X-MCP-Toolsets` or `X-MCP-Exclude-Tools` trims thousands of JSON schema tokens per turn and sharpens agent tool selection.

#### Read-Only & Lockdown Modes

Append `/readonly` to the URL (or set `X-MCP-Readonly: true`) for zero-write audit sessions. Enable `X-MCP-Lockdown: true` on public repos to hide untrusted external issue/PR comments from prompt injection.

## 6. Delegate Issues to @copilot & Automate PR Code Reviews

When you assign a GitHub Issue to Copilot Coding Agent, GitHub spins up an ephemeral Actions runner, executes your custom setup workflow, writes and tests the implementation, runs built-in security & self-review checks, and opens a Draft PR ready for human and AI review.

#### 1 Scope Issue

Include target file paths, clear acceptance criteria, and the exact test command.

#### 2 Assign @copilot

Select **Copilot** in Issue Assignees, pick a model, or delegate directly from VS Code / CLI.

#### 3 Actions Sandbox

Runs `copilot-setup-steps.yml`, edits code, runs linters/tests, and self-reviews diffs.

#### 4 Draft PR Loop

Leave PR review comments tagging `@copilot` to trigger automated follow-up commits.

### Pre-Warming the Sandbox: `.github/workflows/copilot-setup-steps.yml`

The Coding Agent executes inside a firewalled Actions environment. Pre-installing runtimes, package caches, and database binaries in `copilot-setup-steps.yml` prevents firewall blocks during `npm install` or `pip install` and cuts task latency by 40–60%. Copilot Code Review also reuses this file by default.

```
<code><span class="ck-key">name:</span> <span class="ck-str">"Copilot Setup Steps"</span>
<span class="ck-key">on:</span>
  <span class="ck-key">workflow_dispatch:</span>
  <span class="ck-key">push:</span>
    <span class="ck-key">paths:</span> [<span class="ck-str">".github/workflows/copilot-setup-steps.yml"</span>]

<span class="ck-key">jobs:</span>
  <span class="ck-key">copilot-setup-steps:</span>          <span class="ck-cmt"># Exact job name required by GitHub Copilot</span>
    <span class="ck-key">runs-on:</span> <span class="ck-str">ubuntu-latest</span>       <span class="ck-cmt"># Ephemeral runner — NEVER a deploy runner</span>
    <span class="ck-key">permissions:</span>
      <span class="ck-key">contents:</span> <span class="ck-str">read</span>
    <span class="ck-key">steps:</span>
      - <span class="ck-key">uses:</span> <span class="ck-str">actions/checkout@v4</span>
      - <span class="ck-key">uses:</span> <span class="ck-str">actions/setup-node@v4</span>
        <span class="ck-key">with:</span> { <span class="ck-key">node-version:</span> <span class="ck-str">"22"</span>, <span class="ck-key">cache:</span> <span class="ck-str">"pnpm"</span> }
      - <span class="ck-key">run:</span> <span class="ck-str">corepack enable && pnpm install <span class="nowrap">--frozen-lockfile</span></span>
      - <span class="ck-key">run:</span> <span class="ck-str">pnpm build:types</span>      <span class="ck-cmt"># Pre-generate types so agent typecheck runs fast</span></code>
```

#### R Automated PR Reviews via Branch Rulesets

- **Scale with Rulesets:** Enable *Automatically request Copilot code review* in Repo or Org Branch Rulesets rather than relying on individual user toggles.
- **Choose Review Depth:** Select **Lite** (fast syntax/bug pass), **Balanced** (default agentic diff check), or **Max** (deep cross-file reasoning for critical services).
- **Comment-Only Safety:** Copilot Code Review leaves inline suggestions and comments—it *never* counts toward required human approvals or auto-merges code.

#### I Steering Coding Agent PRs Like a Teammate

- **Batch Your Feedback:** Use GitHub's *Start a review* workflow to submit 3–5 inline comments in one review round so `@copilot` addresses everything in a single Actions run.
- **Inspect Session Logs:** Click *View session* on the PR timeline to audit every shell command, file read, and test output the agent executed.
- **CLI / IDE Takeover:** For the last 10% polish, check out the agent's `copilot/*` branch locally or hand off to Copilot CLI.

#### Security Gate: Manual Actions Approval on Agent PRs

By design, GitHub Actions CI workflows on a Copilot Coding Agent PR do **not** run automatically until a repository maintainer with write access clicks *Approve and run workflows*. Keep this gate enabled to review diffs before CI executes untrusted test code.

## 7. Routing Claude, GPT & Gemini Inside GitHub Copilot

One of Copilot's strongest enterprise advantages is its unified multi-model fabric: developers can route tasks across Anthropic Claude, OpenAI GPT, and Google Gemini under a single GitHub seat, zero-retention agreement, and centralized AI credit budget.

*[Illustration: Dark metallic prism router splitting light into sky blue, emerald, and violet streams toward modular server racks and governance shields]*

**Intentional Model Routing:** Match model weight to task complexity—reserving frontier reasoning tiers (Claude Opus, GPT-5.x High) for architecture and gnarly bugs while using fast, high-efficiency models for boilerplate and routine edits.

### Task-to-Model Routing Playbook

| Engineering Workload | Recommended Model Tier | Credit Burn | Why It Wins Here |
| --- | --- | --- | --- |
| **Inline Completions & Quick Edits** | Copilot Base / Fast Mini Models | 0x – Low | Sub-200ms latency for tab autocomplete, docstrings, and single-file renames without draining credits. |
| **Everyday Agent Mode Builds** | Claude Sonnet 4.5 / GPT-5.x Standard | Medium | Best balance of multi-file precision, clean React/TypeScript output, and reliable MCP tool-calling. |
| **Complex Architecture & Root-Cause Debugging** | Claude Opus / GPT-5.x Reasoning | High | Excels at multi-service race conditions, schema migrations, and writing Plan Mode blueprints. |
| **Large-Context Repo Audits & Multimodal UI** | Gemini Pro (Long Context) | Medium | Handles sprawling monorepo traces, lengthy CI logs, and screenshot-to-UI fidelity checks cleanly. |
| **Automated PR Reviews & Backlog Tickets** | Auto / Balanced Coding Agent | Low – Med | Predictable cost per PR across high-volume repositories; escalate to Max depth only on core services. |

#### B Controlling AI Credit Budgets

- **Set Soft & Hard Caps:** Org admins can configure monthly AI credit budgets per team or cost center with 75% / 90% webhook alerts.
- **Start with Plan Mode:** Spend one reasoning turn drafting a crisp plan, then execute the edits with a faster standard model.
- **Prune Stale Threads:** Long 40-turn Agent chats re-send massive histories; open a fresh thread per ticket or subtask.

#### G Enterprise Model Policy Controls

- **Allowlist by Compliance Tier:** Enable or disable specific third-party model families (Anthropic, Google, OpenAI) at the Enterprise or Org level.
- **Preview Feature Gating:** Restrict experimental models and insiders MCP endpoints to a pilot engineering group before org-wide rollout.
- **Usage Telemetry:** Export per-model adoption and credit consumption via the GitHub Copilot Metrics API for quarterly ROI reviews.

## 8. 5 Copy-Paste Copilot Agent Mode & GitHub MCP Recipes

Drop these five battle-tested configurations directly into your repository to unlock read-only triage, monorepo guardrails, automated CI log healing, security-focused PR reviews, and high-success Coding Agent tickets.

| # | Recipe | Target File | Outcome |
| --- | --- | --- | --- |
| **1** | Read-Only Triage MCP | `.vscode/mcp.json` | Safe issue/PR/Actions inspection with zero write risk. |
| **2** | Monorepo `AGENTS.md` | `AGENTS.md` | Portable build/test/forbidden-path rules for all agents. |
| **3** | CI Failure Auto-Healer | `.github/prompts/fix-ci.prompt.md` | Pulls failing Actions logs via MCP and patches locally. |
| **4** | Security Review Rules | `.github/instructions/sec.instructions.md` | Tunes Copilot Code Review to catch OWASP & auth flaws. |
| **5** | `@copilot` Issue Template | `.github/ISSUE_TEMPLATE/agent.yml` | Structures tickets for 90%+ first-pass Coding Agent PRs. |

Recipe 1 • Read-Only Triage MCP (`.vscode/mcp.json`)

```
<code>{
  <span class="ck-key">"servers"</span>: {
    <span class="ck-key">"github-triage"</span>: {
      <span class="ck-key">"type"</span>: <span class="ck-str">"http"</span>,
      <span class="ck-key">"url"</span>: <span class="ck-str">"https://api.githubcopilot.com/mcp/readonly"</span>,
      <span class="ck-key">"headers"</span>: {
        <span class="ck-hdr">"X-MCP-Toolsets"</span>: <span class="ck-str">"issues,pull_requests,actions"</span>,
        <span class="ck-sec">"X-MCP-Lockdown"</span>: <span class="ck-str">"true"</span>
      }
    }
  }
}</code>
```

Recipe 2 • Monorepo Guardrail Header (`AGENTS.md`)

```
<code><span class="ck-hdr"># Repository Agent Contract</span>
- <span class="ck-key">Install:</span> `pnpm install <span class="nowrap">--frozen-lockfile</span>`
- <span class="ck-key">Verify:</span> `pnpm turbo run typecheck lint test`
- <span class="ck-sec">Forbidden:</span> Never edit `infra/prod/**`, `.env*`, or lockfiles
  unless explicitly requested in the issue body.
- <span class="ck-key">PR Style:</span> Small diffs (<400 LOC), include unit tests.</code>
```

Recipe 3 • CI Auto-Healer (`.github/prompts/fix-ci.prompt.md`)

```
<code><span class="ck-hdr">---</span>
<span class="ck-key">mode:</span> <span class="ck-str">"agent"</span>
<span class="ck-key">tools:</span> [<span class="ck-str">"github/list_workflow_runs"</span>, <span class="ck-str">"github/get_job_logs"</span>, <span class="ck-str">"terminal"</span>]
<span class="ck-hdr">---</span>
Fetch the latest failed GitHub Actions run for my current branch,
extract the root-cause stack trace, apply the minimal fix locally,
and re-run the failing test command until green.</code>
```

Recipe 4 • Security PR Review (`.github/instructions/sec.instructions.md`)

```
<code><span class="ck-hdr">---</span>
<span class="ck-key">applyTo:</span> <span class="ck-str">"**"</span>
<span class="ck-hdr">---</span>
<span class="ck-cmt"># Code Review Focus (High Signal Only)</span>
Flag ONLY high-impact defects; skip formatting nitpicks:
1. Unparameterized SQL, XSS sinks, or SSRF in fetch calls.
2. Missing auth/tenant-ID checks on new API handlers.
3. Hardcoded secrets, tokens, or verbose PII in logs.
4. Unbounded loops, missing timeouts, or N+1 DB queries.</code>
```

Recipe 5 • Agent-Ready Issue Template (`.github/ISSUE_TEMPLATE/agent.yml`)

```
<code><span class="ck-key">name:</span> <span class="ck-str">Copilot Coding Agent Task</span>
<span class="ck-key">description:</span> <span class="ck-str">Well-scoped ticket optimized for @copilot</span>
<span class="ck-key">labels:</span> [<span class="ck-str">"copilot-ready"</span>]
<span class="ck-key">body:</span>
  - <span class="ck-key">type:</span> <span class="ck-str">textarea</span>
    <span class="ck-key">id:</span> <span class="ck-str">scope</span>
    <span class="ck-key">attributes:</span>
      <span class="ck-key">label:</span> <span class="ck-str">Target Files & Acceptance Criteria</span>
      <span class="ck-key">placeholder:</span> <span class="ck-str">"Files: src/auth/*.ts\n- Add rate limit..."</span>
  - <span class="ck-key">type:</span> <span class="ck-str">input</span>
    <span class="ck-key">id:</span> <span class="ck-str">verify</span>
    <span class="ck-key">attributes:</span>
      <span class="ck-key">label:</span> <span class="ck-str">Verification Command</span>
      <span class="ck-key">value:</span> <span class="ck-str">"pnpm vitest run"</span></code>
```

#### Quick Test for Recipe 5

Issues that specify **exact file paths + one runnable test command** achieve dramatically higher first-pass merge rates from `@copilot` than open-ended feature requests.

## 9. Hardening Autonomous Agents: Firewall, Exclusions & Audit

Autonomous agents execute shell commands, call external APIs through MCP, and open pull requests at machine speed. Enterprise security teams must pair developer autonomy with four non-negotiable guardrails across egress networking, file exclusions, secret protection, and audit telemetry.

### Enterprise 4-Pillar Security Matrix

| Security Pillar | Risk Mitigated | Recommended Control | Verification Check |
| --- | --- | --- | --- |
| **Coding Agent Firewall** | Prompt-injected data exfiltration or unauthorized package downloads from Actions sandboxes. | Keep the default egress firewall ON with GitHub's recommended allowlist; review every custom domain entry. | Test blocked `curl` in a scratch Coding Agent session; verify firewall logs. |
| **Content Exclusions** | Sensitive credentials, customer PII, or proprietary algorithms leaking into prompts or reviews. | Configure org-wide glob exclusions for `.env*`, `**/secrets/**`, `*.pem`, and `*.key`. | Confirm excluded files show the blocked icon in VS Code & are skipped by Code Review. |
| **Secret Scanning & Push Protection** | Agents accidentally committing hardcoded test tokens or leaking env vars into PR diffs. | Enable GitHub Push Protection + Branch Protection + manual Actions workflow approval on agent PRs. | Require 1+ human CODEOWNERS approval & green CodeQL check before merge. |
| **MCP Governance & SIEM Audit** | Over-privileged third-party MCP servers or unmonitored agent mutations across org repos. | Enforce Enterprise MCP Registry allowlists, OAuth 2.1 scopes, `X-MCP-Lockdown`, and SIEM audit streaming. | Query SIEM for `copilot.mcp_*` and `copilot.agent_*` events weekly. |

#### Z Zero-Trust MCP Hardening Checklist

- **Prefer Remote OAuth:** Retire static PATs; OAuth 2.1 enforces per-user RBAC and instant revocation.
- **Default Read-Only:** Start new MCP connections on `/readonly` and opt into write toolsets only per repo.
- **Block Untrusted Inputs:** Enable `X-MCP-Lockdown: true` on public or open-source repositories to stop indirect prompt injection from external comments.
- **Pin Enterprise Registry:** Restrict VS Code & Coding Agent to admin-approved MCP servers via Enterprise Policy.

#### E Phased Enterprise Rollout (4 Weeks)

- **Week 1 (Policies):** Set Content Exclusions, Public Code Matching, and Enterprise MCP Registry allowlists.
- **Week 2 (Pilot):** Enable VS Code Agent Mode + Remote GitHub MCP on 2 non-production repos with `AGENTS.md`.
- **Week 3 (Cloud Sandbox):** Add `copilot-setup-steps.yml` + Branch Ruleset Copilot Code Review (Balanced).
- **Week 4 (Telemetry):** Stream audit logs to Splunk/Sentinel, review AI credit burn, and publish internal templates.

#### Critical Rule: Never Run Copilot Coding Agent on Deployment Runners

Always run `copilot-setup-steps.yml` on **ephemeral GitHub-hosted runners** (or dedicated, network-isolated ephemeral self-hosted runners) with `permissions: contents: read`. Never assign Coding Agent to a runner pool that holds cloud deployment credentials, production kubeconfigs, or persistent disk state.

## 10. End-to-End Autonomous Delivery: Design to Merged PR

Maximum velocity happens when GitHub Copilot and MCP connect your entire product toolchain—turning Figma frames and Linear/Jira tickets into structured GitHub Issues, autonomous Coding Agent PRs, green Actions CI builds, and pre-screened human merges.

### 5-Stage Connected Engineering Pipeline

#### 1 Design & Issue Handoff

Connect Figma MCP and Linear/Jira MCP alongside GitHub MCP inside VS Code. Use a `/spec-to-issue` prompt to read Figma design tokens and create a crisp, file-anchored GitHub Issue in seconds.

#### 2 Parallel Autonomous Build

Assign 3–5 independent backlog tickets to `@copilot` at once. Each runs in its own firewalled Actions sandbox using `copilot-setup-steps.yml` and opens a clean Draft PR with passing unit tests.

#### 3 High-Leverage Review Gate

Branch rulesets trigger Copilot Code Review automatically on every PR. Humans review architecture, edge cases, and business logic—never formatting or missing null checks—and tag `@copilot` for quick revisions.

#### The 80/20 Handoff Pattern: Pair Local + Cloud Together

Don't treat VS Code Agent Mode and Cloud Coding Agent as competing choices. **Prototype novel architecture synchronously in VS Code Agent Mode** where visual iteration is fastest; once the pattern is merged, **delegate the remaining 80% of repetitive rollout tickets** (migrating 12 routes, backfilling tests, updating SDK docs) to Cloud Coding Agent in parallel.

#### Sample Cross-MCP Orchestration Prompt (VS Code Agent Mode)

"Using `figma/get_design_context` on frame *Billing-Banner* and `github/get_issue` #512, scaffold the responsive banner in `src/components/BillingBanner.tsx`, run `pnpm test:ui`, and open a Draft PR referencing #512 via `github/create_pull_request`."

## 11. Troubleshooting Clinic (Top 7 Fixes) & Pre-Flight Checklist

When an autonomous workflow stalls, the cause is almost always a misconfigured toolset header, a firewalled Actions install, or bloated context. Use this clinic to diagnose issues in under two minutes, then run the 6-point pre-flight check before team rollout.

### Top 7 Copilot Agent Mode & GitHub MCP Fixes

| Symptom | Root Cause | Immediate Fix |
| --- | --- | --- |
| **1. Agent ignores custom instructions** | Wrong filename, invalid `applyTo` glob, or bloated 500+ line file diluted in context. | Verify exact paths (`.github/copilot-instructions.md` or `.github/instructions/*.instructions.md`); check References drawer in Chat to confirm injection. |
| **2. GitHub MCP OAuth fails or tools missing** | Enterprise MCP policy disabled, typo in `X-MCP-Toolsets`, or stale OAuth token. | Sign out/in of GitHub in VS Code Accounts; verify exact toolset names (`repos,issues,pull_requests,actions`) and org MCP policy status. |
| **3. Coding Agent fails `npm`/`pip` install** | Egress firewall blocks private registry or uncached downloads during agent execution. | Move dependency installs into `.github/workflows/copilot-setup-steps.yml` and add private registries to the Coding Agent firewall allowlist. |
| **4. Agent Mode loops & burns AI credits** | Unclear acceptance criteria, huge thread history, or missing test command in instructions. | Stop the loop, revert to the last Checkpoint, start a fresh thread in **Plan Mode**, and set `chat.agent.maxRequests` to `25`. |
| **5. Code Review leaves noisy style nitpicks** | No review-specific instructions; reviewer defaults to generic style checks. | Add a focused `.instructions.md` rule telling Copilot to flag only logic, auth, and security defects while ignoring formatting covered by Prettier/ESLint. |
| **6. MCP write calls rejected (403)** | Connected to `/readonly` URL, `X-MCP-Readonly: true` set, or user lacks repo write role. | Remove `/readonly` or set `X-MCP-Readonly: false` in `.vscode/mcp.json` and confirm your GitHub account has write access to the target repo. |
| **7. Content exclusions not blocking files** | Glob pattern syntax mismatch or surface hasn't refreshed org policy cache. | Use explicit repo-relative globs (`**/.env*`, `**/secrets/**`) in Org Copilot settings and reload VS Code window to pull updated policies. |

### 6-Point Production Pre-Flight Checklist

✓

**1. Repo Contract Committed:** Concise `.github/copilot-instructions.md` + `AGENTS.md` (<150 lines) with verified build, lint, and test commands.

✓

**2. Scoped Remote MCP:** `.vscode/mcp.json` points to `api.githubcopilot.com/mcp/` with OAuth 2.1, minimal `X-MCP-Toolsets`, and `X-MCP-Lockdown` on public repos.

✓

**3. Warm Actions Sandbox:** `.github/workflows/copilot-setup-steps.yml` runs cleanly on ephemeral runners with `contents: read` and pre-cached deps.

✓

**4. Ruleset PR Reviews:** Branch ruleset enables automatic Copilot Code Review (Balanced/Max) alongside required human CODEOWNERS approval.

✓

**5. Security Guardrails Active:** Coding Agent firewall enabled, org Content Exclusions verified on `.env*`, and Push Protection + CodeQL enforced.

✓

**6. Credit & Model Governance:** Team AI credit budgets configured with alert webhooks, model allowlists set, and audit logs streaming to SIEM.

#### Ready to Ship Autonomously

Scope your instructions, wire zero-PAT GitHub MCP, and let `@copilot` turn clean backlog issues into verified PRs.

Edition: Nov 2026

---

## Edition Note & Attribution

This 12-page handbook, its topic structure, and its illustrations were generated with AI under human editorial direction and print-layout QA. Verify commands, pricing tiers, and security settings against official vendor documentation before production use.

- AI & Editorial Disclosure: https://twelve-pages.com/editorial
- Terms & Licensing: https://twelve-pages.com/terms
- Privacy & Cookie Notice: https://twelve-pages.com/privacy
