GitHub Copilot: Your AI Pair Programmer

This guide provides an interactive cheatsheet of GitHub Copilot's basic usage and settings. Explore the sections below to learn how to leverage this powerful AI assistant to write code faster, learn new concepts, and stay in the flow.

Automatic AI Code Reviews (Github.com)

GitHub Copilot can automatically review your pull requests, providing AI-powered feedback on code quality, security issues, and best practices. Set up automatic code reviews using repository rulesets to ensure consistent review coverage across your project.

What Copilot Reviews

Code Quality: Identifies potential bugs, code smells, and performance issues

Security Vulnerabilities: Detects common security patterns and potential risks

Best Practices: Suggests improvements following language conventions

Documentation: Recommends adding comments and documentation

Setup with Rulesets

Step 1: Navigate to your repository settings

Repository → Settings → Rules → Rulesets

Step 2: Create a new ruleset

New ruleset → Branch ruleset → Target branches: main

Step 3: Enable Copilot code review

Branch protections → Require pull request reviews
→ Enable "Require Copilot code review"


Pro Tips for Effective Reviews

Configure Review Triggers:

Set rules to trigger reviews only for specific file types or directories

Combine with Human Reviews:

Use Copilot reviews alongside required human reviewer approvals

Customize Review Scope:

Focus reviews on critical paths like security-sensitive code

Review History:

Track Copilot's suggestions over time to improve code quality

Getting Started in VS Code (Or other IDEs)

1. Install the Extension

Open VS Code, navigate to the Extensions view (Ctrl+Shift+X), search for "GitHub Copilot", and click install. This adds the AI capabilities directly into your editor environment.

2. Authenticate Your Account

After installation, VS Code will prompt you to log in with your GitHub account. You must have an active GitHub Copilot subscription (Individual, Business, or Enterprise) to authorize and activate the service.

Getting Started in Xcode

For full documentation see the docs

1. Install GitHub Copilot for Xcode

Install via Homebrew: brew install --cask github-copilot-for-xcode

Or download the DMG from the latest release and drag "GitHub Copilot for Xcode" into your Applications folder.

2. Open App & Accept Security

Open "GitHub Copilot for Xcode" from Applications folder and accept the macOS security warning. A background item will be added automatically for the extension to function.

3. Grant Required Permissions

Three permissions are required: Background, Accessibility, and Xcode Source Editor Extension. Accept the Accessibility permission when prompted, then manually enable the Xcode Source Editor Extension in System Preferences > Extensions.

4. Sign In & Configure

Click "Sign in" in the settings app to authenticate with your GitHub Copilot subscription. Verify the "GitHub Copilot" menu appears in Xcode's Editor menu.

Tip: Disable "Predictive code completion" in Xcode Preferences > Text Editing to avoid conflicts.

Core Features

GitHub Copilot's power comes from its seamless integration into your workflow. Its two primary modes of interaction are inline code completion, which works as you type, and Copilot Chat, a conversational interface for more complex queries. Select a feature below to learn more about how it works.

Inline Code Completion

As you write code or comments, Copilot provides "ghost text" suggestions directly in your editor. This is ideal for boilerplate code, completing logical next steps, and generating repetitive patterns.

Tab Accept: Press the `Tab` key to accept the current suggestion.
Alt + ] Cycle Suggestions: Use `Alt` (or `Option` on Mac) + `]` and `[` to cycle through alternative suggestions.
Esc Dismiss: Simply press `Esc` or continue typing to ignore the suggestion.

Interaction Modes

GitHub Copilot offers different interaction modes to suit various development tasks. Understanding when and how to use Ask, Edit, and Agent modes will help you work more efficiently with your AI pair programmer.

Ask Mode

Perfect for getting explanations, learning new concepts, and understanding existing code.

Code Explanations: "Explain this function" or "How does this algorithm work?"
Learning: "What's the difference between async/await and promises?"
Research: "What are the best practices for error handling in Node.js?"

Edit Mode

Ideal for making specific changes to existing code with precise control over modifications.

Refactoring: "Refactor this function to use modern ES6 syntax"
Bug Fixes: "Fix the null pointer exception in this method"
Feature Addition: "Add error handling to this API call"

Agent Mode

Powerful autonomous assistance for complex, multi-step tasks that span multiple files.

Multi-file Tasks: "Create a complete REST API with routes, models, and tests"
Complex Workflows: "Set up authentication with JWT tokens across the app"
Project Setup: "Initialize a React app with TypeScript and testing"

Choosing the Right Mode

Use Ask When:

  • • You need to understand code
  • • Learning new concepts
  • • Exploring options
  • • Getting documentation

Use Edit When:

  • • Making targeted changes
  • • Fixing specific issues
  • • Refactoring existing code
  • • Adding single features

Use Agent When:

  • • Building new features
  • • Multi-file operations
  • • Complex implementations
  • • Project scaffolding

Command Reference

Copilot Chat includes a powerful set of slash commands and context variables to streamline your workflow. Use the search bar below to quickly find a command and understand its purpose.

NOTE: Commands do not function in agent mode as they are essentially redundant - simply ask for what you need.

Settings & Best Practices

To get the most out of GitHub Copilot, it's helpful to understand its key settings and follow best practices for interacting with the AI. This ensures you receive the most relevant, secure, and useful suggestions for your project.

Key Settings in VS Code

Access these via `File > Settings` and search for "Copilot" to customize your experience.

Best Practices

Effective use comes from clear communication and diligent review.

Be Specific: Provide clear, detailed prompts and comments. The more context you give, the better the result.
Iterate & Refine: Don't expect perfection on the first try. Edit suggestions and provide follow-up prompts to guide Copilot.
Review & Understand: Always validate generated code for correctness, security, and project standards. You are the pilot.
Provide Context: Keep relevant files open to help Copilot understand your project. Use `@workspace` to reference the whole codebase.

Premium vs Basic Requests

Understanding Request Types

Basic Requests (Unlimited):

Code completions, simple explanations, and focused chat queries. These use efficient models and don't count against quotas.



Premium Requests (Limited):

Complex workspace analysis (@workspace), agent mode tasks using premium models (model select list shows basic ones as "included"), and multi-step operations using advanced AI models.

Check Your Usage

Monitor your premium request usage directly in your IDE by clicking the Copilot status icon in the status bar at the bottom (image shows VS Code).

GitHub Copilot usage status screenshot