GitHub Copilot (GH-300) · 13% practice allocation

GitHub GH-300: Apply Prompt Engineering and Context Crafting Practice Questions

5 free sample questions from the Apply Prompt Engineering and Context Crafting domain, with answers and explanations. The full GH-300 bank has 115 questions across 6 domains. Questions are scenario-based and written from the official GitHub exam guide.

1.

A developer is working in order_service.py and has 12 unrelated files open in other tabs, including several from an old prototype. Copilot's inline suggestions keep referencing deprecated prototype APIs. Which action best addresses this?

  • A. Disable Copilot's neighboring-tabs feature globally in the organization policy
  • B. Rename the prototype files with a _deprecated suffix so Copilot ignores them
  • C. Close the irrelevant prototype tabs and keep only files related to the current task open✓ Correct
  • D. Add a comment at the top of order_service.py saying 'Copilot: ignore other open files'
Explanation

Copilot uses neighboring open tabs as a context source, so irrelevant open files can pollute suggestions; closing them is the documented context-optimization practice. There is no organization policy toggle that disables neighboring-tabs context, and doing so would also remove useful context. Renaming files does not exclude them from context — file names are themselves weak signals, and the content is still available. A natural-language 'ignore other files' comment is not a supported directive and Copilot will not honor it as an exclusion rule.

2.

A team lead is coaching developers on writing better Copilot prompts. Which THREE practices best reflect GitHub's recommended prompt engineering best practices? (Select THREE.)

  • A. Keep relevant files open in the editor so Copilot can draw on neighboring tabs✓ Correct
  • B. Avoid giving examples, because examples bias the model toward copying them
  • C. Write the shortest prompt possible so the model is not distracted by detail
  • D. Ask Copilot to generate the entire application in one prompt to preserve consistency
  • E. Provide clear, specific intent including inputs, outputs, and constraints✓ Correct
  • F. Break a large, complex request into smaller, focused prompts✓ Correct
Explanation

Being specific about intent, inputs/outputs, and constraints; iterating in small, focused steps; and keeping relevant files open (neighboring tabs are a key context source) are all documented best practices. Minimizing detail is wrong — vague prompts produce generic or incorrect results; specificity matters more than brevity. Asking for an entire application in one prompt contradicts the guidance to decompose complex tasks. Avoiding examples is wrong — few-shot examples are an endorsed technique for steering output format and style.

3.

A developer writes the following single prompt to Copilot Chat with no examples: "Write a Python function that converts a Celsius temperature to Fahrenheit." Which prompting technique does this represent?

  • A. Chain-of-thought prompting
  • B. Retrieval-augmented prompting
  • C. Few-shot prompting
  • D. Zero-shot prompting✓ Correct
Explanation

Zero-shot prompting gives the model an instruction with no worked examples of the desired input/output pattern, relying entirely on the model's pretrained knowledge — exactly what this prompt does. Few-shot prompting would include one or more sample inputs and outputs to demonstrate the pattern. Chain-of-thought prompting explicitly asks the model to reason step by step before answering. Retrieval-augmented prompting supplements the prompt with content fetched from an external knowledge source, which is not happening here.

4.

A team is standardizing prompt practices. Which TWO statements about zero-shot and few-shot prompting with Copilot are correct? (Select TWO.)

  • A. Few-shot prompting requires fine-tuning the underlying model with the supplied examples
  • B. Few-shot prompting is especially valuable when the output must follow a domain-specific or proprietary convention the model has not seen✓ Correct
  • C. Zero-shot prompting is always preferred because examples consume context window space that would otherwise improve accuracy
  • D. Zero-shot is often sufficient for common, well-known tasks such as writing a standard sorting function✓ Correct
  • E. Few-shot examples must be supplied as a separate uploaded dataset; they cannot appear inline in a prompt or file
Explanation

Zero-shot works well for widely represented, conventional tasks, while few-shot shines when the target pattern is proprietary or unusual and must be demonstrated. Few-shot does not involve fine-tuning — examples are supplied in-context at inference time and change no model weights. Zero-shot is not 'always preferred'; examples are often the cheapest way to fix format drift, and the context window is large enough to accommodate a few. Few-shot examples are provided inline in the prompt or in nearby code, not as an uploaded dataset.

5.

A developer is using GitHub Copilot Chat in VS Code and wants to ask a question specifically about a function in a file that is not currently open in the editor. Which chat variable should they use to bring that file into the prompt context?

  • A. #selection
  • B. #terminalLastCommand
  • C. #file✓ Correct
  • D. #editor
Explanation

#file lets you explicitly reference a specific file in the workspace (via a file picker or by name) so its contents are included as context, even if the file is not the active editor. #selection only refers to the text currently highlighted in the active editor, so it cannot reach an unopened file. #editor refers to the visible contents of the currently active editor tab, which again is not the unopened file. #terminalLastCommand includes the last command run in the integrated terminal and has nothing to do with file contents.

Test yourself across every GH-300 domain

The free GH-300 practice test mixes about 20 questions weighted like the exam. The full 115-question bank adds instant grading, flashcards and a timed mock exam.

Study this domain

Apply Prompt Engineering and Context Crafting study guide (GH-300) →

Other GH-300 domains

← All GitHub Copilot study resources