Skip to content

GH-300 · Domain 4: Apply prompt engineering and context crafting · 13% of the exam

Task 4.2: Engineer prompts for performance

Prompt engineering principles, the prompt process flow, and how chat history and context windows affect results and cost.

Study it

  • Prompt engineering principles and the prompt process flow

    Lesson coming

  • Chat history, compaction and context windows

    Partly covered by: Context Windows

Sample questions

Try each one before opening the answer. Every option is explained, with the GitHub documentation page that proves it.

Question 1 · choose 1

After spending an hour debugging a payment bug in Copilot Chat, a developer moves on to writing a migration for an unrelated reporting table in the same conversation. Copilot keeps mentioning payment classes. What should the developer do?

  1. AKeep the conversation and ask Copilot to ignore everything before the next message
  2. BStart a new conversation for the new task
  3. CSwitch to a model with a larger context window so that both topics fit
  4. DAdd the reporting table to the repository's custom instructions
Show the answer and why
  • AKeep the conversation and ask Copilot to ignore everything before the next message

    Incorrect

    Instructions to ignore history are less reliable than giving Copilot only relevant history.

  • BStart a new conversation for the new task

    Correct

    Conversational surfaces use history as context; starting a new conversation for a new task keeps only relevant history.

  • CSwitch to a model with a larger context window so that both topics fit

    Incorrect

    A larger window keeps the unrelated history in play rather than removing it.

  • DAdd the reporting table to the repository's custom instructions

    Incorrect

    Custom instructions are persistent repository guidance, not a fix for stale history.

Copilot's conversational surfaces use your conversation history as context. To keep only relevant history, start a new conversation or session when you begin a new task, and where the surface supports it, remove or roll back turns that are no longer relevant.

Question 2 · choose 1

In Copilot CLI, a test command prints about 2 MB of logs. A developer expected the whole log in the conversation but sees that Copilot only received a file path and a preview. Why, and what is the trade-off of raising the limit?

  1. AOutput over 20 KiB is saved to a temp file; raising the threshold leaves less context for the rest
  2. BContent exclusion blocked the log file from Copilot, and raising the limit would require an exclusion exception
  3. CThe model rejected the log as too long for one turn, and raising the limit would make each request fail outright
  4. DLogs are streamed only in autopilot mode; switching modes would double the AI credits used
Show the answer and why
  • AOutput over 20 KiB is saved to a temp file; raising the threshold leaves less context for the rest

    Correct

    Large tool output is written to a temp file with a preview, and a higher threshold uses more of the context window.

  • BContent exclusion blocked the log file from Copilot, and raising the limit would require an exclusion exception

    Incorrect

    Content exclusion is unrelated to the size of tool output.

  • CThe model rejected the log as too long for one turn, and raising the limit would make each request fail outright

    Incorrect

    No rejection happened; the CLI deliberately saved the output to a file.

  • DLogs are streamed only in autopilot mode; switching modes would double the AI credits used

    Incorrect

    The behavior applies to all tools and is not tied to autopilot.

To stop a single tool response from consuming too much of the context window, Copilot CLI saves tool output larger than 20 KiB to a temporary file and gives the model the file path and a preview. You can change the limit with COPILOT_LARGE_OUTPUT_THRESHOLD_BYTES, but a higher limit leaves less context for the conversation and later tool calls.

Question 3 · choose 1

Microsoft Learn's GitHub Copilot training sums up its prompt engineering principles as four S's. A team writes a single, specific and short prompt but still gets generic suggestions because their files are named util1.js to util9.js and nothing related is open. Which principle are they missing?

  1. ASequence: number prompts so that Copilot processes them in a fixed order
  2. BSimplify: remove all comments so the prompt stays short
  3. CScope: limit each prompt to one file at a time
  4. DSurround: use descriptive file names and keep related files open
Show the answer and why
  • ASequence: number prompts so that Copilot processes them in a fixed order

    Incorrect

    Sequence is not one of the four S's.

  • BSimplify: remove all comments so the prompt stays short

    Incorrect

    Simplify is not one of the four S's, and removing comments removes useful context.

  • CScope: limit each prompt to one file at a time

    Incorrect

    Scope is not one of the four S's.

  • DSurround: use descriptive file names and keep related files open

    Correct

    The four S's are Single, Specific, Short and Surround; Surround means descriptive filenames and related files open for rich context.

Microsoft Learn summarizes prompt engineering as four S's: Single (one well-defined task), Specific (explicit, detailed instructions), Short (concise), and Surround (descriptive filenames and related files kept open so Copilot has rich context). Copilot also uses parallel open tabs to understand requirements.

Question 4 · choose 1

