How to Set Up GitHub Copilot in VS Code
Install one extension, sign in with GitHub, and start getting code suggestions in minutes. This guide shows every step in plain words.
In short: install VS Code, add the GitHub Copilot extension, sign in with a GitHub account that has a Copilot plan, and use Tab, chat and agent mode.
Why Copilot in VS Code
VS Code is free and the most used editor. GitHub Copilot is the most popular assistant for it. Together they give inline suggestions, a chat panel, and an agent that can edit files — a great first setup for any student.
What you need
- VS Code (free, from code.visualstudio.com).
- A GitHub account (free to make).
- A Copilot plan: there is a free tier with monthly limits, plus Pro/Business/Enterprise. Confirm current limits on github.com.
The whole setup, top to bottom
Step-by-step setup
- Install VS Code and open it.
- Open Extensions with Ctrl+Shift+X (Mac: Cmd+Shift+X).
- Search "GitHub Copilot" and click Install. (Copilot Chat is included.)
- Sign in: a prompt appears — click Sign in to GitHub, approve in the browser, come back to VS Code.
- Check the status icon in the bottom bar. If it shows Copilot is active, you are ready.
Copilot Free vs Paid (check current limits)
How to use it
- Inline: start typing or write a comment like
# read a CSV and print the first 5 rows. Grey ghost code appears — press Tab to accept, or Esc to reject. - See more options: press Ctrl+Enter to open a panel of alternative suggestions.
- Chat: press Ctrl+Alt+I (Mac: Ctrl+Cmd+I) or click the chat icon. Ask "explain this file" or "write a test for this function".
- Inline chat: press Ctrl+I inside the editor to ask about the selected code right there.
- Agent mode: in the chat panel switch to Agent, give a goal, and approve its file edits and commands.
First test (try it now)
- Make a file
hello.py. - Type the comment:
# function that returns the average of a list of numbersand press Enter. - Accept the suggestion with Tab, then run it and check the result.
Safety
- Do not paste secrets or real customer data into chat.
- Turn on duplication detection in settings if your org needs it.
- For private code that must stay offline, use a local model instead (Ollama + Continue).
Verify your setup: make Copilot fix a small library late-fee bug
Hello friends. The chapter above showed how to install Copilot and sign in. Now we prove that the setup really works on your machine. You will open a tiny practice folder for a fictional library called Lotus Lane Library, check that Copilot is signed in, see one grey inline suggestion, and then ask Copilot Chat to fix a late fee bug. The tests tell you the truth: the starter file fails 3 tests and passes 3, and a correct fix passes all 6.
नमस्कार मित्रांनो. वरच्या chapter मध्ये आपण Copilot install करून sign in कसं करायचं ते पाहिलं. आता setup खरंच तुमच्या machine वर चालतो का, ते तपासूया. Lotus Lane Library नावाच्या काल्पनिक library चा एक छोटा practice folder उघडा. Copilot sign in आहे का ते बघा, एक grey inline suggestion बघा, आणि मग Copilot Chat ला late fee चा bug fix करायला सांगा. खरं काय ते tests सांगतात: starter file मध्ये 3 tests fail आणि 3 pass होतात, आणि बरोबर fix केल्यावर सगळे 6 pass होतात.
नमस्ते दोस्तों. ऊपर के chapter में हमने Copilot install करके sign in करना देखा. अब देखते हैं कि setup सच में आपकी machine पर चलता है या नहीं. Lotus Lane Library नाम की काल्पनिक library का एक छोटा practice folder खोलो. Copilot sign in है या नहीं देखो, एक grey inline suggestion देखो, और फिर Copilot Chat से late fee का bug ठीक करवाओ. सच tests बताते हैं: starter file में 3 tests fail और 3 pass होते हैं, और सही fix के बाद सभी 6 pass होते हैं।
Ravindra Bagale's Tip
Run the tests before and after you ask Copilot. If the count goes from 3 failed to 6 passed, your extension, sign-in and chat all work. Read every line Copilot changes before you keep it.
Ravindra Bagale's Tip – मराठी
Copilot ला विचारण्याआधी आणि नंतर tests चालवा. 3 failed वरून 6 passed झालं, तर extension, sign in आणि chat तिन्ही चालतात. Copilot ने बदललेली प्रत्येक ओळ ठेवण्याआधी वाचा.
Ravindra Bagale's Tip – हिंदी
Copilot से पूछने से पहले और बाद में tests चलाओ. 3 failed से 6 passed हुआ, तो extension, sign in और chat तीनों चल रहे हैं. Copilot की बदली हर line रखने से पहले पढ़ो।
Python 3.13.5 and pytest 9.1.1. Starter: 3 failed, 3 passed. Fixed file: 6 passed. The AI tool itself runs on your own computer, so its words will differ from any example here.Your task: open the practice folder in VS Code, confirm Copilot is signed in, and ask Copilot Chat to make late_fee charge 5 rupees per day late, never more than 50 rupees, and reject negative days with a message that contains days_late.
Setup (practice folder lotus-lane-fees)
- Create the practice folder with the name shown below, and save the two files from this section inside it.
- Create a virtual environment: on macOS or Linux run
python3 -m venv .venv. On Windows runpy -3 -m venv .venv. - Activate it: on macOS or Linux run
source .venv/bin/activate. In Windows Command Prompt run.venv\Scripts\activate.bat, and in Windows PowerShell run.venv\Scripts\Activate.ps1. - Install pytest inside the virtual environment:
python -m pip install pytest.
Starter late_fee.py (no cap at 50 rupees, and negative days are accepted):
"""Lotus Lane Library late fee helper (fictional teaching library, not a real one)."""
def late_fee(days_late: int) -> int:
"""Return the late fee in rupees: 5 rupees per day late, capped at 50 rupees."""
# Starter bugs: there is no cap at 50, and negative days are not rejected.
return days_late * 5
Simple tests test_late_fee.py:
import pytest
from late_fee import late_fee
def test_on_time_is_free():
assert late_fee(0) == 0
def test_three_days_late():
assert late_fee(3) == 15
def test_ten_days_reaches_cap():
assert late_fee(10) == 50
def test_eleven_days_stays_at_cap():
assert late_fee(11) == 50
def test_thirty_days_stays_at_cap():
assert late_fee(30) == 50
def test_negative_days_rejected():
with pytest.raises(ValueError, match="days_late"):
late_fee(-1)
Before you ask the AI, run python -m pytest -q in the folder. You should see 3 failed, 3 passed. That proves Python and pytest work before the AI tool is involved.
The exact prompt to try (copy it as it is):
copilot-prompt.txtIn late_fee.py, fix late_fee for the fictional Lotus Lane Library. Charge 5 rupees per day late, but never more than 50 rupees. Raise ValueError with a message that contains days_late when days_late is negative. Keep the function name and do not change test_late_fee.py. Explain the change in two short sentences.
HOW to verify your Copilot setup
- Open the folder: in VS Code choose File and then Open Folder, and pick
lotus-lane-fees. - Check that you are signed in: hover over the Copilot icon in the Status Bar at the bottom. If you see Use AI Features, select it and finish the sign-in. If you have no paid plan, an eligible account is enrolled in Copilot Free.
- Check inline suggestions: create a scratch file named
scratch.pyand type the comment# function that returns True when a number is even, then press Enter. Grey ghost text should appear. Press Tab to accept it, and then deletescratch.py. - Open chat: open the Chat view with Ctrl+Alt+I on Windows or Linux (Ctrl+Cmd+I on Mac), keep
late_fee.pyopen in the editor, and paste the prompt above. - Review before you keep: read the proposed change line by line. Keep it only if it adds the cap and the negative check and leaves the test file alone.
- Run the tests again:
python -m pytest -q. Expect 6 passed.
What a correct result looks like: Copilot explains that the fee needs a cap and a check for negative days, and its change uses something like min(days_late * 5, 50) plus a ValueError whose message contains days_late. The exact words and code style change from run to run, which is fine. The result is correct only when pytest shows 6 passed. If Copilot edits test_late_fee.py, undo that change, because changing the tests hides the bug instead of fixing it.
Real pytest output after the fixed file:
pytest-after.txt...... [100%]
6 passed in 0.01s
Optional completed late_fee.py (try it yourself first)
Copilot may write the check in a different order. Any version is fine if all 6 tests pass and the test file is unchanged.
late_fee.py"""Lotus Lane Library late fee helper (fictional teaching library, not a real one)."""
def late_fee(days_late: int) -> int:
"""Return the late fee in rupees: 5 rupees per day late, capped at 50 rupees."""
if days_late < 0:
raise ValueError("days_late must be 0 or more")
return min(days_late * 5, 50)
Troubleshooting: common Copilot setup problems
- Problem: no grey ghost text appears. Fix: open the Copilot status dashboard from the Status Bar and check that inline suggestions are not turned off globally or for Python. On Copilot Free, also check whether you have used this month's inline suggestion allowance.
- Problem: Copilot says your subscription is not detected. Fix: VS Code must be signed in with the same GitHub account that has the plan. Open the Accounts menu in the Activity Bar, select Sign out, and sign in again with the right account.
- Problem: you are signed in to GitHub but Copilot is still unavailable. Fix: sign out from the Accounts menu, press F1 and run Developer: Reload Window, and then sign back in.
- Problem: chat does not work after an extension update. Fix: new Copilot Chat versions work only with the latest VS Code release, so run Code: Check for Updates from the Command Palette and restart.
- Problem: Copilot cannot connect on a college or office network. Fix: open the Command Palette and run GitHub Copilot: Chat Diagnostics. If a check fails, ask your network admin about the firewall, proxy or VPN.
- Problem: you see a rate limit message. Fix: wait a few minutes and try again. A short rate limit is separate from your monthly allowance.
- Problem: nothing above explains the error. Fix: run Output: Show Output Channels, pick GitHub Copilot or GitHub Copilot Chat, and read the errors near the time it failed. Remove code and personal details before you share any log.
Practice cards: English and spoken Marathi
Each card below explains one idea on its own, so you can save or revise a single card without reading the whole chapter.
Prove the setup with tests
Never let the AI edit the tests
Tests ने setup सिद्ध करा
AI ला tests बदलू देऊ नका
Quick quiz
1. Which key accepts an inline suggestion?
Tab (Esc rejects it).
2. How do you open Copilot chat?
Ctrl+Alt+I (Mac: Ctrl+Cmd+I), or click the chat icon.
3. What do you need besides VS Code?
A GitHub account with a Copilot plan (free tier or paid).
4. What does agent mode do?
Edits several files and can run commands, with your approval.
Save tokens and money
The free tier has monthly limits — use inline mode for small tasks and save chat for real problems. Ask short, clear questions. See more AI Coding guides.
Save these cards
How do you add Copilot to VS Code?
Copilot in VS Code in 3 ideas
More revision cards
These standalone cards cover the GH-300 GitHub Copilot certification and Copilot CLI in the terminal. Each card has an English page and a spoken Marathi page.
- GH-300 prep in 5 steps · मराठी
- GH-300 facts · मराठी
- What is the GH-300 exam? · मराठी
- Copilot CLI in 5 steps · मराठी
- Copilot CLI basics · मराठी
- What is GitHub Copilot CLI? · मराठी