Add helpful comments to your code with GitHub Copilot – beginner guide
A friendly step‑by‑step walkthrough that shows anyone how to get GitHub Copilot to write plain‑language comments for any line of code
Hook: By the end of this guide you’ll be able to ask GitHub Copilot to write easy‑to‑read comments above any line of code, even if you’ve never opened a code editor before. This tutorial is for absolute beginners who want to make their scripts clearer for themselves and anyone else who reads them.
💡 Tip: tap a step’s number when you finish it — a green tick appears and your browser remembers how far you got.
- A free GitHub account (you’ll sign in to VS Code with it).
- Visual Studio Code installed on your computer (Windows, macOS or Linux).
- An active GitHub Copilot plan – the 30‑day free trial works, otherwise a paid subscription is required.
- A simple code or text file you’re happy to experiment with.
- About 10 minutes of uninterrupted time.
Download and install Visual Studio Code
Visit code.visualstudio.com in any web browser; you’ll see a large button that usually says “Download for Windows”, “Download for macOS” or “Download for Linux”. Click that button, then open the installer that lands in your Downloads folder (it ends with .exe, .dmg, .deb or .rpm). The installer walks you through a few screens – just click “Next”, accept the licence, and press “Install”. When the installer finishes, it launches VS Code, showing a window with a thin left sidebar and a blank centre editor. If the button doesn’t match exactly, look for a link that says “Other platforms” or “Get VS Code for …”. You’ll know it worked when the VS Code icon appears on your desktop or in your applications folder and the program opens to an empty editor.

Sign in to GitHub from inside VS Code
With VS Code open, glance at the bottom‑left corner; you should see a small silhouette icon – this is the Accounts button (think of it as the door that lets VS Code meet your online identity). Click it; a tiny panel slides up offering “Sign in with GitHub”. Choose that option; your default web browser opens and asks you to confirm the sign‑in. After you approve, the panel disappears and a little avatar or your initials replace the silhouette. If you don’t see the silhouette, open the menu bar, select View → Command Palette, type “Sign in” and pick the option that mentions GitHub. You’ll know it worked when your GitHub username or avatar shows up in the bottom‑left corner of VS Code.

Install the GitHub Copilot extension
In the left sidebar look for an icon that looks like four squares arranged in a grid – this opens the Extensions view (imagine a mini app store built into VS Code). Click the icon; a panel appears with a search bar at the top. Type GitHub Copilot into that bar. The first result is the official Copilot extension with an Install button next to it. Click Install; VS Code downloads the extension and automatically enables it. Once the process finishes, a new Copilot logo (usually a stylised chat bubble) appears in the activity bar – the thin vertical strip on the far left. If you don’t see the four‑square icon, you can also open View → Extensions from the top menu. You’ll know it worked when the Extensions list shows GitHub Copilot as “Enabled” and the Copilot icon appears in the activity bar.

Open a code file in the editor
Click the first icon in the left sidebar – it looks like two stacked pages and represents the Explorer (think of it as a folder browser). In the Explorer pane navigate to a folder that contains a file such as example.js or notes.txt. Single‑click the file to select it, then double‑click to open it; the file’s contents fill the central editor area and a column of line numbers appears on the left. (A function is just a named bundle of instructions, like a recipe card, and a comment is a note for human readers that the computer silently ignores.) If the Explorer isn’t visible, press Ctrl+Shift+E (on macOS, Cmd+Shift+E). You’ll know it worked when the file’s text appears in the editor with line numbers running down the left side.

Ask GitHub Copilot to suggest a comment above a line of code
Place the cursor on an empty line directly above the line you want explained. Type // followed by a short instruction such as Explain what this line does. In many cases, GitHub Copilot will show a faint, grey ghost text suggestion right after you finish typing – this is Copilot’s inline auto‑complete behaviour. If the ghost text appears, press Tab to turn it into a real comment; press Escape if you want to discard it and try a different prompt.
If no ghost text shows up, it may be because the instruction is too short or the extension needs a moment to load. In that case you can use the built‑in command as a fallback: open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P) and run “GitHub Copilot: Explain”. Copilot will then insert a comment based on the line you have selected.
You’ll know it worked when a readable comment appears above the target line, summarising its purpose in plain English.

Review, edit and save the suggestion
Read the newly inserted comment aloud; if it accurately describes the code, you’re finished. If the wording is off, simply click into the comment line and type a correction – Copilot does not learn from these edits, so manual tweaks are normal. To finish, save the file by pressing Ctrl+S (or Cmd+S on macOS); the dot next to the file name in the tab disappears, indicating the file is saved. If you notice the comment is still unclear, return to Step 5 and re‑phrase your prompt (for example, Summarise the tax‑calculation step in plain English).

- Typing a whole code block instead of a short prompt. GitHub Copilot works best with brief instructions like
// Explain this step. Fix: keep the trigger line under 10 words. - Pressing Escape before accepting the ghost text. The grey suggestion is the output you want; pressing Escape discards it. Fix: press Tab to accept the suggestion, then edit if needed.
- Expecting Copilot to understand very complex logic on the first try. Long or ambiguous code often yields vague comments. Fix: add more context to your prompt or break the code into smaller chunks and ask for one comment at a time.
Open any small code or text file you have, put the cursor on a blank line above a line you recognise, type // Explain what this line does, press Tab when the ghost text appears (or use the “GitHub Copilot: Explain” command if it doesn’t), and then save the file. In under two minutes you’ll see your first Copilot‑written comment right in the editor.
❓ Quick questions
How long does this take?
About 6 minutes — the guide has 6 steps, and you can tick each one off as you go.
Which tool do I need?
This guide uses GitHub GitHub Copilot — but the approach works very similarly in other AI assistants.
Do I need to prepare anything?
- A free GitHub account (you’ll sign in to VS Code with it).
- Visual Studio Code installed on your computer (Windows, macOS or Linux).
- An active GitHub Copilot plan – the 30‑day free trial works, otherwise a paid subscription is required.
- A simple code or text file you’re happy to experiment with.
- About 10 minutes of uninterrupted time.
What mistakes should I avoid?
- Typing a whole code block instead of a short prompt. GitHub Copilot works best with brief instructions like
// Explain this step. Fix: keep the trigger line under 10 words. - Pressing Escape before accepting the ghost text. The grey suggestion is the output you want; pressing Escape discards it. Fix: press Tab to accept the suggestion, then edit if needed.
- Expecting Copilot to understand very complex logic on the first try. Long or ambiguous code often yields vague comments. Fix: add more context to your prompt or break the code into smaller chunks and ask for one comment at a time.
Keep reading
📬 The week’s AI, in your inbox
One friendly email every Sunday — the 5 stories that mattered, in plain English. No spam, unsubscribe anytime.
✦ Original step-by-step guide by AI World HQ's AI editorial team. Written in plain language, reviewed for accuracy.
← Back to all stories