Ravindra BagaleCourses & study guides Track your progress
AI CODING ASSISTANTS · CHAPTER 2

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

WHY

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

WHAT
  • 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

1 · Install VS Code free editor 2 · Install the Copilot extension from the Marketplace 3 · Sign in with GitHub free or paid plan 4 · Accept a suggestion Tab on ghost text 5 · Use chat and agent side panel

Step-by-step setup

HOW · INSTALL
  1. Install VS Code and open it.
  2. Open Extensions with Ctrl+Shift+X (Mac: Cmd+Shift+X).
  3. Search "GitHub Copilot" and click Install. (Copilot Chat is included.)
  4. Sign in: a prompt appears — click Sign in to GitHub, approve in the browser, come back to VS Code.
  5. Check the status icon in the bottom bar. If it shows Copilot is active, you are ready.
Settings / config: open Settings (Ctrl+,) and search "Copilot" to turn inline suggestions on/off, enable/disable for some languages, or switch the chat model (if your plan offers choices).
COMPARISON CARDAI Coding

Copilot Free vs Paid (check current limits)

Free: a monthly cap on completions and chat messages; good to try it.
Pro / Business / Enterprise: unlimited completions, more models, agent features, admin controls.
Tip: plans change — confirm the current limits on github.com before you decide.
Ravindra Bagale · ravindrabagale.com/ai-coding

How to use it

  1. 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.
  2. See more options: press Ctrl+Enter to open a panel of alternative suggestions.
  3. 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".
  4. Inline chat: press Ctrl+I inside the editor to ask about the selected code right there.
  5. Agent mode: in the chat panel switch to Agent, give a goal, and approve its file edits and commands.

First test (try it now)

  1. Make a file hello.py.
  2. Type the comment: # function that returns the average of a list of numbers and press Enter.
  3. Accept the suggestion with Tab, then run it and check the result.
Rule: read and run every suggestion. Copilot can suggest code that looks right but is wrong.

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.

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.

Practice label: Lotus Lane Library and its late fee rule are fictional teaching data. It is not a real library, and no real member data is used. Passing these tests proves only the listed cases.
Environment (tested): on 16 November 2026 the starter and fixed files below were run on this course's Linux build machine with 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.
Checked against official docs: every menu name, command and setting in this practice was checked on 16 November 2026 against the VS Code Copilot setup, troubleshooting and FAQ pages on code.visualstudio.com and the GitHub Copilot troubleshooting page on docs.github.com. These tools update often. If a menu name looks different on your screen, search for the same words in the official docs or the Command Palette, and do not guess.

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)

HOW
  1. Create the practice folder with the name shown below, and save the two files from this section inside it.
  2. Create a virtual environment: on macOS or Linux run python3 -m venv .venv. On Windows run py -3 -m venv .venv.
  3. 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.
  4. 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):

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."""
    # Starter bugs: there is no cap at 50, and negative days are not rejected.
    return days_late * 5

Simple tests test_late_fee.py:

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.txt
In 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

HOW
  1. Open the folder: in VS Code choose File and then Open Folder, and pick lotus-lane-fees.
  2. 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.
  3. Check inline suggestions: create a scratch file named scratch.py and 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 delete scratch.py.
  4. Open chat: open the Chat view with Ctrl+Alt+I on Windows or Linux (Ctrl+Cmd+I on Mac), keep late_fee.py open in the editor, and paste the prompt above.
  5. 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.
  6. 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

HOW
  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.

PRACTICE CARDAI Coding

Prove the setup with tests

Run pytest before and after you ask Copilot for a fix.
When the result moves from 3 failed to 6 passed, the extension, sign-in and chat are all working.
Ravindra Bagale · ravindrabagale.com/ai-coding
PRACTICE CARDAI Coding

Never let the AI edit the tests

The tests describe the correct late fee, so they must stay unchanged.
If Copilot edits the test file, undo that change and ask it to fix only late_fee.py.
Ravindra Bagale · ravindrabagale.com/ai-coding
सराव कार्डमराठी

Tests ने setup सिद्ध करा

Copilot ला fix मागण्याआधी आणि नंतर pytest चालवा.
3 failed वरून 6 passed झालं की extension, sign in आणि chat तिन्ही चालतात हे समजतं.
Ravindra Bagale · ravindrabagale.com/ai-coding
सराव कार्डमराठी

AI ला tests बदलू देऊ नका

Tests बरोबर late fee काय आहे ते सांगतात, म्हणून ते तसेच राहिले पाहिजेत.
Copilot ने test file बदलली तर तो बदल undo करा आणि फक्त late_fee.py fix करायला सांगा.
Ravindra Bagale · ravindrabagale.com/ai-coding

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

SMART AI USE

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

INTERVIEW CARDAI Coding

How do you add Copilot to VS Code?

Answer: install the GitHub Copilot extension from the Marketplace, sign in with a GitHub account that has a Copilot plan, then accept suggestions with Tab.
Key line: chat is Ctrl+Alt+I (Mac: Ctrl+Cmd+I); agent mode edits files with approval.
Ravindra Bagale · ravindrabagale.com/ai-coding
REVISION CARDAI Coding

Copilot in VS Code in 3 ideas

1 Install: Extensions → GitHub Copilot → Install.
2 Sign in: GitHub account + Copilot plan.
3 Use: Tab = accept, chat panel = ask, agent = multi-file.
Ravindra Bagale · ravindrabagale.com/ai-coding

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.

Next in this course: How to Code in Python Using AI.