GitHub Copilot Advanced Setup Guide: Configuration, Agents, and Workflow Integration

GitHub Copilot has evolved from an autocomplete tool into a multi-modal coding assistant with agent capabilities, custom instructions, and deep IDE integration. Most developers use 20% of what it offe

Introduction#

GitHub Copilot has evolved from an autocomplete tool into a multi-modal coding assistant with agent capabilities, custom instructions, and deep IDE integration. Most developers use 20% of what it offers. This guide covers the configuration layer and advanced features that separate basic tab-completion usage from a fully integrated AI-assisted development workflow.

Installation and Editor Setup#

VS Code#

Install the official extensions:

1
2
GitHub Copilot
GitHub Copilot Chat

Both are required. The Chat extension powers the inline chat, the sidebar panel, and agent mode.

After installation, sign in with your GitHub account that has an active Copilot subscription:

  1. Click the Accounts icon in the Activity Bar
  2. Select “Sign in with GitHub to use GitHub Copilot”
  3. Complete the OAuth flow in your browser

JetBrains IDEs (IntelliJ, GoLand, PyCharm, Rider)#

Install from the JetBrains Marketplace:

  1. Open Settings > Plugins > Marketplace
  2. Search for “GitHub Copilot”
  3. Install and restart the IDE
  4. Sign in via Tools > GitHub Copilot > Sign in

Neovim#

Use the official plugin:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
-- lazy.nvim configuration
{
  "github/copilot.vim",
  config = function()
    -- Disable default Tab mapping if you prefer manual trigger
    vim.g.copilot_no_tab_map = true
    vim.keymap.set("i", "<C-J>", 'copilot#Accept("\\<CR>")', {
      expr = true,
      replace_keycodes = false,
    })
    -- Enable for specific filetypes only
    vim.g.copilot_filetypes = {
      ["*"] = true,
      ["markdown"] = false,
      ["yaml"] = false,
    }
  end,
}

For Copilot Chat in Neovim, add CopilotChat.nvim:

1
2
3
4
5
6
7
8
9
{
  "CopilotC-Nvim/CopilotChat.nvim",
  dependencies = { "github/copilot.vim", "nvim-lua/plenary.nvim" },
  opts = {
    model = "claude-sonnet-4-5",
    context = "buffers",
    show_help = false,
  },
}

Custom Instructions: The Most Underused Feature#

Custom instructions are system-level prompts that Copilot applies to every interaction in your workspace. They eliminate the need to repeat project context in every chat prompt.

Repository-Level Instructions#

Create .github/copilot-instructions.md at your repository root:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Project Context
This is a Go microservice for payment processing using Gin, PostgreSQL,
and Redis. It runs on AWS ECS behind an ALB.

## Code Style
- Use structured logging via `pkg/logger` (zerolog wrapper), never fmt.Println
- All errors must be wrapped with `fmt.Errorf("context: %w", err)`
- Database queries belong in `internal/repository/`, not in service files
- Use `pkg/apierror` for all HTTP error responses
- Follow the handler pattern in `internal/handlers/health.go` for new handlers

## Testing
- Unit tests mock at the repository interface boundary
- Integration tests use testcontainers — see `internal/testhelpers/`
- Test files use table-driven tests, not repeated test functions

## Security
- No secrets in code — use AWS SSM Parameter Store via `pkg/config`
- All user input must be validated before reaching the service layer
- SQL queries must use parameterized statements, never string concatenation

## What to Avoid
- Do not use `database/sql` directly — use the wrapper in `pkg/db`
- Do not log request bodies or authorization headers
- Do not use global state or package-level variables

User-Level Instructions#

For instructions that apply across all your projects, configure them in VS Code settings:

1
2
3
4
5
6
7
8
9
10
11
12
13
{
  "github.copilot.chat.codeGeneration.instructions": [
    {
      "text": "Always use early returns to reduce nesting. Prefer explicit error handling over panics."
    },
    {
      "text": "When writing tests, use table-driven tests with a cases slice."
    },
    {
      "text": "Never use var declarations at package level. Prefer dependency injection."
    }
  ]
}

