As I continue leveling up in my career as a developer, I am always looking for new ways to approach work. One tool I have learned to appreciate recently is GitHub Copilot. Now I’ve worked with Copilot for almost a year and recently began integrating their beta release of Copilot Chat into my daily workflow. As a result, this tool has begun to change the way I write software.
What is Copilot?
For those who have never heard of this tool before, GitHub Copilot is an AI developer tool. It provides contextualized code completions inline to help speed up the development process. As of writing this blog post, Copilot currently supports integrations with Visual Studio Code, Visual Studio, JetBrains IDEs, and Neovim.
Although it is hard to capture all the value Copilot can provide you, I have some favorite use cases. These include assistance with regular expressions, writing documentation over code snippets, defining unit tests, creating dictionaries over a known collection (e.g., a dictionary over U.S. state names to their state abbreviations), and prompting basic function definitions via a human-readable sentence in a comment.
As the development of GitHub Copilot’s successor Copilot X continues, GitHub has released a beta version of one of its new features to their current Copilot subscribers: Copilot Chat. (Currently, this beta is only available in Visual Studio and Visual Studio Code.) Copilot Chat provides the same functionalities as GitHub Copilot through an interactive chatbot that utilizes the Copilot X AI.
How I use Copilot in development.
With this new way of interacting with the Copilot AI, I find myself taking a new approach to development.
When I start on a new feature, my workflow can be resolved in a few steps. Begin gathering information needed before writing code, attempt to implement the new information, and test the code to see if it is working as expected. If not, repeat this process.
This loop works great for a junior developer because it allows for iterations over a feature until they can grasp all facets of the implementation. But this process can feel a bit sluggish as the number of loops needed to build a good initial implementation is proportional to how new the developer is to the technology they’re working with. This is where Copilot shines.
My New Workflow
After working more with GitHub Copilot and Copilot Chat, I’ve been finding that my daily workflow has adapted to prompting Copilot chat to build a basic version of the new feature. (Typically I try to provide it with as much context as needed for the technologies it will be using.) Then, I test the code to see if it is working as expected; if not, repeat. Next, I parse through the generated solution looking for any new section, and gather information necessary to understand the working solution. Then, with the new information, I begin iterating over the basic implementation and work towards aligning it with the desired feature.
Although both these approaches are viable, the second workflow has better risk management. This approach helps reduce the time spent researching and attempting to get an initial implementation built and optimizes for time spent on learning how the actual implementation works.
Copilot can handle scouring massive amounts of data for the basics needed to get a snippet of code functioning. That’s one of the great benefits of utilizing a large language model. Now the only job for the developer is to find the basics they are not familiar with in a working implementation. This frees more time for development. You can use that time to refactor the solution (which should almost always be done with generated code, unless the snippet is simplistic enough to feel comfortable with) to be better and easier to work with.
Getting the Most out of Copilot
GitHub Copilot is a powerful tool and we should treat it as such. It’s very easy for the sheer speed to blind you and to find yourself taking off running with its generated code. This can be detrimental to a junior developer’s growth as they will have very little or no understanding of what they are building. To make the most out of Copilot, remember to refactor and parse through the generated solution to find where there are knowledge gaps and work to make those gaps nonexistent.