A code completion assistant is a tool that suggests code inline as a developer types. The suggestion appears as faded “ghost text” after the cursor. The developer can press Tab to accept it or keep typing to ignore it.
Popular Examples: GitHub Copilot, Cursor Tab, JetBrains AI Assistant, Amazon Q Developer
The basic flow is simple: take the code around the cursor, send it to a model, and display a suggestion. Making that flow useful is harder. A suggestion that arrives after the developer has typed past the cursor position is already too late. One that calls a helper function with the wrong arguments creates more work than it saves. And with millions of developers sending requests every few seconds, even a small cost per request becomes a substantial GPU bill.
In this chapter, we’ll design a code completion assistant. We’ll start with requirements and the high-level architecture, then examine the end-to-end latency budget, context selection, fill-in-the-middle generation, and how to measure whether suggestions actually help.
Let's start by clarifying the requirements.