Exercise - Develop with AI-powered code suggestions by using GitHub Copilot and VS Code

In this lab, you will learn how to use GitHub Copilot with Visual Studio Code to get AI-powered code suggestions and accelerate your development workflow. GitHub Copilot is an AI pair programmer that helps you write code faster and with less effort by suggesting whole lines or entire functions based on your context.

You will learn how to:

  • Install and configure GitHub Copilot in VS Code
  • Use GitHub Copilot for code completion
  • Accept and modify Copilot suggestions
  • Prompt Copilot effectively for better suggestions
  • Understand when to use Copilot's suggestions
  • Leverage AI assistance in your development workflow

This lab takes approximately 30-45 minutes to complete.

Before you start

To complete the lab, you need:

  • A GitHub user account. If you don't have one, you can create a new account. If you need instructions on how to create a GitHub account, refer to the article Creating an account on GitHub.
  • Access to GitHub Copilot (requires a subscription or trial).
  • Basic programming knowledge (any language).
  • A web browser with access to the internet.

Complete the exercise on GitHub

In this exercise, you'll learn to use GitHub Copilot through a hands-on exercise that guides you through installation and usage.

Note: This exercise is hosted on Microsoft Learn and provides an interactive learning experience. You'll install GitHub Copilot by using GitHub Codespaces, prompt it for code suggestions, and learn best practices for working with AI-powered coding assistance.

The exercise consists of the following activities:

  1. Start a web browser and navigate to the exercise page: https://learn.microsoft.com/en-us/training/modules/introduction-to-github-copilot/5-exercise

  2. On the exercise page, select the Start the exercise on GitHub button. This will take you to a public GitHub template repository: https://github.com/skills/getting-started-with-github-copilot

  3. Select the Use this template button or Start course button to create your own copy of the repository.

    Note: We recommend creating a public repository, as private repositories use GitHub Actions minutes. Wait about 20 seconds after creating your repository, then refresh the page.

  4. Follow the instructions on the repository's README to complete all the challenges, which include:

    • Installing GitHub Copilot by using GitHub Codespaces
    • Prompting GitHub Copilot for code suggestions
    • Accepting code suggestions from GitHub Copilot
    • Using different types of suggestions (inline, multi-line)
    • Learning best practices for working with AI assistance
    • Understanding when to trust Copilot's suggestions
  5. Work through each step in the exercise, following the prompts and instructions provided in the README.

    Note: You don't need to modify any of the workflow files to complete this exercise. Altering the workflow contents can break the exercise's ability to validate your actions and provide feedback.

  6. When you finish all the challenges, return to the Microsoft Learn module for a knowledge check and to earn your completion badge.

What you've learned

After completing this exercise, you should be able to:

  • Install and configure GitHub Copilot in development environments
  • Use GitHub Copilot to get code suggestions
  • Accept, modify, and reject Copilot suggestions appropriately
  • Write effective prompts to get better suggestions
  • Understand the capabilities and limitations of AI coding assistance
  • Integrate GitHub Copilot into your development workflow
  • Use AI to improve coding productivity and quality
  • Apply best practices for AI-assisted development

Congratulations! You've completed the "Develop with AI-powered code suggestions by using GitHub Copilot and VS Code" exercise and learned how to leverage AI in your coding workflow!