Domain 5 of 6 · Chapter 1 of 2

Craft Effective Prompts

Unlock the complete study guide.

Bundled into the existing GitHub Copilot premium course — no separate purchase.

14-day money-back guarantee — no questions asked.

Included in this chapter:

  • Request text, surrounding context, examples, and task scope
  • Request text: goal first, then requirements
  • Request text: precise wording
  • Expert roles: a perspective, not a specification
  • Keep Copilot Chat requests on coding and technology topics
  • Surrounding context: implicit and explicit
  • Readable code as a context signal
  • Zero-shot and few-shot prompting
  • Choosing representative examples
  • Task scope: split, sequence, and bound each step
  • Plan first when the approach is unclear
  • Apply best practices for prompt crafting

Request text, surrounding context, examples, and task scope

AspectRequest textSurrounding contextExamplesTask scope
Question it answersWhat exactly do I want?What can Copilot see besides my words?What should the result look like?How much do I ask for at once?
Core techniquesGoal first, then contract, constraints, and verifiable success; exact referents; concrete terms; named library; response form; clarifying questionsRelevant files open, irrelevant closed; select the code; explicit attachments for essential sources; readable project codeZero-shot for familiar patterns, and as a baseline when unsure whether examples are needed; one-shot (one example) or few-shot (several) when a pattern needs demonstrating, from the first prompt when the output must follow your own specific pattern or convention; representative examples or unit testsSplit into small requests; sequence by dependency; one observable result per step; plan first when unclear
Risks it reducesCopilot infers the goal, interface, or quality barCopilot uses the wrong code or misses a mandatory sourceOutput ignores a required shape or conventionErrors hidden inside one oversized change
Practice pitfallAn expert persona or "make it better" treated as a requirement"Open every file" or trusting "this" to resolveOne example repeated, or assuming examples were needed without a baselineEvery feature combined into one prompt

Decision tree

Is the approachalready clear?Plan firstexplore, plan, review the planNoYesOne small task with anobservable result?Split and sequencethen take each step through this treeNoYesOutput must follow your ownspecific pattern or convention?Examples in the first promptone-shot or few-shot, representativeYesNo or unsureZero-shot baselinemeets the requirement?Keep zero-shotbaseline was enoughYesNoAdd examplesone-shot or few-shot:representative examples or testsEvery prompt: goal first, then requirements; attach essential context explicitly

Cheat sheet

  • Lead with the goal before listing detailed requirements
  • State the input and output contract explicitly
  • Declare implementation constraints that affect the solution
  • Define success with verifiable outcomes
  • Name the exact code element a request refers to
  • Replace vague quality terms with concrete changes
  • Explain the purpose of an uncommon library
  • Identify a required library instead of leaving the choice implicit
  • Curate open files around the current task
  • Select the code that an IDE chat request should target
  • Explicitly attach context that the answer must consider
  • Readable project code provides stronger prompting signals
  • Attach visual and rendered-page evidence as explicit VS Code chat context
  • Zero-shot prompting supplies instructions without examples
  • Use zero-shot prompting first for familiar standard tasks
  • Use zero-shot output as a performance baseline
  • Zero-shot prompting avoids demonstration overhead
  • Few-shot prompting demonstrates the desired pattern with several examples
  • Examples can demonstrate inputs, outputs, or implementations
  • Unit tests can act as executable prompting examples
  • Use representative examples that do not imply a false pattern
  • Split a large task into small focused requests
  • Sequence dependent subtasks so later prompts build on verified work
  • Give each subtask its own observable result
  • Resolve an unclear approach before requesting implementation
  • Assign a relevant expert role for a specialized task
  • Specify the response form the task requires
  • Ask Copilot to clarify ambiguous requirements before acting
  • Keep Copilot Chat prompts focused on coding and technology

Unlock with Premium — includes all practice exams and the complete study guide.

Also tested in

References

  1. https://learn.microsoft.com/en-us/training/modules/introduction-prompt-engineering-with-github-copilot/2-prompt-engineering-foundations-best-practices
  2. https://docs.github.com/en/copilot/concepts/prompting/prompt-engineering
  3. https://code.visualstudio.com/docs/agents/concepts/context
  4. https://learn.microsoft.com/en-us/dotnet/ai/conceptual/zero-shot-learning
  5. https://code.visualstudio.com/docs/agents/best-practices
  6. https://docs.github.com/en/copilot/get-started/best-practices
  7. https://learn.microsoft.com/en-us/credentials/certifications/resources/study-guides/gh-300
  8. https://docs.github.com/en/copilot/how-tos/chat-with-copilot/chat-in-ide
  9. https://docs.github.com/en/copilot/responsible-use/chat
  10. https://code.visualstudio.com/docs/chat/copilot-chat-context
  11. https://docs.github.com/en/copilot/concepts/completions/code-suggestions