Github Copilot. How to improve your performance
Victor Karabedyants
MSDP in Software Engineering, CTO, MBA, Cloud Manager at Sitecore | AI Engineer | Azure Solutions Architect | Azure Administrator | Azure Security Engineer | Azure Developer | Azure Data Engineer and Devops| CKA
I'm committed to getting the very highest quality of experience, and that’s fantastic. So, how do I get this programming AI partner? There are a few steps I need to follow in order to leverage this tool.
Step One: I need a GitHub account. This part is pretty straightforward—GitHub offers free accounts, so I just need to sign up if I haven’t already.
Next, I’ll need to add a GitHub Copilot license. This license can come from my organization, or I can purchase it as an individual. There are different options available, like Copilot Business and Copilot Enterprise, each with its own price point. If I look into these options, I can see that they offer features like inline chat, prompt suggestions, and public code filters. It's important to note that with business and enterprise licenses, my code is never used for training the AI, though prompts might be.
GitHub's Trust Center provides detailed information on how they handle security and privacy, so I can check that out to understand exactly what’s happening with my data.
Once I have the license, the next step is to add the necessary extensions. There are actually two extensions I need to install: the base extension and the chat extension. One of the most common keystrokes I’ll be using is Control + I (or Command + I on a Mac), which brings up an interactive window to start interacting with GitHub Copilot.
GitHub Copilot supports several popular IDEs and code editors, including Visual Studio Code, Visual Studio (2022 and later), and a range of JetBrains IDEs like IntelliJ IDEA, PyCharm, and WebStorm. Additionally, Neovim users can integrate Copilot through community plugins, and it can also be added to Sublime Text and Atom with limited functionality. For the best experience, VS Code and JetBrains IDEs offer the most robust integration, providing real-time AI-driven code suggestions.
To install these extensions, I’ll go over to my code editor, Vs code, search for "GitHub Copilot," and install both the GitHub Copilot and GitHub Copilot Chat extensions. Once they’re installed, I just need to sign in to complete the process.
After signing in, I’m all set and ready to start using GitHub Copilot. Now, let's dive into how I can actually use it in my development environment.
When I open my code editor, I’ll notice a little GitHub Copilot icon at the bottom. It should show that the status is "ready." From here, I can open a GitHub Copilot chat, access various panels, and edit different settings to control the code completion interactions.
One thing I want to emphasize is that there are best practices when working with large language models like this. It's important to keep prompts short, simple, and specific. GitHub Copilot is my partner, not a replacement. It can help create functions, provide suggestions, refactor code, or set up a framework for what I want to do. For example, instead of asking for "a function to process data," try "a Python function to remove duplicates from a list."?
To start playing around, I can create a new file—let’s say a PowerShell script—and write a comment like function to multiply two numbers and return the result. When I press Enter, GitHub Copilot immediately suggests the code for a multiply function. I can simply press Tab to accept the suggestion. I can continue this process, getting suggestions for test cases or asking Copilot to add validation that inputs are numbers.
This kind of interaction makes my coding process much smoother and more efficient because GitHub Copilot analyzes the context of the code you're working on. For example, when you open a new JavaScript file and write a comment describing what you want to achieve, Copilot uses that information to generate suggestions relevant to JavaScript. It leverages its understanding of language syntax and common patterns to tailor its recommendations to the specific task.
Additionally, you can ask Copilot to modify existing code by providing clear instructions in comments, such as "Add input validation to this function." It will then generate the necessary code, like validating data types or checking for null values. If you need an explanation of a function, simply write a comment like "Explain this function," and Copilot will generate a comment or description outlining how the function works. This interactive approach streamlines coding, reducing the time spent on repetitive tasks and helping you focus on more complex logic.
In addition to these inline suggestions, the GitHub Copilot Chat is a powerful tool. I can open the chat window by clicking on the chat icon or using the shortcut Control + Shift + I (or Command + Shift + I on a Mac). Here, I can ask more complex questions or request new files with specific functions. For example, I might ask, "Create a new C file with a function to multiply two numbers," and Copilot will generate the code for me.
The chat is interactive, and I can reference the current editor or even ask it to explain what's in the editor. If I use Copilot frequently, I might want to dock the chat in a secondary sidebar for easier access. I can do this by going to View > Appearance > Secondary Sidebar and dragging the chat icon over.
Moreover, I can interact with GitHub Copilot through "sparkly" quick actions that appear when I select code. For instance, if I write a Python script and see an error, I can use Copilot to fix it or explain it to me. This feature is incredibly useful for solving problems on the fly.
I can also use slash commands in the chat to interact with VS Code or the terminal. For example, I might ask it how to change to a light theme or how to create an environment variable, and it will provide step-by-step instructions.
As I become more familiar with GitHub Copilot, I can start to use it for more complex tasks, like refactoring code using design patterns or even modernizing old code. It’s a versatile tool that can assist me in a wide range of programming activities.
My recommendation for getting the most out of GitHub Copilot is to start small. Focus on using one feature at a time, like the Control + I command to bring up the menu, and make it a natural part of my workflow. As I get comfortable, I can explore more features and integrate them into my daily coding routine.
I hope this overview was helpful, and I’m excited to start leveraging GitHub Copilot to enhance my programming experience!
SVP of Engineering| Technology Leader | Advisor | Delivery-Oriented | Team-Focused| Mentor| “Empowered teams deliver magic, transforming vision into business value and strong culture."??????
7 个月Great Article. Thank you, Victor.