Loading lesson…
Let's actually feel what autocomplete is like. Write a comment, pause, and watch a full function appear. Then learn what to do next.
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.
# 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}!"One comment in, one working function out. This is the smallest possible AI-assisted coding loop.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.
— An old engineering saying, still true with AI
The big idea: autocomplete is a conversation through your comments and signatures. Leave good breadcrumbs, and the AI will follow them to useful code.
15 questions · take it digitally for instant feedback at tendril.neural-forge.io/learn/quiz/end-coding-first-completion-builders
What is the term for the gray suggested code that appears directly at your cursor location in an AI code completion tool?
A developer sees gray text appear after writing a comment. They want to accept the suggestion. Which key should they press?
A developer wants to make a suggestion disappear without accepting it. Which key is recommended for dismissing ghost text?
Which of the following provides the most signal for an AI autocomplete system to generate a useful code suggestion?
Why is it recommended to read ghost text out loud after it appears?
A developer writes a function signature first (def greet(name, time_of_day):) before letting AI complete the body. What is the main advantage of this approach?
What happens if you type a function's name and parameters before accepting any AI suggestion?
A developer writes a comment saying 'function that calculates area of a circle' but the AI generates code for a rectangle. Why might this happen?
What should a developer do immediately after seeing ghost text appear for a function they requested?
A student writes a comment 'make a function' and expects perfect code. The AI generates something unexpected. What went wrong?
Which of these best describes the relationship between comments and autocomplete suggestions?
Why might accepting ghost text without reading it introduce bugs into your code?
The quote 'Writing the first line of a function is the most valuable line of code you can write' emphasizes the importance of what?
A developer notices the AI suggested a dictionary with only two cases, but their comment mentioned three cases. What should they check?
What does the lesson mean when it says 'autocomplete is a conversation through your comments and signatures'?