Instructions by Task Type#

VS Code lets you set separate instructions for different task types:

1
2
3
4
5
6
7
8
9
10
11
{
  "github.copilot.chat.codeGeneration.instructions": [
    { "file": ".github/copilot-instructions.md" }
  ],
  "github.copilot.chat.testGeneration.instructions": [
    { "file": ".github/copilot-test-instructions.md" }
  ],
  "github.copilot.chat.reviewSelection.instructions": [
    { "file": ".github/copilot-review-instructions.md" }
  ]
}

Example .github/copilot-test-instructions.md:

1
2
3
4
5
6
7
8
When generating tests:
- Use table-driven tests with a `cases` struct slice
- Name test functions `TestFunctionName_Scenario`
- Always test error paths, not just happy paths
- Use `testify/require` for assertions that should halt the test on failure
- Use `testify/assert` for non-fatal assertions
- Mock dependencies at interface boundaries using `testify/mock`
- Include at minimum: happy path, empty input, invalid input, error from dependency

Agent Mode for Multi-File Tasks#

Agent Mode gives Copilot the ability to read files, run terminal commands, and make changes across multiple files autonomously. It is the closest equivalent to an agentic coding workflow within VS Code.

Enabling Agent Mode#

In VS Code settings:

1
2
3
4
{
  "github.copilot.chat.agent.enabled": true,
  "chat.agent.maxRequests": 25
}

Open the chat panel and select “Agent” from the mode dropdown (or use @workspace).

Effective Agent Prompts#

Agent mode performs best with complete, outcome-oriented prompts:

1
2
3
4
5
6
7
8
9
Add pagination to the GET /users endpoint in internal/handlers/user.go.

Requirements:
- Accept `page` (default 1) and `page_size` (default 20, max 100) query params
- Return a response with shape: { data: [...], page: int, page_size: int, total: int }
- Add the corresponding repository method in internal/repository/user_repository.go
- Update the existing unit tests in internal/handlers/user_test.go to cover the
  pagination parameters
- Do not change the response shape of any other endpoints

Scoping Agent Context with #-References#

Use # references to direct agent attention to specific files or symbols rather than the entire workspace:

1
2
3
Refactor #file:internal/cache/redis.go to add a connection pool with a
configurable max size. The pool size should be read from the config
in #file:pkg/config/config.go. Keep the existing public interface unchanged.

Available references:

  • #file:path/to/file.go — specific file
  • #sym:FunctionName — specific symbol
  • #selection — currently selected code
  • #codebase — full workspace search

GitHub Copilot CLI#

Copilot CLI brings AI assistance to the terminal for shell commands, git operations, and explanations.

Installation#

1
2
3
4
npm install -g @githubnext/github-copilot-cli

# Authenticate
github-copilot-cli auth

Set up shell aliases:

1
2
# Add to ~/.zshrc or ~/.bashrc
eval "$(github-copilot-cli alias -- "$0")"

This installs three aliases: ?? (explain), git? (git commands), and gh? (GitHub CLI commands).

Usage Examples#

1
2
3
4
5
6
7
8
# Explain what a command does before running it
?? "find all files modified in the last 7 days and larger than 10MB"

# Get a git command for what you want to do
git? "undo the last commit but keep the changes staged"

# Get a gh CLI command
gh? "list all open PRs assigned to me across all repos in the org"

Direct Command Generation#

1
2
# Generate and optionally execute a shell command
github-copilot-cli suggest "compress all PNG files in ./assets/ to 80% quality"

Copilot in GitHub Actions#

GitHub Copilot integrates into GitHub Actions for automated code review on pull requests.

Automated PR Review#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# .github/workflows/copilot-review.yml
name: Copilot PR Review

on:
  pull_request:
    types: [opened, synchronize, ready_for_review]

