Lesson 28 of 1570
Your First Copilot-Style Completion
Let's actually feel what autocomplete is like. Write a comment, pause, and watch a full function appear. Then learn what to do next.
Lesson map
What this lesson covers
Learning path
The main moves in order
- 1Ghost Text, Meet Real Text
- 2autocomplete
- 3ghost text
- 4tab completion
Concept cluster
Terms to connect while reading
Section 1
Ghost Text, Meet Real Text
Autocomplete shows suggested code in gray right where your cursor is. This is called ghost text. Press Tab to accept, Esc to dismiss, or just keep typing to ignore. That is the entire user interface.
The magic is in what triggers a good suggestion. The model sees your open file, nearby files, and any comment you just wrote. The more signal you leave, the better the guess.
Try this exact experiment
- 1Open a new Python file named greetings.py
- 2Type a single comment describing the function you want
- 3Press Enter and wait two seconds
- 4The AI will draft the whole function as ghost text
- 5Press Tab to accept, then read every line
One comment in, one working function out. This is the smallest possible AI-assisted coding loop.
# Function that takes a name and a time of day (morning, afternoon, evening)
# and returns a friendly greeting string.
def greet(name, time_of_day):
greetings = {
"morning": "Good morning",
"afternoon": "Good afternoon",
"evening": "Good evening",
}
prefix = greetings.get(time_of_day, "Hello")
return f"{prefix}, {name}!"What to do the moment it finishes typing
- 1Read every line out loud in your head
- 2Ask: does the dictionary cover all three cases I named?
- 3Ask: what happens if time_of_day is something weird like None?
- 4Run the function with a real name and see the output
Pro tip: type the function signature first
If you type the function name and its parameters first, the AI has to fit its body to your shape. That gives you more control than letting it invent everything. Builders who write signatures first get noticeably better suggestions.
“Writing the first line of a function is the most valuable line of code you can write.”
Key terms in this lesson
The big idea: autocomplete is a conversation through your comments and signatures. Leave good breadcrumbs, and the AI will follow them to useful code.
End-of-lesson quiz
Check what stuck
15 questions · Score saves to your progress.
Tutor
Curious about “Your First Copilot-Style Completion”?
Ask anything about this lesson. I’ll answer using just what you’re reading — short, friendly, grounded.
Progress saved locally in this browser. Sign in to sync across devices.
Related lessons
Keep going
Builders · 25 min
What Does AI-Assisted Coding Even Mean?
AI-assisted coding is not magic and not cheating. It is a new way of working where a model drafts, you decide. Let's draw a map before we start building.
Builders · 30 min
Prompting for Code Is Different From Prompting for Prose
A prompt that writes a poem is not the same as a prompt that ships working code. Code has hidden standards. You need to make them explicit.
Builders · 35 min
When AI Writes Buggy Code — How to Read It Critically
The AI will hand you code that looks right but isn't. Here are the most common bugs and the habits that catch them before they bite.
