Skip to content
Lucky Snail Logo Lucky Snail
中文

GitHub Copilot Chat Experience

/ 5 min read /
#github copilot #ai #提效
Table of Contents 目录

Recently, I’ve seen many big shots sharing about GitHub Copilot Chat, claiming it can double productivity. Skeptical and in the mood to debunk it, I decided to give it a try myself. The result? Really impressive. Below is my experience using GitHub Copilot Chat.

First, let’s understand what GitHub Copilot Chat is. GitHub Copilot is an AI-powered code completion tool jointly developed by OpenAI and GitHub. It uses machine learning models to predict and generate code, helping developers write code faster. GitHub Copilot Chat is an extension of GitHub Copilot that brings the AI programming assistant into a conversational interface, helping answer coding questions, provide code examples, and even review and fix code. Both tools are effective assistants for developers, improving coding efficiency and code quality. So, here’s what we need to do 👇🏻👇🏻

  1. You must have purchased GitHub Copilot, because Chat is built on top of it. You can buy it from Taobao like I did – it’s quite cheap (costs about the price of a milk tea). I believe this is definitely the most cost-effective investment you’ll make in 2023.
  2. After purchasing, log in to your VS Code using the account you bought the service with, then download the GitHub Copilot plugin from the extension marketplace to experience its capabilities (my code output = ChatGPT + GitHub Copilot).
image-20230527153837751
  1. Apply to join the waitlist: github.com/github-copi… After joining, if you revisit the URL you’ll see 👇🏻. Also, keep an eye on the email you provided; you’ll be notified when approved (very fast, at most two working days).
image-20230527154016617
  1. Download VS Code Insiders, because that’s the only place you can experience it (this cost me a lot of time): code.visualstudio.com/insiders/
image-20230527154108314
  1. In the VS Code Insiders we just downloaded, install the extension GitHub Copilot Nightly: marketplace.visualstudio.com/items?itemN… You’ll see 👇🏻
image-20230527154215438

If you don’t see it, don’t panic. First check if your editor is logged into GitHub, and see if there’s a popup in the bottom right asking you to sign in for GitHub Copilot Chat. If both are done, restart and the long-awaited chat page should appear.

Experience the Power of AI

First, let’s see how the official description positions it: “I’m your copilot. I’m here to help you get things done faster. I can identify problems, explain and even improve code. You can ask general questions, but where I really shine is helping you write code. For example:

  • Generate unit tests for my code
  • Explain selected code
  • Suggest and fix errors in my code

If you want to learn more about my abilities and limitations, check the copilot docs: docs.github.com/en/early-ac…

Generate unit tests for my code

I select the function on the left, then use command + i (Windows: ctrl + i)

image-20230527163056394

Here my prompt is /test Generate tests for the selected code with Mocha. Two notes:

  1. I used the /test keyword provided by GitHub Copilot Chat to generate unit test code.
  2. I added the testing framework Mocha at the end.

On the right, the corresponding unit test code is generated. Since I haven’t installed the testing library, it errors out. Guys, check if the generated code looks correct? (I think it’s reliable.)

Explain selected code

Step-by-step explanation of the selected code

Again I use command + i and the prompt is the built-in /explain

image-20230527163742419

Suggest and fix errors in my code

Erroneous code: image-20230527164206558

If you run it, you’ll find it doesn’t detect the error in the hooks usage. That’s understandable because it doesn’t know the context. After I write the prompt like this, it works:

image-20230527164355663

Other features

  1. /ext: Ask about VS Code extension development.
  2. /fix: Suggest fixes for issues in selected code.
  3. /help: General help about GitHub Copilot.
  4. /vscode: Questions about VS Code.
  5. /clear: Clear the current session.

Summary of experience

  1. When chatting on the left, it really understands how lazy developers are – it automatically predicts the next question. That’s seriously smart.
  2. The biggest benefit is the seamless integration with the editor. The experience is very nice. No more context switching.
  3. When reading source code, I think /explain is incredibly powerful. After this, I’m never afraid of reading source code again.
  4. Placing it in the editor doesn’t mean it can’t do other things. You can basically treat it as a ChatGPT 3.5. Hmm… so now I can use ChatGPT at work without being caught?
  5. After writing code, if there’s complex business logic and some untested bugs, we can directly select the code and ask: “Any improvements here?” “Does this code need refactoring?”
  6. Now, if we can streamline our workflow, we can fully use AI to help us complete tasks. For example, the most common CRUD operations – if the code is generic enough, can’t we just leave new CRUD to AI? Unlike writing it ourselves, where we might copy-paste errors.
  7. We can also ask it how to implement scenarios we haven’t tackled before, making our code more robust and readable. I think, after learning from so many excellent open-source libraries on GitHub, it basically provides best practices. We just need to write better prompts.

Finally, I discovered a gem: GitHub Copilot Voice. I’ve already joined the waitlist. In the future, writing code might not even need a keyboard. That’s really cool!