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.
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.
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.
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. |
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.
Swipe horizontally to view the full interactive workspace mockup
• src/db/idempotency.ts +28 -0 [Keep | Undo]
• tests/webhooks.test.ts +24 -4 [Keep | Undo]
Start ambiguous features in Plan Mode to generate an editable Markdown execution plan, then switch to Agent Mode to execute file writes and tests.
Hot-swap between Claude Sonnet/Opus, GPT-5.x, and Gemini Pro mid-thread without losing workspace context or MCP tool state.
Toggle individual MCP servers and toolsets on/off per session. Keeping active tools under 35 maximizes tool-calling accuracy.
Attach exact files (#file), terminal output (#terminalSelection), or repo prompt files (/add-endpoint) to ground the first turn.
Every Agent turn creates a restore checkpoint. Review inline hunks with Keep / Undo before staging commits so no silent regressions slip in.
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).
Click Delegate to Cloud Agent to package your current thread, branch context, and acceptance criteria into an async GitHub Actions session.
"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.
.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. |
.github/instructions/api.instructions.md---
applyTo: "src/api/**/*.ts,src/routes/**/*.ts"
---
# API Route Engineering Standards
- 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..github/prompts/new-endpoint.prompt.md---
mode: "agent"
tools: ["codebase", "terminal", "github/get_issue"]
---
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..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.
.vscode/mcp.json){
"servers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"X-MCP-Toolsets": "repos,issues,pull_requests,actions",
"X-MCP-Readonly": "false",
"X-MCP-Lockdown": "true"
}
}
}
}{
"inputs": [{
"id": "gh_pat", "type": "promptString", "password": true
}],
"servers": {
"github-local": {
"command": "docker",
"args": ["run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server", "--toolsets=repos,issues"],
"env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "${input:gh_pat}" }
}
}
}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. |
X-MCP-Toolsets or X-MCP-Exclude-Tools trims thousands of JSON schema tokens per turn and sharpens agent tool selection.
/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.
Include target file paths, clear acceptance criteria, and the exact test command.
Select Copilot in Issue Assignees, pick a model, or delegate directly from VS Code / CLI.
Runs copilot-setup-steps.yml, edits code, runs linters/tests, and self-reviews diffs.
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.
name: "Copilot Setup Steps"
on:
workflow_dispatch:
push:
paths: [".github/workflows/copilot-setup-steps.yml"]
jobs:
copilot-setup-steps: # Exact job name required by GitHub Copilot
runs-on: ubuntu-latest # Ephemeral runner — NEVER a deploy runner
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: "22", cache: "pnpm" }
- run: corepack enable && pnpm install --frozen-lockfile
- run: pnpm build:types # Pre-generate types so agent typecheck runs fast- 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.
- Batch Your Feedback: Use GitHub's Start a review workflow to submit 3–5 inline comments in one review round so
@copilotaddresses 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.
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.
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. |
- 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.
- 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. |
.vscode/mcp.json){
"servers": {
"github-triage": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/readonly",
"headers": {
"X-MCP-Toolsets": "issues,pull_requests,actions",
"X-MCP-Lockdown": "true"
}
}
}
}AGENTS.md)# Repository Agent Contract
- Install: `pnpm install --frozen-lockfile`
- Verify: `pnpm turbo run typecheck lint test`
- Forbidden: Never edit `infra/prod/**`, `.env*`, or lockfiles
unless explicitly requested in the issue body.
- PR Style: Small diffs (<400 LOC), include unit tests..github/prompts/fix-ci.prompt.md)---
mode: "agent"
tools: ["github/list_workflow_runs", "github/get_job_logs", "terminal"]
---
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..github/instructions/sec.instructions.md)---
applyTo: "**"
---
# Code Review Focus (High Signal Only)
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..github/ISSUE_TEMPLATE/agent.yml)name: Copilot Coding Agent Task
description: Well-scoped ticket optimized for @copilot
labels: ["copilot-ready"]
body:
- type: textarea
id: scope
attributes:
label: Target Files & Acceptance Criteria
placeholder: "Files: src/auth/*.ts\n- Add rate limit..."
- type: input
id: verify
attributes:
label: Verification Command
value: "pnpm vitest run"@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. |
- Prefer Remote OAuth: Retire static PATs; OAuth 2.1 enforces per-user RBAC and instant revocation.
- Default Read-Only: Start new MCP connections on
/readonlyand opt into write toolsets only per repo. - Block Untrusted Inputs: Enable
X-MCP-Lockdown: trueon 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.
- 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.
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
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.
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.
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.
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
.github/copilot-instructions.md + AGENTS.md (<150 lines) with verified build, lint, and test commands..vscode/mcp.json points to api.githubcopilot.com/mcp/ with OAuth 2.1, minimal X-MCP-Toolsets, and X-MCP-Lockdown on public repos..github/workflows/copilot-setup-steps.yml runs cleanly on ephemeral runners with contents: read and pre-cached deps..env*, and Push Protection + CodeQL enforced.@copilot turn clean backlog issues into verified PRs.