GH-300 domain - 13% of the exam

Apply prompt engineering and context crafting

Apply prompt engineering and context crafting is 13% of the GH-300 exam. These are the objectives it covers, each with practice questions, with every answer explained.

The domain in numbers

36
Practice questions
3
Objectives
36
Medium

Where people go wrong

  • Treating a repeated or reworded vague prompt as refinement

    The wrong answers keep the request as vague as before: a single ambiguous word or noun, the same sentence sent again, or an added superlative such as "best" or quality word such as "professional". None of these adds a goal, inputs or constraints, so Copilot still has to guess and the output stays unfocused. The correct answers name the specific goal and constraints, such as reducing time complexity while keeping the public signature unchanged, and say what output is expected.

    See it in a sample question
  • Reading content exclusions as a way to steer context

    Content exclusions appear as an answer to questions about steering suggestions, teaching a format or following project conventions. They only stop named files being used as context, so excluding an example file removes the very conventions Copilot should follow, and they never define an output shape. Steering works the opposite way: opening the relevant module or example files in neighbouring tabs keeps them in context.

    See it in a sample question
  • Using zero-shot or prose where worked examples are needed

    The wrong answers try to fix an idiosyncratic output with another bare instruction, more urgent wording or a longer written description. When a plain instruction keeps getting field order, bracket style or company-specific category boundaries wrong, the correct answer is few-shot prompting with worked examples, such as two or three correctly formatted lines or one labelled ticket per category. Zero-shot fits a common, well-documented task, such as reversing a string or applying a standard encoding, that the model handles from the instruction alone.

    See it in a sample question
  • Expecting anything but a new conversation to clear chat history

    The wrong answers claim that a stronger instruction, a different model, extra open files or a temperature change will clear an earlier topic, or that Copilot keeps permanent memory across conversations. History is scoped to the conversation thread and carried into each new prompt, which is why an unnamed follow-up resolves to the earlier function. Starting a new chat conversation is what drops unrelated turns.

    See it in a sample question
  • Sourcing inline context from commit history or a repository scan

    The wrong answers name commit history, a whole-repository index, file creation order or the default branch as the source of inline context. Inline completions draw on the current file plus relevant code in neighbouring open tabs. That is also why a stale module left open keeps pulling suggestions towards its patterns until it is closed.

    See it in a sample question

Objectives in this domain

What to study

The official documents this domain's practice questions cite most.

Sample questions from this domain

Free sampleApply prompt engineering and context craftingmedium

A developer asks Copilot Chat to write a function and gets a vague, unfocused answer. They want to improve the result by giving the request a clearer shape. Which way of structuring the prompt is most likely to produce a focused, usable response?

  • AKeep the request to a single ambiguous word so that Copilot is free to infer the broadest possible interpretation of what is wanted.
  • BPaste several unrelated requests into one message so that Copilot can choose whichever of the competing tasks it judges to be the easiest.
  • CRepeat the same broad sentence three times in a row so the model treats the heavily emphasised instruction as the most important one.
  • DState the goal, then the relevant inputs and constraints, then the expected output, so Copilot has a clear and ordered picture of the task. Correct
Structure prompts as goal, then context and constraints, then expected output to give Copilot the specifics needed for a focused response. A well-structured prompt sequences the goal, the relevant context and constraints, and the desired output. This ordering gives Copilot the concrete signals it needs to scope the task, so the response is targeted rather than the vague output produced by a one-word or scattered request.

Why A is wrong: Tempting because short prompts feel quick, but a single ambiguous word removes the goal, inputs, and constraints Copilot needs, so it tends to produce exactly the vague output described.

Why B is wrong: Bundling unrelated tasks confuses the intent and splits Copilot's focus, which produces a muddled answer rather than the clear single result the developer wants.

Why C is wrong: Repetition adds no new specifics and does not clarify goal or constraints, so the answer stays as unfocused as the original vague request.

Why D is correct: Correct: structuring a prompt as goal, then context and constraints, then desired output gives Copilot the specifics it needs to generate a focused, relevant response.

Free sampleApply prompt engineering and context craftingmedium

A developer wants Copilot to generate a new function that matches the naming style and error-handling pattern used across their project. They are about to prompt Copilot in the IDE. Which preparation step most improves the context available to Copilot before they prompt?

  • AClose every other file so only a blank editor remains, on the basis that an empty workspace lets Copilot infer conventions more cleanly.
  • BDisable Copilot suggestions until the prompt is sent, because suppressing inline context first makes the eventual generation follow project style better.
  • CSet a content exclusion on the example files so Copilot is obliged to treat their conventions as the authoritative template for the new function.
  • DOpen the existing files that show the project's naming style and error handling, so those relevant files are part of Copilot's context. Correct
Improve Copilot context by opening files that demonstrate the conventions you want generated code to follow. Copilot derives context from the files open in the editor. Opening files that exemplify the project's naming and error-handling patterns puts those examples in scope, so generated code aligns with them. Closing files, disabling suggestions, or excluding the examples all strip away that helpful context.

