Technical Preview

Your AI pair programmer

With GitHub Copilot, get suggestions for whole lines or entire functions right inside your editor.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env ts-node import { fetch } from "fetch-h2"; // Determine whether the sentiment of text is positive // Use a web service async function isPositive(text: string): Promise<boolean> { const response = await fetch(`http://text-processing.com/api/sentiment/`, { method: "POST", body: `text=${text}`, headers: { "Content-Type": "application/x-www-form-urlencoded", }, }); const json = await response.json(); return json.label === "pos"; }
Copilot
Powered by

Trained on billions of lines of public code, GitHub Copilot puts the knowledge you need at your fingertips, saving you time and helping you stay focused.

Extends your editor

GitHub Copilot is available as an extension for Neovim, JetBrains, and Visual Studio Code. You can use the GitHub Copilot extension on your desktop or in the cloud on GitHub Codespaces. And it’s fast enough to use as you type.

Speaks all the languages you love

GitHub Copilot works with a broad set of frameworks and languages. The technical preview does especially well for Python, JavaScript, TypeScript, Ruby, Java, and Go, but it understands dozens of languages and can help you find your way around almost anything.

You’re the pilot

With GitHub Copilot, you’re always in charge. You can cycle through alternative suggestions, choose which to accept or reject, and manually edit suggested code. GitHub Copilot adapts to the edits you make, matching your coding style.

More than autocomplete

GitHub Copilot is powered by Codex, the new AI system created by OpenAI. GitHub Copilot understands significantly more context than most code assistants. So, whether it’s in a docstring, comment, function name, or the code itself, GitHub Copilot uses the context you’ve provided and synthesizes code to match. Together with OpenAI, we’re designing GitHub Copilot to get smarter at producing safe and effective code as developers use it.