permissions:
  pull-requests: write
  contents: read

jobs:
  review:
    if: github.event.pull_request.draft == false
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Request Copilot Review
        uses: github/copilot-pull-request-review@main
        with:
          reviewers: copilot

Copilot Autofix for Security Alerts#

Enable Copilot Autofix in your repository settings under Security > Code scanning. When CodeQL or third-party scanners detect a vulnerability, Copilot automatically generates a pull request with a fix.

This requires:

  1. GitHub Advanced Security (GHAS) enabled on the repository
  2. Code scanning alerts enabled
  3. Copilot Autofix toggled on in repository settings

VS Code Keybindings for Copilot Chat#

Default keybindings are not always optimal. Remap for faster access:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// keybindings.json
[
  {
    "key": "ctrl+shift+i",
    "command": "workbench.panel.chat.view.copilot.focus"
  },
  {
    "key": "ctrl+shift+/",
    "command": "github.copilot.interactiveEditor.explain",
    "when": "editorHasSelection"
  },
  {
    "key": "ctrl+shift+.",
    "command": "github.copilot.interactiveEditor.fix",
    "when": "editorHasSelection"
  },
  {
    "key": "alt+]",
    "command": "editor.action.inlineSuggest.showNext",
    "when": "inlineSuggestionHasCompletionWithInlineDetail && textInputFocus"
  },
  {
    "key": "alt+[",
    "command": "editor.action.inlineSuggest.showPrevious",
    "when": "inlineSuggestionHasCompletionWithInlineDetail && textInputFocus"
  }
]

Copilot Model Selection#

Copilot Chat lets you switch between underlying models. Access the model selector in the chat panel header.

Available models (availability varies by Copilot plan):

  • GPT-4o — General purpose, good balance of speed and quality
  • GPT-4o mini — Faster, lighter tasks
  • Claude Sonnet — Strong for code generation and analysis
  • Claude Opus — Complex reasoning, architecture decisions
  • o1 and o3 — Step-by-step reasoning for algorithmic problems

Set a default model in settings:

1
2
3
{
  "github.copilot.chat.defaultModel": "claude-sonnet-4-5"
}

Choose based on the task:

  • Inline completions and quick edits: GPT-4o mini
  • Code generation, refactoring, test writing: Claude Sonnet or GPT-4o
  • Architecture analysis, complex debugging: Claude Opus or o3

Copilot Extensions#

Copilot Extensions connect third-party tools directly into the Copilot Chat interface via @-mentions.

Official Extensions#

  • @docker — Generate Dockerfiles and Compose files, explain images
  • @sentry — Query Sentry issues, get fix suggestions in context
  • @datadog — Query metrics and logs from within the editor
  • @azure — Azure resource management and IaC generation

Installing Extensions#

Extensions are installed from the GitHub Marketplace as GitHub Apps:

  1. Go to GitHub Marketplace and search for Copilot Extensions
  2. Install the extension to your organization or personal account
  3. In VS Code Chat, mention the extension: @docker generate a multi-stage Dockerfile for a Go application

Building a Custom Extension#

For internal tooling, you can build a Copilot Extension that exposes your internal APIs:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import express from "express";
import { verifyAndParseRequest } from "@copilot-extensions/preview-sdk";

const app = express();
app.use(express.raw({ type: "application/json" }));

