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
| Aspect | Request text | Surrounding context | Examples | Task scope |
|---|---|---|---|---|
| Question it answers | What 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 techniques | Goal first, then contract, constraints, and verifiable success; exact referents; concrete terms; named library; response form; clarifying questions | Relevant files open, irrelevant closed; select the code; explicit attachments for essential sources; readable project code | Zero-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 tests | Split into small requests; sequence by dependency; one observable result per step; plan first when unclear |
| Risks it reduces | Copilot infers the goal, interface, or quality bar | Copilot uses the wrong code or misses a mandatory source | Output ignores a required shape or convention | Errors hidden inside one oversized change |
| Practice pitfall | An expert persona or "make it better" treated as a requirement | "Open every file" or trusting "this" to resolve | One example repeated, or assuming examples were needed without a baseline | Every feature combined into one prompt |
Decision tree
Cheat sheet
Unlock with Premium — includes all practice exams and the complete study guide.
Also tested in
References
- https://learn.microsoft.com/en-us/training/modules/introduction-prompt-engineering-with-github-copilot/2-prompt-engineering-foundations-best-practices
- https://docs.github.com/en/copilot/concepts/prompting/prompt-engineering
- https://code.visualstudio.com/docs/agents/concepts/context
- https://learn.microsoft.com/en-us/dotnet/ai/conceptual/zero-shot-learning
- https://code.visualstudio.com/docs/agents/best-practices
- https://docs.github.com/en/copilot/get-started/best-practices
- https://learn.microsoft.com/en-us/credentials/certifications/resources/study-guides/gh-300
- https://docs.github.com/en/copilot/how-tos/chat-with-copilot/chat-in-ide
- https://docs.github.com/en/copilot/responsible-use/chat
- https://code.visualstudio.com/docs/chat/copilot-chat-context
- https://docs.github.com/en/copilot/concepts/completions/code-suggestions