In Copilot CLI, a developer suspects MCP tool definitions are taking up much of the context window. Which slash command shows a breakdown of token usage by category?

  1. A/context
  2. B/compact
  3. C/model
  4. D/feedback
Show the answer and why
  • A/context

    Correct

    /context shows token usage for the system prompt, custom instructions, system tools, MCP tools, messages, free space and buffer.

  • B/compact

    Incorrect

    /compact compresses the conversation history.

  • C/model

    Incorrect

    /model selects the model.

  • D/feedback

    Incorrect

    /feedback sends feedback to GitHub.

The /context command visualizes context window usage. The first line shows the active model and tokens in use; the rest breaks usage down into system prompt, custom instructions, system tools, MCP tools, messages, free space and buffer. /compact compresses history when you need room.

Question 5 · choose 1

At what point does Copilot CLI start compacting the conversation automatically in the background, according to the context management documentation?

  1. AAt about 50% of the context window
  2. BAt about 80% of the context window
  3. COnly when the window is 100% full
  4. DNever; compaction only happens when you run /compact
Show the answer and why
  • AAt about 50% of the context window

    Incorrect

    Compaction starts much later than half full.

  • BAt about 80% of the context window

    Correct

    Copilot CLI starts compacting at about 80%, leaving roughly 20% for tool calls while it runs.

  • COnly when the window is 100% full

    Incorrect

    Waiting until full would stall the session; compaction starts earlier.

  • DNever; compaction only happens when you run /compact

    Incorrect

    Compaction is automatic, and /compact also triggers it manually.

When the conversation reaches about 80% of the context window, Copilot CLI starts compacting in the background, leaving a buffer of about 20% so tool calls can keep running. If usage reaches about 95% before compaction finishes, the CLI pauses briefly to let it complete. You can also run /compact manually.

Question 6 · choose 1

A developer on Copilot Pro sees her AI credits draining fast. Last week she accepted about 3,000 code completions and next edit suggestions, asked a handful of quick chat questions and ran two long Copilot cloud agent sessions across many files. According to GitHub's billing documentation, which activity most likely used most of the credits?

  1. AThe completions and next edit suggestions, because each accepted suggestion is billed by its tokens
  2. BThe chat questions, because every chat message costs the same fixed number of credits
  3. CThe two cloud agent sessions, because a single agentic task can involve many model calls
  4. DThe completions, because Copilot Pro starts billing them once the first 2,000 of the month are used
Show the answer and why
  • AThe completions and next edit suggestions, because each accepted suggestion is billed by its tokens

    Incorrect

    On paid plans, code completions and next edit suggestions are not billed in AI credits; they remain unlimited.

  • BThe chat questions, because every chat message costs the same fixed number of credits

    Incorrect

    Credits follow the tokens consumed and the model used; a quick question with a lightweight model can cost a fraction of a credit.

  • CThe two cloud agent sessions, because a single agentic task can involve many model calls

    Correct

    Agentic features such as agent mode and the cloud agent can make multiple model calls within one task, so a long session across many files consumes far more than a quick chat question.

  • DThe completions, because Copilot Pro starts billing them once the first 2,000 of the month are used

    Incorrect

    The 2,000 completions a month are the Copilot Free allowance; paid plans have unlimited completions that are not billed in AI credits.

Usage is measured in AI credits, priced by the tokens consumed and the model used. More complex interactions consume more: longer conversations, and agentic features such as agent mode and the cloud agent that can involve several model calls within a single task. Code completions and next edit suggestions are not billed in AI credits and remain unlimited on paid plans; Copilot Free includes 2,000 code completions a month.

Question 7 · choose 1

A team's .github/copilot-instructions.md has grown to 400 lines as each squad adds its own rules. Why does GitHub advise keeping repository instructions short and broadly applicable?

  1. ABecause files over one page are ignored
  2. BBecause instructions are only read on the first message of a chat
  3. CBecause only organization owners can edit long instruction files
  4. DBecause they are sent with every chat message in the repository
Show the answer and why
  • ABecause files over one page are ignored

    Incorrect

    No page limit is given; the issue is relevance to every request.

  • BBecause instructions are only read on the first message of a chat

    Incorrect

    They are sent with every chat message.

  • CBecause only organization owners can edit long instruction files

    Incorrect

    Anyone who can commit to the repository can edit the file.

  • DBecause they are sent with every chat message in the repository

    Correct

    Instructions are sent with every chat message, so they should apply to most requests made in the repository.

Repository custom instructions should be short, self-contained statements. Because they are sent with every chat message, they should be broadly applicable to most requests made in the repository's context.

Practise domain 4 →Practise all domains →