Skip to content
Longterm Wiki
Back

This is a practical developer guide on prompt engineering for GitHub Copilot, focused on productivity rather than AI safety; the current tags (causal-model, corrigibility, shutdown-problem) appear to be incorrectly assigned and this resource has minimal relevance to AI safety topics.

Metadata

Importance: 12/100blog posteducational

Summary

A practical guide from GitHub developer advocates on prompt engineering for GitHub Copilot, explaining how to communicate more effectively with AI coding assistants to get better code suggestions. The article covers what prompts are, best practices for writing them, and concrete examples demonstrating how specificity and context improve AI-generated outputs.

Key Points

  • Vague prompts often produce irrelevant or no suggestions; specificity and context dramatically improve GitHub Copilot's output quality.
  • Prompt engineering for developers focuses on practical communication techniques rather than the ML research definition of the term.
  • Breaking down complex tasks into smaller, detailed sub-prompts yields more accurate and useful code generation.
  • Understanding how Copilot processes context (surrounding code, comments, file structure) helps developers frame better requests.
  • Iterative refinement of prompts is recommended, treating AI assistance as a collaborative, conversational process.

Cited by 1 page

PageTypeQuality
Corrigibility Failure PathwaysAnalysis62.0

Cached Content Preview

HTTP 200Fetched Apr 7, 202615 KB
How to write better prompts for GitHub Copilot - The GitHub Blog 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 

 
 
 
 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
 Rizel Scarlett & Michelle Duke 
 
 
 
 
 
 June 20, 2023 

 | 
 
 Updated February 26, 2025 
 
 | 
 
 
 
 25 minutes 
 
 
 
 
 
 Share: 
 

 
 
 
 
 
 
 

 
 
 
 
 
 
 

 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
 Generative AI coding tools are transforming the way developers approach daily coding tasks. From documenting our codebases to generating unit tests, these tools are helping to accelerate our workflows. However, just like with any emerging tech, there’s always a learning curve. As a result, developers—beginners and experienced alike—sometimes feel frustrated when AI-powered coding assistants don’t generate the output they want. (Feel familiar?)

 For example, when asking GitHub Copilot to draw an ice cream cone 🍦using p5.js, a JavaScript library for creative coding, we kept receiving irrelevant suggestions—or sometimes no suggestions at all. But when we learned more about the way that GitHub Copilot processes information, we realized that we had to adjust the way we communicated with it.

 Get the latest on GitHub Copilot

 GitHub Copilot is always adding new features and functionality. Check out these resources to keep up to date:

 
 Our comprehensive guide on how to use GitHub Copilot with real-world examples 

 The GitHub Copilot tag and GitHub Copilot category on the GitHub Blog

 The GitHub Copilot documentation and the GitHub Copilot Chat cookbook 

 
 
 Here’s an example of GitHub Copilot generating an irrelevant solution:

 

 When we adjusted our prompt, we were able to generate more accurate results:

 

 We’re both developers and AI enthusiasts ourselves. I, Rizel , have used GitHub Copilot to build a browser extension , rock, paper, scissors game , and to send a Tweet . And I, Michelle , launched an AI company in 2016. We’re both developer advocates at GitHub and love to share our top tips for working with GitHub Copilot.

 In this guide for GitHub Copilot, we’ll cover:

 
 What exactly a prompt is and what prompt engineering is, too (hint: it depends on whether you’re talking to a developer or a machine learning researcher).

 Three best practices and three additional tips for prompt crafting with GitHub Copilot .

 An example where you can try your hand at prompting GitHub Copilot to assist you in building a browser extension.

 
 Progress over perfection 

 Even with our experience using AI, we recognize that everyone is in a trial and error phase with generative AI technology. We also know the challenge of providing generalized prompt-crafting tips because models vary, as do the individual problems that developers are working on. This isn’t an end-all, be-all guide. Instead, we’re sharing what we’ve learned about prompt crafting to accelerate collective learning during this new age of software development.

 What’s a prompt and wha

... (truncated, 15 KB total)
Resource ID: 3da94a1dccb522fc | Stable ID: sid_DEZG3xt9xa