Copilot Chat Fundamentals
Learn GitHub Copilot chat to build a CLI to-do app, refine prompts, and decode complex code in Visual Studio Code.
In the last lesson, you experienced the GitHub Copilot completing your code as you typed. But that was just the beginning.
Imagine going one step further—not just accepting suggestions, but talking directly to your AI coding partner. Ask it to explain what a piece of code does. Guide it to build a feature from scratch. Get help debugging an error, or even ask for a cleaner rewrite of something you wrote yourself.
That’s what this lesson is all about.
Welcome to Copilot chat—your window into AI-powered coding conversations.
Opening the Copilot chat
Let’s start by launching the chat itself.
If you’re using Visual Studio Code, open your editor and press:
Ctrl + ⌘ + I
(side chat) or⌘ + I
(inline chat) on macOSCtrl + I
on Windows or Linux
You should see a chat panel open, usually on the right-hand side of your editor. This is where the conversation begins.
💡 If the shortcut doesn’t work, open the command palette (
Cmd + Shift + P
orCtrl + Shift + P
) and search for:
“Copilot: Toggle Chat”
Once the panel opens, you’re ready to chat.
To-do list using chat
Let’s put Copilot chat to work by building a small but functional CLI to-do app using only natural language instructions.
What your app should do:
Your script should support three commands:
add "task text"
→ Adds a new task and prints the assigned number.list
→ Prints all current tasks, numbered.delete <number>
→ Removes the task with that number and confirms it.
Remember: No database is required—just store everything in memory for now.
Starter code
Create a starter_app.py
file in your folder. We’ve prepared a basic scaffold for you to build on. Choose your language and copy it into your VS Code editor.
# starter_app.py# Run this in terminal: python starter_app.py add "Buy milk"def main():# TODO via Copilot Chat:# 1. add <task># 2. list# 3. delete <task#>passif __name__ == "__main__":import sysmain()
Paste your scaffold into VS Code. You’re now ready to prompt Copilot.
Start the conversation
In the Copilot chat panel, try this first prompt:
“Implement add, list, and delete commands for this CLI to-do list app. Tasks should be stored in memory.”
Now watch as Copilot side chat responds with actual code logic. Read it carefully. Does it match what you had in mind? If not, follow up with:
“Can you make it more concise?”
“It’s missing the delete logic—add that too.”
Note: Paste your final code into the widget above, click “Run,” and verify that it executes correctly.
Just like a real developer conversation, you can go back and forth.
Once you’re happy, insert the code into your file and run it locally to test.
Try things like:
python3 starter_app.py add "Buy groceries"
Refine your prompt
Want Copilot chat to deliver more accurate responses?
Use the following three-part pattern:
Context: Tell it what you’re working on.
Instruction: Tell it what to do.
Constraint: Tell it how to do it.
Try rewriting your earlier message like this:
“‘I’m editing
starter_app.py
, a CLI to-do list. Implementadd
,list
, anddelete
commands, and keep the code under 35 lines following standard Python style.”
Write the above prompt, and compare it to your original result. You’ll often get cleaner, more focused responses—especially for real-world tasks.
Debugging with Copilot chat
Ran into an error? Don’t worry, that’s where Copilot chat really shines.
Instead of getting stuck or scouring Stack Overflow, try describing the issue directly to Copilot.
For example, you can ask:
“Why might my
delete
command raise anIndexError
? Here’s the error message…”
Copilot will review the context, reason through your code, and often point out the exact logic flaw, sometimes even offering a better approach than what you had in mind.
Challenge: Explain code with Copilot chat
Now it’s time to test Copilot chat’s ability to explain logic—and your ability to summarize it clearly.
Take a look at this compact Python expression:
zzz = [q for q in range(2, 100) if all(q % w for w in range(2, int(q**0.5) + 1))]print(zzz[:10])
It might look dense at first, but don’t panic. Open Copilot chat and ask:
“Explain step-by-step what this code does and why it works.”
After reviewing the explanation, copy and paste it into the answer box to test whether GitHub Copilot’s explanation is accurate. Paste your explanation below to run the test.
Awesome! You can now try this prompt directly in GitHub Copilot.
Let’s test your knowledge with the following quiz:
What is the correct way to open Copilot chat in VS Code on macOS by default?
Cmd + I
Ctrl + ⌘ + I
Cmd + Shift + P
Alt + I
Well done! You’ve just put your knowledge to the test with the quiz above.
What you achieved
In this lesson, you:
Opened and used Copilot chat: You launched Copilot chat in VS Code and learned how to interact with Copilot using natural language, enhancing your workflow.
Built a working CLI to-do app: You used Copilot chat to create a fully functional to-do list app with features like
add
,list
, anddelete
, all without writing code manually.Refined a prompt: You applied the context-instruction-constraint method to craft effective prompts, improving the quality and focus of Copilot’s responses.
Leveraged chat to decode code: You asked Copilot to explain complex code step-by-step, gaining clearer insights into its functionality.
What’s next?
Next, you’ll level up with prompt engineering—learning proven patterns to fine-tune your prompts, get precise Copilot chat answers, and generate accurate code suggestions across any project.