Ghost Prompts

Ghost Prompts

What Are Ghost Prompts?

Ghost prompts are the faint gray inline suggestions that appear in your code editor when GitHub Copilot predicts what you’re about to write. They’re called “ghosts” because they’re not actually in your file until you accept them. These suggestions can range from completing a single line of code to entire functions or multi-step logic blocks.

When you pause after typing a comment, a function signature, or part of a line, Copilot analyzes the current file context and shows what it thinks should come next. This is one of the most powerful features of Copilot because it allows developers to stay in flow without constantly jumping to documentation or searching for snippets online.

How Do You Accept or Dismiss Ghost Prompts? (Keyboard Shortcuts)

Ghost prompts are intentionally unobtrusive; you decide whether to accept them. Here are the essential keyboard shortcuts:

  • Accept the suggestion:

    • Press Tab to accept the entire suggestion.

    • Press the Right Arrow key to accept one character at a time (helpful if you want to partially edit).

  • Dismiss the suggestion:

    • Press Esc to dismiss the suggestion and continue typing.

  • See more alternatives:

    • Press Cmd + Enter (Mac) or Ctrl + Enter (Windows/Linux) to open a menu with multiple suggestion options.

Knowing these shortcuts is key to controlling Copilot rather than letting it control you.

✏️ Ghost Prompts – Live Follow-Along

Setup

Before we start, open VS Code and create a new project folder (or use any existing one). Inside it, create a new file:

touch ghost-prompts-demo.ts

Demo 1: Date Function

  1. In ghost-prompts-demo.ts, type this function signature:

    function formatDate(date: Date): string {
  2. Pause for a moment. You should see a faint gray ghost prompt appear, suggesting the rest of the function. If you don’t see any ghost prompt, then you are most likely not logged into Copilot yet.

    1. image-20250730-025749.png
  3. Press Tab to accept the full suggestion.

  4. If the suggestion looks wrong, press Esc to dismiss it and try retyping.

Demo 2: Fill Arrays Example

  1. In the same file, type the following comment:

    // Create an array of the first 10 prime numbers
  2. Pause and watch Copilot generate a suggestion for the array.

    1. image-20250730-030408.png
  3. Press Tab to accept.

  4. Try changing the comment to something more specific:

    // Create an array of the first 5 Fibonacci numbers
  5. Pause and watch how Copilot re-generates the code:

    1. image-20250730-030554.png

Demo 3: Shortcuts in Action

  • Accept entire suggestion: Press Tab

  • Accept one character at a time: Press Right Arrow

  • Dismiss suggestion: Press Esc

  • See more alternatives: Press Cmd + Enter (Mac) or Ctrl + Enter (Windows/Linux)

Try cycling through multiple alternatives for one of the examples using Cmd/Ctrl + Enter. Notice how Copilot can generate different variations of the same logic.

Using “Fix with Copilot” and “Explain with Copilot”

GitHub Copilot isn’t limited to inline ghost prompts. It also offers on-demand actions that can help you auto-complete code or explain existing code. These appear in the VS Code context menu and can be triggered with a simple keyboard shortcut.

How to Access These Options

  1. Place your cursor at the end of a line or statement (e.g., the function signature):

function formatDate(date: Date): string {
  1. Press Cmd + . (Mac) or Ctrl + . (Windows/Linux).

  • This opens the lightbulb context menu with AI-powered actions.

  • You will see options like:

    • Fix using Copilot

    • Explain using Copilot

    • image-20250730-031134.png

Option 1: Fix Using Copilot

This action tells Copilot to auto-complete or fix the current line or block of code. It’s particularly useful when:

  • You wrote a function signature but haven’t implemented the body yet.

  • You have an incomplete or broken code snippet, and you want Copilot to “fix” it into a working version.

Real-World Example: Implementing formatDate

  1. Type the function signature only:

    function formatDate(date: Date): string {
  2. Without writing the body, place your cursor at the end of the line and press Cmd + . / Ctrl + .

  3. Choose Fix using Copilot from the menu.

  4. Result: Copilot will analyze the function name and signature, then insert the entire implementation automatically:

    1. image-20250730-031354.png

Option 2: Explain Using Copilot

This action generates a plain-English explanation of what the selected code does. It’s helpful for:

  • Understanding unfamiliar code: Especially useful when reviewing PRs or legacy code.

  • Onboarding junior developers: They can ask Copilot for clarifications in real time.

  • Self-documentation: Turn Copilot’s explanation into inline comments.

Real-World Example: Explaining Code

  1. Remove the previous function body and place your cursor again at the end of the line.

    function formatDate(date: Date): string { return date.toISOString(); }
  2. Press Cmd + . / Ctrl + . and choose Explain using Copilot.

  3. A Copilot Chat sidebar will open that will display a text explanation, e.g.:

    1. image-20250730-032226.png