Why A is wrong: Closing the example files removes the very context that demonstrates the conventions, so Copilot has nothing to mirror and is more likely to guess.

Why B is wrong: Disabling suggestions does not improve context; it simply stops Copilot from offering help and removes the open-file signals it would otherwise use.

Why C is wrong: Content exclusions remove files from Copilot's context entirely, so excluding the examples would prevent it from following their conventions at all.

Why D is correct: Correct: opening files that demonstrate the conventions makes them available as context, so Copilot can mirror the project's naming and error-handling patterns.

Free sampleApply prompt engineering and context craftingmedium

A developer needs Copilot to emit log lines in a strict in-house format that the model keeps getting subtly wrong, such as field order and the bracket style. They want to lock the output shape without writing extra rules in prose. Which technique most directly achieves this?

  • AZero-shot prompting, by restating the instruction more forcefully and trusting the model to infer the precise field order and bracket style on its own.
  • BContent exclusions, by marking the existing log files so Copilot stops drawing on them and instead produces the desired bracket style automatically.
  • CCustom instructions, by adding a long prose description of every field rule so the model gradually learns the format across separate sessions.
  • DFew-shot prompting, by including two or three correctly formatted log lines as worked examples so Copilot mirrors the exact shape in its output. Correct
Choose few-shot prompting to lock an unusual output format by showing worked examples rather than describing rules in prose. Few-shot prompting supplies concrete input and output examples that demonstrate the exact shape wanted, so the model imitates field order and bracket style directly, which is more dependable than prose rules for an idiosyncratic format the model keeps mishandling.

Why A is wrong: Zero-shot relies on the model inferring the shape, which is what already failed here, so repeating a bare instruction will not reliably lock an idiosyncratic format.

Why B is wrong: Content exclusions only stop named files being used as context and never define an output format, so they cannot teach the model the bracket style wanted.

Why C is wrong: The developer explicitly wants to avoid more prose rules, and a written description is exactly the brittle approach that few-shot examples are meant to replace.

Why D is correct: Few-shot prompting shows the model concrete correct examples, which pins down an idiosyncratic format far more reliably than prose for a shape it keeps getting wrong.

Free sampleApply prompt engineering and context craftingmedium

After several follow-up questions in one Copilot Chat conversation, a developer switches to an unrelated task and finds Copilot's answers are skewed by the earlier topic. Which action best aligns with how chat history shapes responses?

  • ALower the model temperature in the chat settings so Copilot stops weighting any of the previous conversation turns when forming its answer.
  • BKeep the same conversation open and simply phrase the new question more forcefully so it overrides the accumulated history.
  • CStart a new chat conversation so the unrelated history is cleared and the new task is answered without the earlier context. Correct
  • DDisable content exclusions for the workspace so the earlier conversation is no longer treated as available context for the new question.
Understand that starting a new conversation clears accumulated chat history so an unrelated task is not skewed by earlier turns. Copilot Chat treats the running conversation as context, so a topic shift within one thread leaves stale turns influencing answers; beginning a new conversation removes that history and resets the context for the new task.

Why A is wrong: Temperature affects randomness of wording, not which prior turns are treated as context, so it does not remove the stale topic that is steering the answers.

Why B is wrong: Wording the question more strongly does not clear the accumulated history, which remains in context and can still pull the response toward the earlier unrelated topic.

Why C is correct: Because prior turns are carried forward as context, opening a fresh conversation drops that history and lets the new, unrelated task be answered cleanly.

Why D is wrong: Content exclusions govern which repository files may be used as context, not the in-conversation chat history, so toggling them does not reset the carried-over thread.

Free sampleApply prompt engineering and context craftingmedium

A developer is editing one file and wants Copilot's inline completions to match helper functions and types defined in other files of the same project. Which combination of context sources does Copilot draw on most directly to satisfy this?

  • AA full static index of every file in the repository, built and queried whether or not any of those files are currently open in the editor.
  • BThe organisation's audit log entries describing how other developers on the team used similar helper functions and types in earlier sessions.
  • CThe text in the current file together with related code from other project files the developer has open in neighbouring editor tabs. Correct
  • DThe commit history of the current branch, parsed to reconstruct how the helper functions and types evolved across previous changes.
Inline completions draw context from the current file and code in neighbouring open tabs, not a whole-repository index. Copilot assembles inline completion context from the file at the cursor and from related code in other tabs the developer has open, so opening the files that define the helpers and types is what brings them into scope.

Why A is wrong: Copilot does not statically index the entire repository for inline completions; it relies on the current file and open neighbouring tabs, not a whole-repo scan.

Why B is wrong: The audit log records administrative activity and is unrelated to assembling editor context for inline completions.

Why C is correct: Inline completions are built from the current file plus relevant snippets from neighbouring open tabs, which is how project helpers and types reach the suggestion.

Why D is wrong: Commit history is not a source for inline completion context; Copilot uses the open file and neighbouring tabs rather than parsing git history.

Other domains in this exam

See also the GH-300 cert hub, the study guide, and the cheat sheet.

Examworthy is not affiliated with or endorsed by GitHub. Original, blueprint-aligned practice material only.