Developers / Artificial Intelligence

GitHub Copilot: AI Tool for Salesforce Developers

By Igor Kudryk

Generative AI is here to change the way we work. With the release of ChatGPT, OpenAI caused a wave of new tools that are using LLMs (Large Language Models). The idea is simple – an AI system is trained on a large dataset. After the training, the user can provide some data for the input, and LLM will produce the most probable answer to the user’s input.

But so far, we haven’t seen many working tools that you can use in your day-to-day job. GitHub Copilot is one of the first tools seamlessly integrated into the workflow of developers.

What Is GitHub Copilot?

GitHub Copilot is an AI product for developers released by GitHub to use within VS Code or IntelliJ IDEA. The main promise of GitHub Copilot is smart auto-completion.

When I first discovered GitHub Copilot, I was blown away by its capabilities. The promises were lofty – 96% of users reported being faster with repetitive tasks, 88% reported being more productive, and 74% could focus on more satisfying work.

Standard Autocompletion

You probably know about VS Code’s built-in autocompletion – you press on a dot, and VS Code shows what you can access on this particular variable. 

However, VS Code doesn’t know anything about what you are actually trying to solve, what code you already have, and what functionality you are trying to develop. It is missing one thing – context awareness.

Context Awareness

Context awareness means that Copilot understands what you are actually writing. Copilot analyzes your whole class (and the classes you are using), sends them into LLM, and shows the most probable next piece of code. It can be just one character, a line, or even the whole method. 

For example, if you are typing in a method called “queryOpportunityById”, the Copilot can guess that you will need a SOQL query and suggest one – including fields that you will most likely need.

Code Generation From a Description

Another difference from standard autocompletion is that it can generate working methods from just one comment, and you don’t even need to type anything.

Smart Autocompletion

Basically, everything that we discussed before is autocompletion. It can also work on the line or even character level. In the example below, Copilot guesses which variable should be passed into the method and even adds a semicolon at the end.

How Was It Trained?

GitHub is a website that contains billions of lines of open-source code. So, if you need an AI model, you’d probably want to use GitHub to train it.

Even though it was trained on publicly available code in GitHub, it doesn’t mean that the code it produces is just copied and pasted from someone else’s repository. Instead, it calculates probability based on the code it saw and makes suggestions that most likely fit your typing.

What Languages Does It Support?

As Copilot was trained on GitHub repositories, it supports all the programming languages that have ever had a public repository on GitHub! That includes all languages for Salesforce development (Apex, Visualforce, LWC, and Aura). However, in my experience, it works best with Apex.

How to Install GitHub Copilot

GitHub Copilot is an extension for VS Code and IntelliJ Idea. If you have a license, you can simply download it as an extension and log in to your GitHub account.

What About Privacy?

Privacy is a big concern with most AI tools. GitHub Copilot can only make code suggestions if it has access to your code – and code in your organization may contain sensitive information. 

Luckily, you can uncheck a box, and it will ensure that your codebase is only used to generate code for you and not anywhere else.

Pricing

GitHub Copilot is currently priced at $10 per month for individuals and $19 per month for organizations. Using the more secure plan is recommended if you are working with sensitive information.

The Benefits of Using GitHub Copilot

As a developer, you solve business problems with code, not just typing. The latter is usually quite a draining exercise because you always forget function names or which arguments you have to pass into a method. You may not know all the documentation about certain classes either and will have to switch to another tab to look it up, and context switching makes the process of writing code quite exhausting sometimes.

GitHub Copilot eliminates 80% of your manual typing. You can’t just accept everything Copilot produces, and you probably do not want to. But it helps not to switch tabs every five minutes to find which parameter your function accepts. While it is not perfect, it is not intended to replace you as a developer.

Their website claims that 88% of the developers using GitHub Copilot feel more productive. Personally, I can confirm that. After six months of using it, I cannot return to writing code without it – that would be like writing code in a notepad.

GitHub Copilot X

Microsoft is working on GitHub Copilot X, which is the next version of GitHub Copilot. “X” stands for all the other features they are working on. There is currently no release date or known status, but here is what they want to bring in the future:

  • Automatic test generation
  • Chat directly in VS Code
  • Documentation on button click
  • AI-generated pull requests
  • AI CLI assistance

GitHub Copilot Labs

GitHub Copilot Labs is an experimental sandbox where the GitHub team tests experimental features. Currently, it has the following functionality:

  • Removing and adding debug statements
  • Removing and adding comments
  • Changing up your code in multiple methods
  • Explaining code

Since it is an alpha preview, it does not work well with Salesforce-related languages. However, it is worth installing to be on track with what might come next.

Final Thoughts

GitHub Copilot is a powerful tool that enhances developer productivity. It eliminates a lot of manual typing, reduces context switching, and has become an indispensable part of my development workflow. If you are looking for ways to make your day-to-day life easier, try GitHub Copilot now.

The Author

Igor Kudryk

Igor is the Founder of Cloud Prism where he teaches Salesforce development.

Leave a Reply