Github Copilot Tips and Tricks
Github Copilot Tips and Tricks
Foreword
During my tenure at Microsoft Germany, I have had the privilege of contributing to several e-books.
The first e-book – if I recall correctly – was the Visual Studio Island Book 2013, featuring insights on
Visual Studio, Team Foundation Server, Windows 8, and Windows Azure (as it was known back then).
Subsequent e-books followed on topics such as Visual Studio, Visual Studio Code, and efficient remote
collaboration among development teams shortly after the outbreak of Covid. For the latter e-book,
Thomas Dohmke, who is now the CEO of GitHub, wrote about the cultural transformation at GitHub.
The next wave of change is already underway – naturally, I am referring to GitHub Copilot.
Back in 2015, Satya Nadella, CEO of Microsoft, declared that every company would become a software
company. Satya Nadella has reiterated this statement in various forms to this day. The essence always
revolves around empowering development teams or so-called Citizen Developers to use their creativity to
the fullest in solving problems and creating new products and solutions that provide value. Therefore, the
focus is on enabling the creation of new things with technology and concentrating on what's essential.
And this is precisely where GitHub Copilot comes in. To bring you this new offering from the user's
perspective, we decided it was time to publish another e-book featuring real-life tips and tricks about
GitHub Copilot. The idea is to continually expand the e-book with new tips and tricks. If you would like to
contribute to one of the upcoming editions, please feel free to email me at [email protected]. I
Until then, I hope you enjoy reading the first edition of this e-book.
Dennis Gassen
Malte Lantin
Just three years after GitHub's first internal whitepaper on AI-assisted software development in 2020, and the
launch of GitHub Copilot in 2022, GitHub Copilot has already become a standard tool for many developers
and enterprises. It's easy to forget that AI support in software development was once viewed as mere fiction.
Today, GitHub Copilot represents a turning point in the development of software tools.
With continuous improvements and features specifically designed for professional use in businesses, GitHub
Copilot has become an indispensable tool. This introduction explores its basic functionality and the added
value it provides, which will be illustrated through numerous case studies in the following chapters.
Azure OpenAI Services, and seamless integration into the development process. Developers now have
AI-powered code completion at their fingertips in Visual Studio Code, Visual Studio, the JetBrains IDEs,
and other editors, drawing context from actively worked-on source files and information from the
respective editor. This enables it to generate relevant and highly applicable code suggestions during
the development process. The “Fill-in-the-Middle” (FIM) paradigm used allows for suggestions that are
optimally adjusted to the current context and consider the style of the project.
By the end of 2023, the introduction of GitHub Copilot Chat significantly expanded the possibilities for
AI-driven development. Integrated directly into the development environment, this chat interface now
or even creating complete work environments by GitHub Copilot. With its iterative approach based on
natural language, Copilot Chat is accessible and helps developers speed up software development, fix
problems, and learn new technologies. The contextual knowledge that GitHub Copilot gains from the
code editor is a key differentiator from other chat-based AI language models. GitHub Copilot Chat can
access knowledge from requested files or command line statements, thus providing perfectly tailored
GitHub Copilot is continuously expanding and since spring 2024 has also been available as an exten-
sion of the GitHub CLI Tools to explain or generate commands on the command line.
Since February 2024, companies using GitHub Enterprise Cloud have also been able to benefit from an
even deeper integration of GitHub Copilot into their development processes. This includes integrating
GitHub Copilot Chat with the GitHub web interface, AI-powered editing of pull requests, access to the
knowledge of their own source code repositories and documentation, and future customization of AI
models to their own codebases. This support extends parts of the development process that occur
spread acceptance within the developer community. Today, more than 1.8 million software developers
use GitHub Copilot, and over 50,000 companies have opted to implement the technology. The impact
of GitHub Copilot on developer productivity is both quantifiable and significant. In one study, it was
found that over 30 percent of suggestions from GitHub Copilot are accepted, highlighting its relevance
and utility in daily development. With a work speed increase of up to 55 percent, the benefits are clear.
Equally important, however, is that developers report feeling more satisfied and productive when using
GitHub Copilot, as surveys suggest. Studies also show that code quality improves, and code reviews are
described as more purposeful and quicker. Developers report being able to work more focused for
longer periods as GitHub Copilot helps minimize context switching and distractions.
The greatly enhanced development experience offers benefits beyond productivity gains. By automa-
ting routine and repetitive aspects, GitHub Copilot enables developers to focus on the more complex
It symbolizes the beginning of a new era of AI-assisted programming that significantly enhances
developer productivity, improves code quality, and positively affects the overall well-being of develo-
pers. As GitHub Copilot continues to evolve and integrate more deeply into the software development
process, its influence will grow, making it an indispensable tool in the field of software development.
The following chapters will describe practical applications and illustrate the everyday benefits of using
GitHub Copilot. We hope you enjoy reading and using GitHub Copilot!
Further information:
• 2
Quantifying GitHub Copilot’s impact on code quality
Foreword................................................................................................................................................................................................................ 2
Better prompts for better code – tips & tricks for developers.......................................................................................................45
Additional resources........................................................................................................................................................................................79
#GitHubCopilot
GitHub Copilot introduces artificial intelligence into development, helping developers create better code
faster. This AI assistant aids in writing individual lines or entire blocks of code and can suggest ways to
expand or improve existing code. The result is a development process accelerated by more than half, as
For example, with GitHub Copilot, you can write a comment that describes the desired logic and sets
your preferred style conventions. AI handles the rest, allowing you to focus on the truly complex tasks.
This enables you to work more productively and complete repetitive tasks much faster and with less
stress. GitHub Copilot also helps developers master a new language or framework faster than would be
Script, TypeScript, Go, and Ruby. More than 50,000 companies have already implemented this AI
GitHub Copilot also enhances team collaboration. It indexes your repositories, understands the code
stored within, and helps you get up to speed with new codebases more quickly. When you connect
new repositories, you can build upon the work of others. Another application of GitHub Copilot is in
creating functions and diagrams that developers specify via a prompt. GitHub Copilot avoids vulnera-
bilities and security gaps right from the code generation phase, as the system is optimized to generate
As you write lines of code, GitHub Copilot analyzes the code and automatically suggests
completions. This creates perfect harmony between the developer and AI. Developers can also
use GitHub Copilot to automatically create commit messages. There are many applications that
GitHub Copilot not only helps in creating new code or improving existing lines of code. The AI assistant is
also a valuable tool for finding errors in code based on a “conversation” in natural language. If you get
stuck, just ask GitHub Copilot. GitHub Copilot acts intelligently, personalizing responses based on your
expertise and available documentation, from which the AI models continue to learn.
You don’t have to leave your preferred development environment to use it. You can integrate GitHub
Copilot directly into your development environment through extensions, for example in Visual Studio,
Visual Studio Code, Vim, Neovim, JetBrains Suite, and Azure Data Studio. GitHub Copilot can also assist
in the CLI to provide help. Since 2024, GitHub Copilot has also been available for GitHub Mobile,
allowing developers to work with GitHub Copilot on smartphones and tablets just as they would on a
desktop computer.
The latter choose either GitHub Copilot Business or GitHub Copilot Enterprise. For individual developers,
there is GitHub Copilot Individual. All versions have one thing in common: they convert natural langua-
GitHub Copilot Business is primarily aimed at businesses. For $19 per user per month, developers in
the company gain access to GitHub Copilot, including code completions, chat with GitHub Copilot
over the IDE and GitHub Mobile, CLI support, filters for security gaps and public code, enterprise-level
security and privacy, and code referencing. When GitHub Copilot recognizes vulnerable coding patterns,
it blocks the lines. This also applies to the use of public code.
GitHub Copilot Enterprise offers additional features to the Business version, significantly increasing
respective company and support for pull request diff analysis for more precise code reviews. In code
completion, users benefit from specially tailored models to further enhance the efficiency and
precision of code creation. GitHub Copilot Enterprise can be used not only in IDE, CLI, and GitHub
GitHub Copilot Individual is aimed at individual developers who want to complete code. It also
includes a chat with GitHub Copilot. This version is particularly suitable for individual developers and
probability calculations. Although the models used by GitHub Copilot are trained with code from
publicly accessible repositories, they do not contain code themselves. In generating code, GitHub
Copilot utilizes the existing code in the IDE, especially the lines above and below the cursor. This
includes information from training data and other files that you have linked with GitHub Copilot and
the respective repository. Based on this data, GitHub Copilot generates the next lines of code or makes
innovative possibilities. At Microsoft Build 2024, for example, GitHub Copilot Extensions were introdu-
ced, allowing partner technologies to integrate directly with GitHub Copilot Chat. Early partners inclu-
de DataStax, Docker, LambdaTest, Microsoft Azure, MongoDB, Octopus Deploy, Sentry, and Stripe.
A possible scenario for using the extensions: You need to fix a database error in your development
project. Through GitHub Copilot Chat, you can use various tools and technologies such as Sentry or
Azure to analyze and fix the problem without having to switch contexts.
This is just one of many examples of how GitHub Copilot is being developed. Current updates are
Martin Brandl
GitHub Copilot's Slash Commands make interacting with the assistant even more efficient.
By simply tapping a slash ("/") in the chat a list of useful commands appears, allowing you to perform
They are indicated with the @ symbol. Currently, there are two:
• @workspace has context information about the code in your workspace and can help you navi-
gate by finding relevant files or classes.
• @vscode knows commands and functions in the VS Code editor itself and can help you use them
effectively.
Example: In the following code snippet, an integer division is performed, where the decimal places are
int x = 5;
int y = 2;
double result = x / y;
However, this error can be easily fixed by running the /fix command in the GitHub Copilot chat. The @
• @workspace /explain: This command explains the selected code step by step.
• @workspace /fix: This command suggests a solution for any errors in the selected code.
• @workspace /new: This command allows you to create a new project based on a natural
language description.
• @workspace /newNotebook: This command enables the creation of a new Jupyter Notebook
• @workspace /terminal: This command provides explanations on how to use the integrated
• @workspace /tests: This command automatically generates unit tests for the selected code.
• @vscode /api: If you have questions about developing VS Code extensions, this command is
available to you.
David Losert
From standardization and modernization efforts over a lack of developer expertise to the desire for
company-wide collaboration across team boundaries (keyword: innersourcing), there are many good
reasons to translate an existing application or parts of it from one programming language to another.
Especially in enterprises and after about a decade of technological diversification – driven not least by
cloud – we are now seeing a reverse movement and a desire for more standardization and uniformity.
Fortunately, translation or migration between two programming languages has become much easier
thanks to advances in artificial intelligence in software development, led by GitHub Copilot. Here’s how
it works.
Preparation
Before you can start translating, you need to define the target technology and the target architecture,
because even with GitHub Copilot, the destination of the journey must be determined and the path
well planned.
It is also advisable to gain a basic understanding of the source application to avoid migrating blindly.
The GitHub Copilot Chat with the so-called @workspace agent can already be very helpful for this.
It’s an agent which automatically includes relevant files to the context processed by GitHub Copilot.
This way, you benefit from explanations and a better understanding of a larger number of files.
is usually defined in English, and to make the whole thing consistent, the following screenshots were
created with English texts (Note: This article was first published in german, hence the german exam-
ple). The target stack can also be initialized with GitHub Copilot Chat and the slash command /new.
The actual migration happens directly in the IDE, executed by the developers and is very simple:
2. Within the GitHub Copilot chat window, you request the translation: “Translate this file into
Repeat this process for all files in the source system to successfully complete the migration. IOf course,
it’s often not quite that simple and there are a few things to consider, which I will discuss in more
detail below.
target file GitHub Copilot helps with about 80 to 90% of the initial translation, but especially in the
nicer way to inject dependencies into the classes. In this case, use the chat to improve the target code:
To avoid having to perform this refinement with each new translation, you can refine the translation
Like that, you will get increasingly better translations from GitHub Copilot from the initial prompt
over the course of the migration. Quick tip: With “Up Arrow,” you can bring up previous prompts for
If there are conceptual differences between programming languages, some more workmight be
necessary. For instance, If you translate from a typeless JavaScript to Java,, you need to create a data
class in Java for data structures that are defined inline in JS. You can also use GitHub Copilot Chat for
this, especially to save a lot of typing work for larger data classes:
in between to avoid context switching and being overwhelmed by too many changes and errors at once.
Since a program often consists of a network of interdependent files, it is recommended to start from the
bottom up, i.e., with files that have few or no dependencies, and then work your way “upwards.” GitHub
Copilot can also translate multiple files at once. In this case, however, refinement is more difficult, and
Tests
Are there unit tests in the source? Great! These can also be translated with GitHub Copilot.
Are there none? No problem. With the /test slash command from GitHub Copilot Chat, the problem is
quickly solved:
upon. Technology-agnostic E2E or black box tests can also be an important addition to verify the
general behavior of the application in both the old and new code and to ensure the core functionality
on both sides.
That's it
With this approach, you can migrate applications between technologies faster than ever before using
GitHub Copilot Chat. The code suggested by GitHub Copilot may not always be perfect at first, but
with a little work and the right prompts on the target files , you can quickly make significant progress.
GitHub Copilot Chat not only helps you better understand the source code but also saves you a lot of
That in turn reduces cognitive load during the migration, allowing you to focus on the important parts
of the project, such as ensuring the actual use cases and functionality of the application as well as the
Daniel Meixner
GitHub Copilot is a development tool—so it makes sense that the AI assistant focuses primarily on
answers related to development. For example, if you ask GitHub Copilot for a buying recommendation
for a specific product, the assistant will reply that it cannot answer that question.
However, this isn't because GitHub Copilot can't also utilize general knowledge from domains outside
of software development. You can use this knowledge, for example, to generate meaningful test data
that technically fits an application and requires knowledge from a specific domain.
If you are programming a web shop, for example, you need test data to display the products. Of
course, you can compile the test data from various sources. Often, this approach also yields useful
data. Typically, however, this method is associated with some effort and is time-consuming. With
process it sensibly. In this example, you create a file named testdata.json and request test data for your
application inline in this file, for example with the Ctrl + I keyboard shortcut. In the following, we
As you can see from the output, it is already quite realistic. GitHub Copilot seems to have very good
knowledge of this area. The descriptions are genuine and also suitable for testing. This is much better
than using Lorem Ipsum as meaningless filler text. By using multiple language variants, the application
can also be developed in multiple languages. This allows you to start programming very quickly without
pose you are working on a medical application and need test data for patients. GitHub Copilot can
help you create fictitious patient data that you can use in your application:
Also, note how GitHub Copilot correctly interpreted "dob" as Date of Birth automatically. If you want
to deliver the data, you can instruct GitHub Copilot to create a web server. This allows you to query the
George Kosmidis
Software development has dramatically evolved in recent times, with technological advances and
changing market needs shifting from traditional, manual coding to a more agile and innovative
approach. This change has been fueled by the integration of artificial intelligence (AI) and machine
learning (ML), revolutionizing both developer workflows and outcomes. GitHub Copilot exemplifies
this shift, offering AI-powered assistance in code writing, reviewing, and optimizing, thus fostering
GitHub Copilot, developed by GitHub, OpenAI and Microsoft, is a pioneering AI code completion tool
that significantly enhances the coding experience. It provides intelligent, context-aware suggestions
from an extensive coding database. It also greatly speeds up the coding process while also improving
accuracy and reducing errors, proving invaluable in business contexts where time is crucial. In addition
to these features, GitHub Copilot includes an interactive feature known as GitHub Copilot Chat. This
allows developers to ask coding-related questions and receive answers directly within supported
Integrated Development Environments (IDEs) like Visual Studio Code. By facilitating this direct
dialogue, Copilot Chat further enriches the coding environment, allowing for quicker problem-solving
and knowledge acquisition. The tool also encourages the exploration of new coding methodologies,
leading to innovative solutions and freeing up more time for creative and strategic thinking. As such,
GitHub Copilot is more than just a coding tool; it's an essential asset for developers, enhancing both
In this evolving landscape, Slalom has been an early adopter of GitHub Copilot, gaining valuable
experience with the tool. The following section will explore their insights and discuss the impact of
Copilot on their development practices. Slalom's experience highlights Copilot's role as more than just
a coding aid, but as a crucial asset in enhancing productivity and the quality of development work.
leverage Azure AI services to create an advanced, Azure Native healthcare analytics platform. The goal
was to integrate various Azure AI capabilities, including Azure Machine Learning, Azure Cognitive
Services, and Azure Bot Service, to enhance patient care and operational efficiency.
The Challenge
The project's ambition lay in seamlessly integrating native features of Azure AI services with Azure ML
models to be deployed as containers or directly consumed by the AI services. This integration presented
a multifaceted challenge: it demanded profound expertise to fully leverage Azure's extensive capabilities,
while simultaneously necessitating efficient cost management to maximize output. Orchestrating this
balance – especially under stringent timelines – posed a significant test of Slalom’s technical acumen and
a difference:
1. Accelerating Development
While building the core analytics engine using Azure Machine Learning, the team utilized GitHub
Copilot to suggest optimized code patterns and algorithms. This not only accelerated development
but also ensured that the solutions were robust and efficient.
2. Streamlining Integration
For the integration of Azure Cognitive Services, particularly in customizing AI models for natural
language processing, GitHub Copilot offered real-time coding assistance. It provided code snippets
In developing a patient interaction bot with Azure Bot Service, Copilot's suggestions helped the
team navigate through complex conversation flows, integrating them seamlessly with the Azure
backend.
A deeper dive
To better understand the impact of GitHub Copilot in this project, let's delve into a specific example.
One of the key efforts was integrating Azure Cognitive Services for natural language processing within
an Azure function. GitHub Copilot played a crucial role here, not only in speeding up the coding
process but also ensuring that the code adhered to best practices. The following Python snippet
demonstrates how Copilot guided the development team in implementing sentiment analysis using
In the above snippet, GitHub Copilot's contribution is evident in several aspects. It suggested using
AzureKeyCredential for secure API key management, a best practice in Azure application development.
Additionally, the structure and implementation of the sentiment analysis function were streamlined
using Copilot’s suggestions, from choosing the right methods to process natural language to enhan-
cing the analysis with key phrase extraction. This example highlights how Copilot not only accelerates
coding but also enriches it with advanced features and best practices, proving invaluable in complex
impact of GitHub Copilot in the realm of software development. Conducted across two distinct
locations – London and Denver – with a total of four development pods, this study offered a unique
Each pod, starting with identical code bases and project backlogs, embarked on a sprint with a crucial
variable: half of the teams utilized GitHub Copilot, while the other half proceeded without this
AI-driven tool. This approach provided a candid examination of how GitHub Copilot influences
development, especially as all developers were relatively new to both the codebase and Copilot itself.
The results were nothing short of remarkable. Less experienced engineers using GitHub Copilot saw
their productivity skyrocket by 88%. This statistic alone speaks volumes about Copilot's ability to level
the playing field, offering less seasoned programmers a significant boost in efficiency and confidence.
suggestions, coupled with on-point code examples and grammar corrections, made the documenta-
tion process not just faster but also more intuitive. Developers could focus more on the creative
aspects of coding rather than getting bogged down by the intricacies of documentation.
One of the most striking outcomes was that teams using Copilot observed up to a 50% increase in
code production speed. This efficiency gain is a game-changer in a field where time is often the most
critical resource. When it came to repetitive tasks, Copilot's impact was even more pronounced, with a
staggering 96% improvement in speed, underscoring its ability to automate and optimize the more
Lastly, the 77% decrease in time spent searching for information or solutions highlights another key
benefit of GitHub Copilot: its role as an on-demand knowledge repository. By providing instant access
to information and coding insights, Copilot significantly reduces the time developers spend in the
Slalom’s internal assessment unequivocally demonstrates that GitHub Copilot is not just a tool but a
paradigm shift in software development. Its impact on productivity, learning curve, documentation
quality, and overall coding efficiency marks a significant leap forward, especially for teams striving to
stay agile and innovative in the fast-paced world of technology. As we continue to explore and
embrace the capabilities of AI-assisted tools like GitHub Copilot, the future of software development
Julia Kordick
“Hey Julia, can you show the technical contacts from the customer how to implement this on Azure?“
„Hi Julia, do you know if what the customer has come up with will work?“
„Hi Julia, can you do a demo on a technical topic for the customer?“
I receive requests like these almost every day. Proofs of concept, explaining and demonstrating technical
contexts, and demos dominate my workday. After some time, I had created a collection of various
repositories that I can now use as a basis for different scenarios. In practice, every customer’s topic is
different – both from technical aspects and in terms of the specific use case. GitHub Copilot helps me to
both adjust existing code and deployments and to quickly and effectively create new ones targeted at
specific audiences.
I have never worked professionally with .NET, my pro-code skills from other languages combined with
the superpower of GitHub Copilot are completely sufficient to create runnable code in almost any
language – and then deploy it quickly and easily via Azure CLI, which I want to focus on in this example.
Here's the scenario: The customer has a monolithic Node.js application that is not containerized and
requires a (relational) database in the background. Therefore, we want to provision an Azure App Service
and an Azure SQL database – the simplest way is through the Azure CLI.
then start setting up some parameters for my deployment. After I have defined the first parameters,
GitHub Copilot knows my naming scheme and makes further suitable suggestions, which I can almost all
simply accept.
Then, using the Azure CLI, I begin to provision the resources and GitHub Copilot makes suggestions
Step by step, GitHub Copilot suggests the necessary descriptive steps, including comments, to create
an Azure App Service and an Azure SQL database. I just keep pressing Enter to receive a new
suggestion from GitHub Copilot and Tab to accept it completely. For particularly important or security-
relevant elements, like configuring firewall rules, I choose to not accept it completely but word by word
using Command & Tab to review the suggestion from element to element carefully.
am. Afterward, I start the shell script I just created and can see the result a few minutes later both as an
Despite my advanced knowledge of Azure, I naturally don't know every command of the Azure CLI by
heart. Therefore, it often happens that GitHub Copilot makes suggestions that I have a rough idea of
what will happen, but I want to know exactly.
That's where GitHub Copilot Chat helps me. I highlight the part in the file on the right side that I want
explained and ask about it in the chat window on the left side.
Thomas Pentenrieder
GitHub Copilot can generate large parts of program logic from comments or prompts as needed.
However, from my perspective, the tool provides the greatest benefit to developers when it simplifies
Especially when methods have already been fully implemented, GitHub Copilot can generate suitable
unit tests and corresponding test data for various cases with very high accuracy from the existing
context. This allows you not only to fundamentally review large parts of the program logic in a very
short time but also to consider edge cases that you might not have thought of on your own.
In the following example, we use GitHub Copilot to extensively test date-specific helper methods. This
is particularly critical in browsers, as the region and time zone depend on the users and are not under
The method to be tested, daysAsArray, returns all visible days of a calendar, for example, only week-
days between a start and end date formatted according to the ISO standard. By selecting the desired
method and calling the /tests command in the GitHub Copilot Chat, you receive seven different test
cases within seconds. These are automatically added to the already existing test file, without you
Copilot having different expectations for the results than you, and accordingly, it may formulate
Jannik Reinhard
Microsoft Intune is a unified endpoint management and security platform that enables companies to
manage and protect their mobile devices such as smartphones, desktops, but also devices like HoloLens
and many others. A key component of Intune are proactive remediation scripts. These are used to check
devices for issues using a detection script, identify these issues, and depending on the return value,
Scripts are mostly written in PowerShell and build upon each other. Here, GitHub Copilot is a big help. It
only needs to be described that it is a remediation script and which error the script should check for.
Every day, new problems are reported by users or noticed through the logs. The goal is to move in a
proactive direction and develop scripts for these errors that automatically detect and correct problems
when they recur or occur in users. This not only reduces the effort in the service desk but also the num-
ber of tickets. Moreover, this approach offers users a better experience in their daily work.
Since the scripts ideally need to be created promptly and quickly, GitHub Copilot is a huge help here,
saving a lot of time. Not every command, function, and line of code needs to be painstakingly resear-
ched. In many cases, it is enough to create a detailed description of what I want to achieve with the
script. After that, GitHub Copilot creates the script for me.
All that needs to be done now is to press “Tab” a few times. GitHub Copilot then generates the script
for me. I can focus on what the command should execute to read the event logs, or how to filter for
The whole thing should now be adjusted to filter only for problems with the Teams client. To do this,
that:
Now that the detection script is ready, a remediation script is needed that clears the Teams cache in
such a case. This script is also created by GitHub Copilot. The procedure is the same. I'll write a
Intune proactive remediation script to remediate team crashes with cleaning the team cache.
Again, it recognizes what is to be achieved and all I have to do is to confirm. Unfortunately, the result
is still not satisfactory. I got the same result as with the detection script and need to rework it.
here. Now I can also simply “tab through” and have a perfect script.
Holger Sirtl
Programming is my passion. Since my childhood, I've been fascinated by the world of codes and
algorithms. It amazes me how I can solve complex problems and develop innovative solutions with just
a few lines of code. As a Cloud Solution Architect at Microsoft, it's my job to bring this passion to
In my customer projects, I often face the challenge of creating small code examples, whether to de-
monstrate new features or to illustrate best practices. However, I face two major challenges: Firstly, my
work as a Solution Architect with frequently changing customer scenarios often leaves me little time to
code myself. Secondly, my projects require that I develop in many different programming languages.
This means that I must be proficient not in one, but in several languages.
How do I iterate over an array in Python? How do I create a tree structure in C# or Java? How do I
output the content of an environment variable in PowerShell? How do I do it in Bash under Linux?
There are many other examples, and it's nearly impossible to memorize every programming construct
in every desired programming language. This is where GitHub Copilot comes into play. The tool allows
me to formulate the desired code example via comments. This means that I don’t have to keep every
detail of the programming language in mind but can focus on the logic and the algorithm instead.
Using GitHub Copilot, it's very easy to create small demos and code examples. Basically, I just need to
know how to write comments in the desired language. I then simply write the desired algorithm as a
comment, in German or English, depending on the customer’s preference. GitHub Copilot then
Here’s a cheat sheet for comments in the most important scripting and programming languages for me:
C# // comment /* comment */
Of course, this approach has its limits. To create larger software solutions, it is essential to know the
structure and constructs of the desired programming language. But especially for smaller projects, quick
solutions, and additions to existing software, GitHub Copilot is a huge help. GitHub Copilot saves time
and facilitates the work since I don't have to keep every detail of the programming language in mind.
Overall, I am excited about the possibilities that GitHub Copilot offers. It is a powerful tool that helps me
I recommend everyone try out the tool and see for themselves its efficiency and simplicity. At the end of
the day, programming is not just about writing code, but about solving problems and implementing
Robin-Manuel Thiel
Similar to ChatGPT, GitHub Copilot offers a text interface through which one can communicate with the AI
in natural language via so-called prompts. Additionally, single, or multiple relevant source code files or
sections can be referenced to answer the question. As with most natural language instructions to an AI, the
structure of the entered information (known as a prompt) plays an important role in GitHub Copilot Chat as
well. The discipline of optimally preparing a prompt for the AI is known as prompt engineering. Repetitive
tasks often follow a certain pattern. The clearer we communicate the instructions for processing these tasks
via the prompt to the AI, the higher our chances of success.
Some aspects that help us structure a prompt so that it can be better processed and more accurately
• Include examples.
• Structure prompts with separators and separate requests for context information.
Happy = 'happy',
Excited = 'excited',
Content = 'content',
Joyful = 'joyful',
Optimistic = 'optimistic',
Amused = 'amused',
Pleased = 'pleased',
Relieved = 'relieved',
Grateful = 'grateful',
Inspired = 'inspired',
Proud = 'proud',
Playful = 'playful',
Satisfied = 'satisfied',
Hopeful = 'hopeful',
Serene = 'serene',
Jubilant = 'jubilant',
Ecstatic = 'ecstatic',
Elated = 'elated',
Blissful = 'blissful',
Radiant = 'radiant',
Merry = 'merry',
Enthusiastic = 'enthusiastic',
Cheerful = 'cheerful',
Whimsical = 'whimsical',
Eager = 'eager'
What would have been a tedious task years ago can now be automated in seconds with GitHub
Copilot Chat. So, I highlighted the entire Enum code and initiated GitHub Copilot Chat with the
The table name should be the enum value itself. The table consists of the
Here is the SQL script that creates a new table for each value of the
enum.
Text VARCHAR(255),
Score INT
);
I received the SQL command that created a table according to my specifications from a single Enum
value. However, the table name that began with a lowercase letter (which did not comply with our
At this point, I could have refined the initial prompt by specifying the capitalization of the table name.
Additionally, I could have instructed in the text to create only one single script with an SQL command
Refining the prompts in several iterations would probably have taken as much time as manually writing
the SQL script with the information already received. A much more effective method to steer the result
in the desired direction with prompt engineering is the addition of concrete examples. Therefore, I
used the insights from the first response to construct a second prompt enriched with examples:
The table name should be the enum value itself. The table consists of the
---
Example:
```
Text VARCHAR(255),
Score INT
);
Text VARCHAR(255),
Score INT
);
```
The result was impressive and perfectly complemented the example script from the prompt with the
remaining values of the Enum. Even the capitalization of the table name, which I did not explicitly
mention but only listed in the example, was considered by GitHub Copilot this time. With a few tricks,
such as adding an example from the first response and clearly separating instruction and example with
dashes, the prompt could be directed in the right direction without rephrasing.
Conclusion
The true strength of GitHub Copilot Chat lies in its ability to understand the existing code. When
converting Enums into SQL commands, GitHub Copilot must understand the context of the Enums and
generate code that is not only syntactically correct but also semantically meaningful. For repetitive
changer for developers, especially for tasks that require an understanding of the existing code and
need to be adapted to another technology. Here, GitHub Copilot Chat plays to its strengths.
Interacting with an AI-powered, chat-based pair programmer not only saves time but also minimizes
human errors and boosts the productivity of developers, allowing them to focus on the interesting,
challenging, and important tasks of software development. We'll leave the boring part to AI from now on.
Christian Wenz
Product demos and conference presentations of GitHub Copilot focus on how easy it is to generate
working code. The selected test scenarios are similar and well-prepared. In practice, working with
GitHub Copilot isn't always as straightforward, as trivial tasks and complex requirements alternate.
In cases where it is applicable, code generation with GitHub Copilot doesn't always work as smoothly
as shown under ideal conditions. The saying “garbage in, garbage out” applies here—or to put it
positively: The quality of the prompt greatly influences the quality of the generated code. For this
reason, the specialized discipline of “Prompt Engineering” has been established—a corresponding
Wikipedia entry was created back in October 2021. Optimized prompts lead to better results. With
GitHub Copilot, this involves both direct input prompts and the comments in the code that GitHub
But as always: “It depends”; there is no one-size-fits-all solution for every application. However, adher-
expect. For example, information about the target system, desired functionality, UX, and much more
The more precise the requirements, the more accurately the results can match the requirements. This is
all the truer for a software tool like GitHub Copilot. Specify exactly what you want and omit irrelevant
The phrasing should also be clear and actionable, that is, you should avoid negations and provide clear
What should the code do? A canonical example would be an application for a to-do list, so start the
prompt with exactly that statement. This allows the system to consider existing solutions in this area
and to define a concept for the application to be created. Then follow with a description of the
functionalities to be implemented.
first draft already correspond to the desired and final result. There is always room for improvement,
either through GitHub Copilot or through your own intervention in the code. For this reason, it makes
sense to specify the individual required tasks in the code separately. Not all at once, but in successive
steps. For example, when creating an API, first generate the data model and then implement the
endpoints.
Of course, it's also possible to do everything at once, for example by providing the context (see point
2) and then a bulleted list of relevant features. In this case, however, interventions can only be made
once the entire code has been generated. With an iterative approach, corrections can be made earlier.
helpful to specify the output of a functionality with examples. This also sets the data structure as it
and an existing code style can be considered by GitHub Copilot. In the end, the code will look (almost)
spare a person who always said “please” and “thank you” when communicating with an AI system.
However, there are apparently indications that polite interaction with a computer system both
improves one's own mood and personal handling. And, let's be honest—properly applied, we save the
extra typing effort for politeness phrases through the quick results generated, right?
Suad Wolgram
Tip 11:
A crucial factor for the effective use of GitHub Copilot is the use of meaningful function names. There-
fore, I want to show you how you can help GitHub Copilot generate more accurate code suggestions
Let's consider the scenario with the following code example. In the function fetch(), we want to retrieve
In this context, it becomes clear that GitHub Copilot does not understand what goal we aim to achieve
with the fetch() method. Therefore, we cannot receive suitable suggestions at this point. One solution
is to replace fetch() with a meaningful function name that precisely describes what the method is
supposed to do. Once the context is clearer, GitHub Copilot immediately provides suggestions for
As a second example, let's assume we want to calculate the number of inhabitants of a planet in the Star
As before, we choose a meaningful method name and specify exactly what we want to return.
As soon as we begin to insert the logic, GitHub Copilot recognizes the context due to the chosen
method name and appropriate variable names and suggests the corresponding implementation.
We can also see that GitHub Copilot uses the variable correctly due to the clear context.
Joël Zimmerli
Tip 12:
In test-driven development (TDD), writing unit tests is one of the most important but often time-consu-
ming tasks. In this article, I will show how I use GitHub Copilot to write my tests efficiently and compre-
As a specific example, I use a Dotnet application where real estate properties with their sale prices are
stored. The search function allows filtering by price range. To implement this filter, I wrote a factory that
creates a comparison function based on the minimum and maximum prices. An excerpt of this function is
return expressionBuilder;
}
To use GitHub Copilot for automatic test generation, I start by creating the test name. This name
describes which object is being tested, which function is called, and what result is expected. This naming
structure is widely used in the world of testing. This allows GitHub Copilot to automatically generate the
// Act
var expression = query.ToExpression();
var result = expression.Invoke(house);
// Assert
result.Should().BeTrue();
}
This test should then be performed with different property prices. To do this, the test can be paramete-
[Theory]
public void HouseQueryToExpression_ShouldEvaluateCorrectly(int?
upperLimit, int? lowerLimit, int housePrice, bool expected){
// Arrange
var query = new HouseQuery()
{
UpperPriceLimit = upperLimit,
LowerPriceLimit = lowerLimit
};
var house = new HouseDocument()
{
Id = "house",
Name = "house",
Price = housePrice
};
// Act
var expression = query.ToExpression();
var result = expression.Invoke(house);
// Assert
result.Should().Be(expected);
}
[Theory]
[InlineData(100, 0, 50, true)]
public void HouseQueryToExpression_ShouldEvaluateCorrectly(int?
upperLimit, int? lowerLimit, int housePrice, bool expected){
By generating the parameters multiple times, a comprehensive list of possibilities is obtained, as shown
in the next illustration. However, it is advisable to carefully review and reconsider this list.
[Theory]
[InlineData(100, 0, 50, true)]
[InlineData(100, 0, 99, true)]
[InlineData(100, 0, 1, true)]
[InlineData(100, 0, 150, false)]
[InlineData(100, 50, 150, false)]
[InlineData(100, 150, 200, false)]
[InlineData(100, 0, 0, false)]
[InlineData(100, 100, 100, false)]
[InlineData(100, 100, 0, false)]
[InlineData(null, null, 0, true)]
[InlineData(100, null, 0, true)]
[InlineData(100, null, 101, false)]
[InlineData(null, 100, 101, true)]
[InlineData(null, 100, 99, false)]
public void HouseQueryToExpression_ShouldEvaluateCorrectly(int?
upperLimit, int? lowerLimit, int housePrice, bool expected){
With these steps, GitHub Copilot can assist you in efficiently creating tests in various scenarios.
Tobias Deekens
Last February, GitHub announced its launch of GitHub Copilot for Business. This announcement immediate-
ly caught our attention and interest, and engineers across the organization shared their desire to use this
product. After aligning internally on an adoption strategy, we decided to evaluate GitHub Copilot for three
months to learn how it could help us be more productive. This article describes our path to evaluating and
Here at commercetools, we use various programming languages and tools to build our different pro-
ducts — from Scala to TypeScript and PHP to Go and Rust. We prioritize making educated choices about
technology decisions so we can select tools that enhance our productivity. Furthermore, as our company
grows, we want to retain our collaborative mindset, which is ingrained into our company values. We see a
huge impact toward collaboration in software engineering by the breadth of tools built with generative
Copilot for three months instead of just adopting it for all engineers. That's because, as a company
policy, commercetools believes in a pragmatic approach to the adoption of AI. AI is a widely supported
initiative, but its usage and determination is bottom-up. We want our teams to evaluate and decide
how AI can enable productivity and functionality. In this case, the engineering department investigated
use and be affected by the tool in order to get their pragmatic opinions.
Moreover, the incoming flux of new and enhanced products backed by generative AI increases the
importance of thoroughly evaluating each tool’s impact individually, as well as how they can be used
together. For instance, is it beneficial to use Replit Ghostwriter, Codeium, CodeComplete, and GitHub
Copilot in tandem, or should we consider complementing one of these with a different tool such as
Mintlify or Wrap? This is a question one can only answer after exploring such tools in practice and not
To perform an informed adoption, we wanted to clearly understand the expected and actual impact of
GitHub Copilot across our engineering organization. This included Frontend Engineers, Backend
Engineers, Site Reliability Engineers, Test Automation Engineers and those working on documentation.
Three months, spanning two quarters, felt ideal. Throughout this time, we hoped to get a comprehen-
sive snapshot of the engineering cycle, including an end of quarter where teams often roll out new
After having settled on a duration, we needed a sample size. Evaluating with only five to ten out of 150
engineers could easily yield skewed results. As a result, we wanted to aim for 30 to 35 engineers to join
the team of evaluators, in turn, a representation of 20 to 25%. Lastly, we wanted to involve as many
disciplines as possible to form a heterogeneous group using different tools and languages.
We were now ready to share our plans through an internal blog post. We covered the process and
linked a Google form for those interested in signing up. After a week, 34 people across the organiza-
tion took part. This roughly matched our desired sample size, and fortunately, we didn’t need to
retroactively adjust our pool of evaluators. Everybody was then added to an email list and Slack channel
to share updates. To grant access, all members were added to a dedicated team on GitHub, giving
With everything set up, we stepped back and allowed everybody to proceed with their work, incorpo-
rating GitHub Copilot into their workflow. Only after a week did we briefly check in to ensure that
coming weeks, people shared their impressions and code samples in Slack or on Pull Requests while
Throughout the duration of our evaluation, we remained in touch with GitHub in the background. The
evaluators shared interesting statistics with us, such as the average code acceptance rate. Additionally,
we obtained GitHub Copilot Chat for the final two weeks of our evaluation, allowing us to peek into
the future of GitHub Copilot as a more collaborative tool. We are excited to see where the future of
GitHub Copilot goes and where its different offerings take us.
hoped our suggestions would be useful across programming languages and not get in people’s way.
Throughout our evaluation, we were not disappointed in any of these expectations, but we also
discovered room for improvement and noticed that the quality of suggestions varied significantly
In more detail, our main survey turned out to be 15 questions long and focused around three key
areas:
Based on these three key areas, we drilled deeper with questions such as:
1. How often did you use GitHub Copilot during our trial?
2. Did your usage of GitHub Copilot change during the three months?
3. How often did you have to amend suggestions made by GitHub Copilot?
5. Should we evaluate other tools using generative AI this year to improve our productivity?
Having asked all these questions, these were the main takeaways:
• 57% used GitHub Copilot every day; everybody else used it every other day.
“At times GitHub Copilot seems asleep with many VS Code windows open.
Then it yells 50 lines of code at you.”
AN EVALUATOR BEING HIT BY A RAPID SUGGESTION BURST
As we evaluated GitHub Copilot for a longer period, we also saw areas for improvement:
Those are a lot of numbers, but they certainly helped us understand the usefulness of GitHub Copilot
across our organization and helped us make the decision to adopt the tool. Once enabled, GitHub
Copilot was used continuously, and its use even increased. Suggestions were often accepted and of
good quality. Users were able to embed it easily into their existing work environments and experienced
significant productivity gains — all of which means that we will continue to roll it out across our orga-
github-copilot-for-3-months. Thanks to Tobias and commercetools for allowing us to republish in this eBook.
Dennis Gassen
This article does not offer a comprehensive view of how accessible software can or should be developed –
the scope here is too limited for that. Instead, I want to show that GitHub Copilot can already consider and
comply with some fundamental standards that make software-based products more accessible and usable
Approximately 1.3 billion people worldwide live with a disability, accounting for about 16 percent of the
global population. A large portion of these individuals reside in low-income countries with poor health
care and education systems and are poorer than many people without disabilities. For this group, access
The Web Content Accessibility Guidelines (WCAG) are the international standard for accessible web
offerings. In the European Union, they have been mandatory for public institutions since September 2019
for new websites, since September 23, 2020, for existing websites, and since June 23, 2021, for mobile
applications. The World Wide Web Consortium (W3C) first published the WCAG as Version 1.0 in 1999.
Since December 2008, Version 2.0 has been recognized as an ISO standard. Currently, Version 2.2 is
recommended by the W3C. Although the W3C recommendations do not have general legal validity, they
nevertheless have high binding force for the development of accessible websites and applications.
When we now use GitHub Copilot Chat and simply ask how GitHub Copilot can support us in developing
tips.” Using Prompt Engineering, however, we have the opportunity to give GitHub Copilot more
the most common accessibility standards and guidelines. When you answer
and webaim.org. Please also provide links and references in your ans-
wers whenever possible. When you suggest code, use semantic HTML and
follow the ARIA Authoring Practices Guide and related design patterns.
• Definition of the role GitHub Copilot has and what feedback we expect.
We can also ask GitHub Copilot for specific examples where accessibility standards are not being met:
Of course, the examples shown here are very simple. However, as an illustration, they very effectively
demonstrate the possibilities GitHub Copilot offers to adhere to Accessibility Standards, making your
Prompt: What are best practices to incorporate accessibility testing in the whole application lifecycle?
hought. This includes during the design phase, where color contrast,
with a keyboard only, and testing with real users with disabilities, is
crucial.
of your code review process. This can help catch potential issues befo-
5. Training and Awareness: Ensure that all members of your team unders-
This can help catch any new issues that may have been introduced.
ject.
For more detailed information, you can refer to the WCAG guideli-
nes and WebAIM, which provides a wide range of resources to help you
automated and manual testing methods. Here are some steps you can follow:
identify issues like missing alt text, incorrect semantic HTML, and
rience of a screen reader user, you should test your application with a
ding NVDA and JAWS for Windows, VoiceOver for macOS and iOS, and Talk-
Back for Android. As you navigate your application with the screen
ble (can be focused and activated using the keyboard) and that the tab
order is logical.
the content and structure of the webpage. Ensure that you're using the
correct HTML elements for their intended purpose and that you're using
5. Descriptive Text: Ensure that all images have alt text, that form
inputs have associated labels, and that links and buttons have descrip-
tive text.
substitute for manual testing with a screen reader. It's also a good
For more detailed information, you can refer to the WCAG guidelines
Prompt: What are best practices for creating accessible tables in HTML?
1. Use <th> for Headers: Use the <th> element for table headers, and
the <td> element for table data. This helps screen readers understand
2. Use scope Attribute: The scope attribute can be used on <th> elements
4. Use <thead>, <tbody>, and <tfoot>: These elements can be used to group
the header, body, and footer of the table. This can make the table
6. Ensure High Contrast: Ensure that the text and background colors of
For more detailed information, you can refer to the WCAG guidelines
and WebAIM, which provides a wide range of resources to help you make
Copilot Chat regarding accessibility. Of course, no one should expect perfect results, as it is “only” a
“Co-Pilot.” However, you can use GitHub Copilot Chat very effectively to expand your own knowledge
and understanding of accessibility. Also, always remember that you can ask GitHub Copilot further
questions about the answers or ask for additional references and examples. It is always the developers'
Tip 15:
Using natural language to produce code has been the software industry's dream for a long time, dating
back to the 1950s with the introduction of COBOL. With the usage of large language models, we are
coming closer and closer to this vision. GitHub Copilot leverages this capability to produce code.
When starting out with GitHub Copilot and GitHub Copilot Chat we used it to produce inline code
from comments and ask questions about code, languages, procedures or frameworks in Copilot Chat.
However, we can also enhance the context by including additional information to our prompts. One idea
here is to tell Copilot about your intention and give Copilot specifications about what you want to achieve.
Workshops. This website should have a couple of smaller tools that you
The first component that I want to build is a timer for a coffee break.
min, 1 hour)
- Upon clicking "Timer Start" the timer should start and count down.
In this case we are telling Copilot what we want to do (“Build a website for trainers to be used during IT
Workshops”) and the technology that we are using (“This website is being built in React with JavaScript”).
After that we give Copilot our requirements and we end up with a fully functional component in React
However, there might be one feature missing in the component: The toggling of the button to be a stop
Also change the JavaScript code to stop the timer once the "timer Stop"
Another powerful way to utilize GitHub Copilot is by describing the desired functionality directly within
the comments of your code. This approach allows you to embed detailed instructions within the
codebase itself, making it easier for Copilot to generate the relevant code snippets.
Here is an example:
When GitHub Copilot reads these comments, it can generate a complete implementation that matches
Beyond code generation, GitHub Copilot can also be used to generate documentation comments
and provide explanations on how to use libraries. This can be particularly helpful for understanding
complex code or unfamiliar libraries. In the example below, we trigger the copilot to describe the
function by starting the description and letting the copilot get the job done.
By leveraging comments, you can guide Copilot to not only generate code but also create comprehen-
sive documentation and explanations. This enhances code readability, maintainability, and helps in
Maxim Salnikov
GitHub Copilot Chat is an incredibly powerful and useful feature that allows you to chat with or about
your code. Even though it’s 100% natural language-friendly (i.e., you can send your messages without
using any specific syntax), leveraging certain special chat capabilities can unlock new AI-assisted
These powerful features, which you can use by applying special syntax, include chat participants, slash
commands, and context variables. Note that the described features are available in VS Code and might
not be fully supported in other IDEs where GitHub Copilot Chat is available.
chat syntax—by prefixing @ to the participant name. The currently available chat participants are:
• @workspace: Knows everything about the code in your currently open workspace.
This is the chat participant with whom you will probably communicate with most frequently.
• @vscode: Knows about the VS Code editor, its commands, and features.
Example: Let’s get information about the backend part of the project we’ve just been assigned to by
asking the @workspace chat participant right after we open the project folder in VS Code.
In this particular case, you don’t even need to have files open in your editor. Compare this with the
code to be considered for the chat response. However, this doesn't mean that all code will be used and
sent as part of the prompt. The GitHub Copilot Chat extension in VS Code does its best to determine
relevant files and parts of these files using local knowledge and intelligence first. You can check which
files and code lines were used for the prompt by expanding the “Used references” line:
Productivity hint: Use Ctrl-Enter (Cmd-Enter) instead of just Enter after typing your message, and the @
workspace string will be inserted into your message automatically before sending.
workspace) is overkill. You might want to point to specific files or even parts of the files in your mes-
sage. Chat variables can help! Use # to call one from this list:
• #codebase: All content of the open workspace. It’s similar to using @workspace and might be
useful when you chat with another agent (like @terminal) but still want to reference the full solution.
Example: Let’s get help on improving method names in a specific file (and we want to ensure that the
In the case of #file, use keyboard navigation again to pick one of the suggested files.
Call up the most frequently used actions quickly with slash commands
Chatting with your code using natural language is fun, but having the option to call up often-used
actions using handy shortcuts is even better. Compare typing the full message “Explain how selected
code works” versus typing “/”, then using keyboard arrows to pick “/explain” from the popup overlay.
Another benefit of using the predefined syntax for commands is the confidence that GitHub Copilot
understands our intent 100% correctly (natural language might have some ambiguity). There are a bunch
of slash commands available. You can use them in conjunction with referencing the chat participant to
• /help: Help on available slash commands, chat participants, chat variables, and more.
• /explain: Explain how the code works (or get help with terminal commands if you prepend
@terminal).
Productivity hint: Try GitHub Copilot Chat in inline mode instead of having the chat always open in the
side pane. Press Ctrl-I (Cmd-I) and type your message in the small overlay dialog that appears right
Summary
Use chat participants, chat variables, and slash commands to maintain full control over the
conversation context, ensure correct and consistent understanding of your intentions, and ultimately
These 16 tips from our experts are a great introduction to the fascinating possibilities of GitHub
Copilot - but the examples presented are just a small preview of how this innovative tool can
The best way to experience the full power of GitHub Copilot is to try out the AI pair programmer for
yourself. Integrating it into your workflow could make a big difference, whether it's speeding up
Of course, we want to hear about your experiences and tips for using GitHub Copilot. We invite you to
share your own insights and recommendations. Your valuable insights could find a place in the next
edition of our whitepaper and help other developers get the most out of GitHub Copilot. Feel free to
contact us at [email protected].
Innovation is at the heart of software development, and GitHub Copilot is undoubtedly a game-
changing tool. Take this opportunity to improve your coding experience and let's shape the future of
Additional resources
• GitHub Blog
views expressed in this document, including URL and other Internet website references, may change
without notice. You bear the risk of using it. This document does not provide you with any legal rights to
any intellectual property in any Microsoft product. You may copy and use this document for your internal,
reference purposes.