GitHub Copilot Prompt Patterns
A prompt pattern is a proven sentence shape that you reuse again and again. Experienced Copilot users keep a small set of patterns in their head and swap in the details for each task. Patterns save time, reduce guesswork, and produce steadier answers. Each pattern below includes a template and a short example so you can start using it today.
Pattern 1: Role and Task
Give Copilot a role, then state the task. The role sets the tone and the level of detail.
TEMPLATE:
Act as a [role]. [Task].
EXAMPLE:
Act as a senior security reviewer. Check this login
function for weak points and list each one.Pattern 2: Show an Example
Copilot copies the style of an example you provide. Paste one sample of the output you want and ask for more in the same style.
TEMPLATE:
Here is an example: [sample]. Create [number] more in the same style.
EXAMPLE:
Here is a test: test('adds 2 and 3', () => expect(add(2,3)).toBe(5)).
Write four more tests for the subtract function in the same style.Pattern 3: Step by Step
Complex tasks work better when you ask for a plan before code. The plan reveals misunderstandings early.
TEMPLATE:
Explain your plan in steps. Wait for my approval. Then write the code.
EXAMPLE:
List the steps to build a password reset feature.
I will confirm each step before you write any code.Pattern 4: Set Limits
Constraints keep the answer inside your project rules. Name the language version, the library, the style, and the size.
TEMPLATE:
Write [thing] using [tool]. Do not use [tool]. Keep it under [limit].
EXAMPLE:
Write a date formatter using only built-in JavaScript.
Do not use external libraries. Keep it under 15 lines.Pattern 5: Fix Format
Tell Copilot exactly how to present the answer. A table, a list, or a single code block each suit different needs.
TEMPLATE:
Answer as a [format] with [columns or sections].
EXAMPLE:
Compare arrays and linked lists as a table with columns for
speed, memory use, and best use case.Pattern 6: Review and Improve
Ask Copilot to critique before it rewrites. This pattern catches problems that a direct rewrite might hide.
TEMPLATE:
Review this code for [concern]. List problems first. Then fix them.
EXAMPLE:
Review this function for speed problems. List each problem
first. Then show an improved version.Pattern 7: Compare Options
Use this pattern when you face a design choice. Copilot lays out the trade-offs and helps you decide.
TEMPLATE:
Compare [option A] and [option B] for [goal]. Recommend one.
EXAMPLE:
Compare REST and GraphQL for a small mobile app with three
screens. Recommend one and explain why.Combining Patterns
Strong prompts often stack two or three patterns. The prompt below joins Role, Limits, and Format in one request.
Act as a database expert. ← Role
Write a query that lists the top 5 customers
by total spending. Use standard SQL only. ← Limits
Show the result as code followed by a one-line
explanation. ← FormatBuild Your Personal Library
Store your favorite patterns in a notes file. Add the date and a short comment on what worked. Review the file monthly and remove patterns that no longer help. A library of ten solid patterns beats a hundred half-remembered ideas.
MY PATTERN LIBRARY
┌─────────────────┬────────────────────────────┐
│ TASK TYPE │ PATTERN TO USE │
├─────────────────┼────────────────────────────┤
│ New function │ Set Limits + Fix Format │
│ Bug hunt │ Review and Improve │
│ Learning │ Role and Task │
│ Design choice │ Compare Options │
└─────────────────┴────────────────────────────┘Patterns guide your thinking, and they never replace judgment. Adjust the wording until the answer fits the problem in front of you.
Adapting Patterns to Your Level
Beginners benefit most from the Role and Task and Show an Example patterns because they need clear explanations and concrete samples. Experienced developers lean on Set Limits and Review and Improve to enforce standards and catch subtle problems. Start with the patterns that match your current needs. Add more as your projects grow and your questions become more specific.
Notice how each template names the goal, the context, and the expected result. Those three parts form the backbone of every strong prompt. Copy the structure, replace the details, and watch the quality of your answers rise.
