Overview
Apply prompt engineering and context crafting focuses on the inputs that drive Copilot's output. It has two official groups. Crafting effective prompts covers describing prompt structure and context, understanding how context is determined, using zero-shot and few-shot prompting, and applying best practices for prompt crafting. Engineering prompts for performance covers explaining prompt engineering principles and describing the prompt process flow and how chat history is used.
GitHub's guidance is practical: start with a general goal and then add specifics, give examples of inputs and outputs, break complex tasks into smaller steps, avoid ambiguity, point Copilot at the relevant code, and iterate. Context comes from comments, names, open files and, in Chat, from references such as #file or a selection and from earlier turns. The August 2026 update did not change this domain.
How it's tested
Prompt questions on GH-300 typically compare prompts, describe a weak response and ask for the best fix, or ask how Copilot determines its context. The right answer usually adds specificity, examples, smaller steps or better context, rather than repeating the same request with more words.
-
Better prompt
Two to four prompts are shown, and you choose the one that is specific, scoped and gives Copilot the context it needs.
-
Zero-shot or few-shot
A prompt is described, and you identify whether it gives examples, or choose to add examples to get a required format.
-
Fix the context
Copilot's answer ignores relevant code or repeats an old assumption, and you choose to reference files, open tabs or start a new thread.
A developer asks Copilot Chat to convert dates to the team's format, and the result uses the wrong format twice. Repeating the request or adding "please be accurate" does not supply missing information. Giving two sample inputs with their expected outputs turns the request into a few-shot prompt that shows the exact format, so adding examples is the best fix.
Functional groups 2
Official functional groups from the GitHub (Microsoft) outline, in outline order.
4.1 Craft effective promptsPrompt structure and context, how context is determined, zero-shot and few-shot, best practices.
- What it means
- This group covers four official skills: describe prompt structure and context, understand how context is determined, use zero-shot and few-shot prompting, and apply best practices for prompt crafting in Copilot inline suggestions and Chat.
- What to understand
- A strong prompt states the goal, the constraints, the inputs and the expected output, and points to relevant code. Copilot determines context from the current file, cursor position, comments, function names, imports and open tabs, and in Chat from selections, references such as #file and the conversation. Zero-shot prompts give only an instruction, while few-shot prompts include examples. Best practices include starting general then adding detail, splitting complex tasks and removing ambiguity.
- How it shows up
- Expect to compare prompts or pick the change that gives Copilot the missing context or format.
- Common confusion
- Confusing few-shot prompting with a multi-turn conversation; few-shot means examples inside the prompt.
4.2 Engineer prompts for performancePrompt engineering principles, process flow and chat history usage.
- What it means
- This group covers two official skills: explain prompt engineering principles, and describe the prompt process flow and how chat history is used. It focuses on getting consistent, high-quality results across a working session.
- What to understand
- Prompt engineering principles include clarity, specificity, giving examples, breaking tasks down and iterating on results. In Chat, each request combines the new message with context and recent conversation turns, so earlier answers shape later ones. Helpful history speeds work, but irrelevant or wrong history can mislead Copilot. Starting a new thread, deleting unhelpful turns or restating requirements resets the context, and custom instructions or prompt files keep recurring guidance consistent.
- How it shows up
- Look for a session where answers drift or repeat an earlier mistake, and choose to reset or refine context.
- Common confusion
- Assuming Chat remembers every past conversation; history applies within the current thread, not across all sessions.
High-yield concepts
The terms, rules and formulas this domain turns into questions most often.
-
Prompt structure
Goal, context, constraints and expected output.
- Remember
- Clear structure beats longer text.
- Tested as
- Better-prompt questions.
- Trap
- Choosing the longest prompt.
-
Zero-shot prompting
An instruction with no examples.
- Remember
- Works for common, simple tasks.
- Tested as
- Identification questions.
- Trap
- Calling any short prompt zero-shot regardless of examples.
-
Few-shot prompting
A prompt that includes input and output examples.
- Remember
- Best for exact formats or patterns.
- Tested as
- Format fix questions.
- Trap
- Confusing it with multi-turn chat.
-
Start general, then specific
State the broad goal, then add requirements.
- Remember
- GitHub recommends this order.
- Tested as
- Best practice questions.
- Trap
- Front-loading every detail at once.
-
Break down complex tasks
Split large requests into smaller steps.
- Remember
- Improves accuracy on multi-part work.
- Tested as
- Best practice questions.
- Trap
- Asking for a whole app in one prompt.
-
Neighboring tabs
Open files that inform inline suggestions.
- Remember
- Open related files, close unrelated ones.
- Tested as
- Context determination questions.
- Trap
- Assuming closed files are always used.
-
Chat references
Explicit pointers such as #file, #selection or a codebase reference.
- Remember
- They tell Chat exactly what to consider.
- Tested as
- Context crafting questions.
- Trap
- Relying on Chat to guess the file.
-
Chat history
Earlier turns in the thread sent with new requests.
- Remember
- Stale history can mislead answers.
- Tested as
- Process flow questions.
- Trap
- Thinking every message starts fresh.
-
New thread
Starting a clean conversation to reset context.
- Remember
- Use it when switching topics.
- Tested as
- Drift fix questions.
- Trap
- Continuing a long, unrelated thread.
-
Iteration
Refining a prompt based on the last answer.
- Remember
- Prompting is a loop, not one shot.
- Tested as
- Principle questions.
- Trap
- Giving up after one weak answer.
Side by side
Concepts candidates mix up, compared on the point that decides the answer.
Zero-shot vs. few-shot vs. multi-turn
| Concept | Meaning | Key difference | Common trap |
|---|---|---|---|
| Zero-shot | Instruction only | No examples given | Using it for strict formats |
| Few-shot | Instruction plus examples | Examples define the pattern | Calling it multi-turn |
| Multi-turn | A conversation refined over replies | Context grows over turns | Treating it as few-shot |
Ways to give Copilot context
| Concept | Meaning | Key difference | Common trap |
|---|---|---|---|
| Comments and names | Describe intent in code | Drives inline suggestions | Vague comments |
| Open tabs | Related files in the editor | Used as neighboring context | Leaving unrelated files open |
| Chat references | Explicit files, selections or symbols | Precise targeting in Chat | Expecting Chat to infer files |
| Custom instructions | Standing preferences for a repository | Applies to every request | Repeating them in each prompt |
Exam traps
Each trap is an answer that looks right. Learn the clue that should change your mind.
-
More words, better prompt
- What candidates pick
- Choose the longest prompt option.
- Why it looks right
- It looks thorough.
- Why it's wrong
- Clarity, scope and relevant context matter more than length; padded prompts can add ambiguity.
Clue to watch for One option is short but names inputs, outputs and constraints.
-
Few-shot is a conversation
- What candidates pick
- Describe several chat turns as few-shot prompting.
- Why it looks right
- Both involve more than one exchange.
- Why it's wrong
- Few-shot means the prompt itself contains examples of input and expected output.
Clue to watch for The question asks how to show Copilot a required format.
-
Chat sees everything
- What candidates pick
- Assume Chat automatically uses the right file without references.
- Why it looks right
- Copilot is integrated in the IDE.
- Why it's wrong
- Chat uses the active editor and what you reference; naming files or selections makes context explicit.
Clue to watch for The answer ignored a file the developer had in mind.
-
History always helps
- What candidates pick
- Keep working in the same thread after changing tasks.
- Why it looks right
- More context sounds better.
- Why it's wrong
- Old turns are sent with new requests and can carry wrong assumptions into unrelated answers.
Clue to watch for Answers keep repeating an earlier requirement that no longer applies.
-
One giant prompt
- What candidates pick
- Ask Copilot to build an entire service in one request.
- Why it looks right
- It seems efficient.
- Why it's wrong
- GitHub recommends breaking complex tasks into smaller steps to get more accurate and reviewable output.
Clue to watch for The request contains many separate components.
-
Politeness fixes accuracy
- What candidates pick
- Add phrases like be accurate to fix wrong output.
- Why it looks right
- It feels like clearer instruction.
- Why it's wrong
- Accuracy improves when you add missing facts, examples or constraints, not generic encouragement.
Clue to watch for The prompt lacks the information needed for a correct answer.
Answer framework
When a GH-300 question asks how to improve Copilot's response, follow these prompting steps.
- Check whether the prompt states a clear goal, the inputs, the constraints and the expected output; add whichever piece is missing first.
- If an exact format or pattern is required, add one or more examples to make the prompt few-shot rather than zero-shot.
- If the request covers several components, break it into smaller sequential prompts and review each result before continuing.
- If Copilot ignores relevant code, provide context by opening related files, selecting code or referencing files explicitly in Chat.
- If answers drift or repeat old assumptions, start a new thread or restate requirements, and move standing rules into custom instructions.
Practice question
Want more like this? The GH-300 practice test has questions for every domain.
Checklist
0 of 10
Tick each one you can do without notes. Your ticks stay in this browser.
Study strategy
Learn this domain by doing. Open a small project with Copilot and run the same task several ways: a vague prompt, a specific prompt, a zero-shot request and a few-shot request with examples. Note how the output changes and keep the best and worst prompts as personal reference examples.
Next, read GitHub's prompt engineering guide for Copilot and turn its recommendations into a short checklist: start general then add specifics, give examples, break complex tasks down, avoid ambiguity, indicate relevant code, experiment and iterate, and keep history relevant. Practise each item until it feels natural.
Then study context. For inline suggestions, test how comments, function names and open tabs change the result. In Chat, use selections and file references, and watch how a long thread carries earlier assumptions forward. Starting a fresh thread and comparing answers makes the role of chat history clear.
Finally, connect prompting to instructions files and prompt files from Domain 2, since they are the durable form of good prompts, and use timed questions to practise picking the better prompt quickly.
FAQ
How much of GH-300 is Domain 4, Apply prompt engineering and context crafting?
Apply prompt engineering and context crafting is 10–15% of the exam, about six to nine questions.
What is the difference between zero-shot and few-shot prompting?
A zero-shot prompt gives only an instruction. A few-shot prompt includes one or more examples of input and expected output so Copilot can follow a pattern or format.
How does Copilot decide what context to use?
For inline suggestions it uses the current file, cursor position, comments, names, imports and related open tabs. Chat also uses selections, explicit references and earlier turns in the thread.
When should I start a new chat thread?
When you switch tasks or notice answers repeating outdated assumptions. A new thread removes old history that could mislead Copilot.
Are longer prompts better?
Not necessarily. Specific, unambiguous prompts with the right context and examples beat long prompts padded with general instructions.
How do prompt files relate to prompt engineering?
Prompt files store well-crafted prompts for reuse, so a team gets consistent responses without rewriting the same instructions each time.
Other Artificial Intelligence & Machine Learning certifications
Where the same subject shows up in other exams. Cards marked "Same subject" open the matching domain.
Test your Domain 4 knowledge
You have covered prompt structure, context, zero-shot and few-shot prompting, best practices and chat history. Test whether you can pick the prompt that gets the right answer.
Keep going
- Training Training Built on your Weak areas
- Practice test Questions by domain, with explanations
- Mock exam Full length, timed like the real exam
- Readiness test Find your weakest domain in minutes
- Cheat sheet Key terms and formulas on one page
- Ask the GH-300 AI tutor Get any concept explained your way