GitHub Copilot: Your AI Pair Programmer
GitHub Copilot is an AI coding assistant powered by OpenAI models, integrated directly into your IDE. It provides code completions, generates functions, writes tests, explains code, and helps debug — all in real time.
Plans
| Plan | Features |
|---|---|
| Copilot Free | 2,000 completions/month, 50 chat messages/month |
| Copilot Pro | Unlimited completions & chat, access to multiple models |
| Copilot Business | Organization management, policy controls |
| Copilot Enterprise | Fine-tuning on your codebase, knowledge bases |
Setup
VS Code
- Install the GitHub Copilot extension
- Sign in with your GitHub account
- Copilot is now active — start typing!
Visual Studio
- Go to Extensions → Manage Extensions
- Search for "GitHub Copilot"
- Install and sign in
JetBrains IDEs
- Go to Settings → Plugins
- Search for "GitHub Copilot"
- Install and authenticate
Code Completions
Copilot provides inline suggestions as you type. Press Tab to accept.
Example: Type a function signature
def calculate_mortgage_payment(principal, annual_rate, years):
# Copilot suggests the full implementation:
monthly_rate = annual_rate / 12 / 100
num_payments = years * 12
payment = principal * (monthly_rate * (1 + monthly_rate)**num_payments) / ((1 + monthly_rate)**num_payments - 1)
return round(payment, 2)
Tips for Better Completions
- Write clear function names —
calculate_shipping_costgets better suggestions thancalc - Add comments first — Describe what you want, then let Copilot implement
- Provide context — Open related files so Copilot understands your codebase
- Be specific in comments —
// Sort users by last login date, most recent first
Copilot Chat
Open the chat panel (Ctrl+Shift+I) for interactive AI assistance.
Common Questions
- "Explain this function" — Select code and ask for explanation
- "Find the bug in this code" — Paste problematic code
- "How do I connect to Azure SQL from .NET?"
- "Write unit tests for this class"
Chat Context
Copilot Chat understands:
- Current file — The file you have open
- Selected code — Any highlighted code
- Workspace — Files in your project (with @workspace)
- Terminal — Recent terminal output (with @terminal)
Slash Commands
Quick actions in the chat:
| Command | Description |
|---|---|
/explain |
Explain selected code |
/fix |
Suggest a fix for problems |
/tests |
Generate unit tests |
/doc |
Generate documentation |
/new |
Scaffold a new project |
/newNotebook |
Create a Jupyter notebook |
Example
/tests for the calculate_mortgage_payment function using pytest
Copilot generates:
import pytest
from calculator import calculate_mortgage_payment
def test_standard_mortgage():
result = calculate_mortgage_payment(300000, 6.5, 30)
assert result == 1896.20
def test_zero_principal():
result = calculate_mortgage_payment(0, 6.5, 30)
assert result == 0.0
def test_short_term():
result = calculate_mortgage_payment(100000, 5.0, 15)
assert result == 790.79
Chat Participants (@mentions)
| Participant | Purpose |
|---|---|
@workspace |
Ask about your entire project |
@terminal |
Ask about terminal output/errors |
@vscode |
Ask about VS Code settings and features |
Examples
@workspace How is authentication handled in this project?@terminal What caused this build error?@vscode How do I change the font size?
Copilot in the CLI
# Install
gh extension install github/gh-copilot
# Ask questions
gh copilot explain "git rebase -i HEAD~3"
# Suggest commands
gh copilot suggest "find all large files in this repo"
Best Practices
- Review all suggestions — Copilot is an assistant, not an authority. Always review generated code.
- Provide context — Comments, types, and good naming improve suggestions dramatically.
- Iterate — If the first suggestion isn't right, modify your prompt or add more context.
- Use chat for complex tasks — Inline completions are great for simple code; use chat for architecture questions, debugging, and learning.
- Keep sensitive data out — Don't paste API keys or secrets into chat.
Resources
Video: Watch the official GitHub Copilot intro on the GitHub YouTube channel.

Launched by Github