app.post("/", async (req, res) => {
  const { isValidRequest, payload } = await verifyAndParseRequest(
    req.body,
    req.headers["github-public-key-signature"] as string,
    req.headers["github-public-key-identifier"] as string,
    { token: req.headers.authorization?.split(" ")[1] }
  );

  if (!isValidRequest) {
    res.status(401).send("Unauthorized");
    return;
  }

  const userMessage = payload.messages[payload.messages.length - 1].content;

  // Call your internal API based on the user message
  const deploymentInfo = await fetchDeploymentStatus(userMessage);

  res.setHeader("Content-Type", "text/event-stream");
  res.write(
    `data: ${JSON.stringify({
      choices: [
        {
          delta: {
            content: `Current deployment status:\n\`\`\`json\n${JSON.stringify(deploymentInfo, null, 2)}\n\`\`\``,
          },
        },
      ],
    })}\n\n`
  );
  res.write("data: [DONE]\n\n");
  res.end();
});

app.listen(3000);

Workspace Configuration for Teams#

For consistent Copilot behavior across a development team, commit the following to your repository:

.github/copilot-instructions.md#

Shared project context and conventions (covered above).

.vscode/settings.json#

Workspace-scoped Copilot settings committed to the repo:

1
2
3
4
5
6
7
8
9
10
11
12
13
{
  "github.copilot.enable": {
    "*": true,
    "plaintext": false,
    "markdown": true,
    "yaml": true
  },
  "github.copilot.editor.enableAutoCompletions": true,
  "github.copilot.chat.localeOverride": "en",
  "github.copilot.chat.codeGeneration.useInstructionFiles": true,
  "github.copilot.chat.reviewSelection.enabled": true,
  "github.copilot.nextEditSuggestions.enabled": true
}

.vscode/extensions.json#

Recommend extensions to team members:

1
2
3
4
5
6
{
  "recommendations": [
    "github.copilot",
    "github.copilot-chat"
  ]
}

Content Exclusions for Sensitive Files#

Prevent Copilot from using sensitive files as context — credentials, internal configs, PII-containing data:

Repository-Level Exclusions#

In .github/copilot-workspace.yml:

1
2
3
4
5
6
7
8
copilot:
  content_exclusions:
    - path: ".env*"
    - path: "secrets/**"
    - path: "**/*.pem"
    - path: "**/*.key"
    - path: "terraform/environments/prod/**"
    - path: "migrations/seeds/**"

Organization-Level Exclusions#

Configure in your GitHub organization settings under Copilot > Content exclusions. These apply to all repositories in the organization and cannot be overridden at the repository level.

Troubleshooting#

Completions not appearing: Check the status bar icon at the bottom of VS Code. A spinning icon means it’s waiting; an X means there is an error. Check the Copilot output panel (View > Output > GitHub Copilot) for error details.

Chat responses ignore project conventions: Verify that .github/copilot-instructions.md exists and that github.copilot.chat.codeGeneration.useInstructionFiles is true in settings.

Agent mode not available: Ensure you are on the latest VS Code and have both the Copilot and Copilot Chat extensions updated. Agent mode requires Copilot Business or Enterprise plans in some regions.

Slow completions in large files: Copilot truncates context on very large files. Split large files and use #file: references in chat to target specific areas.

Suggestions from wrong language or framework: Check that file type associations are correct in VS Code (View > Output > GitHub Copilot Completions) and verify the file has the correct extension.

Best Practices for Teams#

Treat copilot-instructions.md as a living document. Review and update it when architectural decisions change, when new patterns are adopted, or when the team observes Copilot repeatedly suggesting code that violates conventions.

Review agent output before accepting. Agent mode makes real changes. Run your test suite after any agent session that touches multiple files. Use git to stage changes incrementally rather than accepting everything at once.

Calibrate completion trust by context. Copilot completions are highly reliable for boilerplate and patterns it has seen frequently. They are less reliable for internal APIs, custom frameworks, or domain-specific business logic. Apply proportionally more scrutiny in these areas.

Use inline chat for scoped edits, panel chat for reasoning. Inline chat (Ctrl+I) is optimal for editing a specific block. The chat panel is better for asking questions, planning, and multi-file reasoning. Match the tool to the task.

Conclusion#

The productivity gap between basic and advanced Copilot usage is almost entirely determined by configuration investment — primarily the custom instructions file and workspace settings. Once those are in place, agent mode and the CLI extend Copilot into multi-step workflows that go well beyond autocomplete. For teams, committing configuration to the repository ensures consistent behavior and eliminates the need for each developer to configure independently.

Contents