What's changed: New GH-300 Chapter 4 (effective prompts = structure [goal/context/expected output], how Copilot determines context, zero-shot/few-shot, select by relevance; principles & flow = clarity/specificity/iteration/decomposition, input+context→response→refine loop, chat-history use and caveats [irrelevant context/window consumption/new conversation])
4.1Crafting Effective Prompts
Understand prompt structure and how to provide context, how Copilot determines context, zero-shot/few-shot prompting, and best practices for crafting effective prompts.
As Chapter 3 showed, suggestion quality depends heavily on context. Hence prompt engineering—what you convey and how—drives results. A good prompt specifies "the goal, constraints, and expected output format concretely" and supplies sufficient, relevant context. Vague requests yield vague results.
4.1.1Prompt structure and context
An effective prompt includes the goal (what you want), context (the target code, assumptions, constraints), and expected output (language, format, style). In Copilot Chat, explicitly passing a selection or file improves accuracy. For inline suggestions, keeping related code open and writing clear function names/comments first act as "context hints." In short, reduce what the model must guess by supplying needed information up front.
Continue reading — free sign-up
You're reading the free preview. Sign up free to read this section in full, plus every chapter (including 4+) and all questions.