Visual Studio Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package main type Run struct { Time int // in milliseconds Results string Failed bool } // Get average runtime of successful runs in seconds func averageRuntimeInSeconds(runs []Run) float64 { var totalTime int var failedRuns int for _, run := range runs { if run.Failed { failedRuns++ } else { totalTime += run.Time } } averageRuntime := float64(totalTime) / float64(len(runs) - failedRuns) / 1000 return averageRuntime }
Copilot
main
Ln 23 Col, 1

Skip the docs and stop searching for examples. GitHub Copilot helps you stay focused right in your editor.

Convert comments to code. Write a comment describing the logic you want, and let GitHub Copilot assemble the code for you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/** * json schema: * [ * { name: "John Doe", * collaborators: ["Jane Doe", "Herbert Frapp", "Elsie McEwan"] * }, * { name: "Jane Doe", * collaborators: ["John Doe", "Karen Smith"] * }, * { name: "Skittles the Cat", * collaborators: [] * } * ] */ function collaborators_map(json: any): Map<string, Set<string>> { const map = new Map<string, Set<string>>(); for (const item of json) { const name = item.name; const collaborators = item.collaborators; const set = new Set<string>(collaborators); map.set(name, set); } return map; }
Copilot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
interface CommentMarker { start: string; end: string; } const markers: { [language:string]: CommentMarker } = { javascript: { start: '//', end: ''}, python: { start: '#', end: ''}, css: { start: '/*', end: '*/'}, html: { start: '<!--', end: '-->'}, bash: { start: '#', end: ''}, postscript: { start: '%', end: ''}, cobol: { start: '*', end: ''} asm: { start: ';', end: ''}, haskell: { start: '--', end: ''} }
Copilot

Autofill for repetitive code. GitHub Copilot works great for quickly producing boilerplate and repetitive code patterns. Feed it a few examples and let it generate the rest!

Tests without the toil. Tests are the backbone of any robust software engineering project. Import a unit test package, and let GitHub Copilot suggest tests that match your implementation code.

1
2
3
4
5
6
7
8
9
10
11
12
def strip_suffix(filename): """ Removes the suffix from a filename """ return filename[:filename.rfind('.')] def test_strip_suffix(): """ Tests for the strip_suffix function """ assert strip_suffix('notes.txt') == 'notes' assert strip_suffix('notes.txt.gz') == 'notes.txt'
Copilot

Show me alternatives. Want to evaluate a few different approaches? GitHub Copilot can show you a list of solutions. Use the code as provided, or edit it to meet your needs.

Visual Studio Code
1
2
3
4
5
6
def max_sum_slice(xs): max_ending = max_so_far = 0 for x in xs: max_ending = max(0, max_ending + x) max_so_far = max(max_so_far, max_ending) return max_so_far
main
Ln 6 Col, 21

Code confidently
in unfamiliar territory

Whether you’re working in a new language or framework, or just learning to code, GitHub Copilot can help you find your way. Tackle a bug, or learn how to use a new framework without spending most of your time spelunking through the docs or searching the web.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
const token = process.env["TWITTER_BEARER_TOKEN"] const fetchTweetsFromUser = async (screenName, count) => { const response = await fetch( `https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=${screenName}&count=${count}`, { headers: { Authorization: `Bearer ${token}`, }, } ) const json = await response.json() return json }
Copilot

Flight reports

Hundreds of engineers, including many of our own, have been using GitHub Copilot every day. It’s transformed the way they work – here’s what they have to say:

Trying to code in an unfamiliar language by googling everything is like navigating a foreign country with just a phrase book. Using GitHub Copilot is like hiring an interpreter.

Harri Edwards // OpenAI

It surprised me with how precisely it understood my comment and generated accurate suggestions. The ability to choose from 10 different suggestions was the cherry on top.

Gunnika Batra

I’m impressed by how GitHub Copilot seems to know exactly what I want to type next. GitHub Copilot is particularly helpful when working on React components, where it makes eerily accurate predictions. GitHub Copilot has become an indispensable part of my programmer toolbelt.

Feross Aboukhadijeh

GitHub Copilot discovered that a test file I was working in was missing a specific test and suggested and wrote the test for me.

Kate Studwell // GitHub

How it works

how it works

Frequently
asked questions

What is GitHub Copilot?
GitHub Copilot is an AI pair programmer that helps you write code faster and with less work. GitHub Copilot draws context from comments and code, and suggests individual lines and whole functions instantly. GitHub Copilot is powered by OpenAI Codex, a new AI system created by OpenAI. The GitHub Copilot technical preview is available as an extension for Visual Studio Code, Neovim, and the JetBrains suite of IDEs.
How does GitHub Copilot work?
OpenAI Codex was trained on publicly available source code and natural language, so it understands both programming and human languages. The GitHub Copilot editor extension sends your comments and code to the GitHub Copilot service, which then uses OpenAI Codex to synthesize and suggest individual lines and whole functions.
How good is GitHub Copilot?
We recently benchmarked against a set of Python functions that have good test coverage in open source repos. We blanked out the function bodies and asked GitHub Copilot to fill them in. The model got this right 43% of the time on the first try, and 57% of the time when allowed 10 attempts. And it’s getting smarter all the time.
Does GitHub Copilot write perfect code?
No. GitHub Copilot tries to understand your intent and to generate the best code it can, but the code it suggests may not always work, or even make sense. While we are working hard to make GitHub Copilot better, code suggested by GitHub Copilot should be carefully tested, reviewed, and vetted, like any other code. As the developer, you are always in charge.
How do I get the most out of GitHub Copilot?
It works best when you divide your code into small functions, use meaningful names for functions parameters, and write good docstrings and comments as you go. It also seems to do best when it’s helping you navigate unfamiliar libraries or frameworks.
What context does GitHub Copilot use to generate suggestions?
GitHub Copilot relies on file content for context, both in the file you are editing, as well as neighboring or related files. When you are using GitHub Copilot, it may also collect the URLs of repositories or file paths to identify relevant context.
How will GitHub Copilot get better over time?
GitHub Copilot doesn’t actually test the code it suggests, so the code may not even compile or run. GitHub Copilot can only hold a very limited context, so even single source files longer than a few hundred lines are clipped and only the immediately preceding context is used. And GitHub Copilot may suggest old or deprecated uses of libraries and languages. You can use the code anywhere, but you do so at your own risk.
How can I contribute?
The best way to contribute is to sign up for the technical preview. By using GitHub Copilot and sharing your feedback, you help to improve the models that power GitHub Copilot.
Can I post code suggested by GitHub Copilot to social media like Twitter?

Of course! Please use #GitHubCopilot when you post so we can see what you produce!