Exercise 1 - Installing GitHub Copilot CLI
GitHub Copilot CLI is a powerful agentic coding assistant that runs in your terminal, enabling you to explore codebases, generate code, run commands, and interact with external tools - all from the command line. It allows you to offload tasks, request changes, and stay in the zone. The first step, as you might imagine, is to install the tool! Fortunately this can be done using tools you’re already familiar with.
In this exercise, you will learn how to:
- install GitHub Copilot CLI using npm.
- authenticate with your GitHub account.
- verify the installation.
Scenario
Section titled “Scenario”Your team is starting to use AI agents to work through a growing backlog. Copilot CLI brings that capability into the terminal, where many developers already live. This exercise gets you installed, authenticated, and ready to use it for the rest of the workshop.
Open a terminal in your codespace
Section titled “Open a terminal in your codespace”Before installing Copilot CLI, you need to open a terminal window in your codespace.
- Return to your codespace if you’re not already there.
- Open a terminal window by pressing Ctrl+`.
- You should see a terminal panel appear at the bottom of your VS Code window.
Install Copilot CLI
Section titled “Install Copilot CLI”You can install Copilot CLI through npm, WinGet, and Homebrew. Since GitHub Codespaces come with Node.js pre-installed you’ll use npm to install Copilot CLI.
-
In the terminal, verify Node.js is installed and meets the version requirement:
Terminal window node --versionYou should see version 22 or higher (e.g.,
v22.x.x). -
Install Copilot CLI globally in the codespace using npm:
Terminal window npm install -g @github/copilot -
Verify the installation by checking the version:
Terminal window copilot --versionYou should see the version number displayed (e.g.,
v1.0.XX).
Authenticate with GitHub
Section titled “Authenticate with GitHub”On first launch, Copilot CLI will prompt you to authenticate with your GitHub account.
-
Start Copilot CLI:
Terminal window copilot -
If you’re not currently logged in, you’ll see a prompt to authenticate. Copilot CLI will display a device code and ask you to visit a URL.
-
Follow the on-screen instructions:
- Open the provided URL in your browser
- Enter the device code when prompted
- Authorize Copilot CLI to access your GitHub account
-
Once authenticated, you’ll see the Copilot CLI prompt, ready to accept your questions and commands.
Trust the directory and verify everything is working
Section titled “Trust the directory and verify everything is working”Now that you’re at the Copilot CLI prompt for the first time, let’s trust this workshop repository and make sure Copilot CLI is properly installed and connected.
-
When Copilot CLI asks you to confirm that you trust the files in this folder, you’ll see three options:
- Yes, proceed: Trust for this session only
- Yes, and remember this folder for future sessions: Trust permanently
- No, exit (Esc): Don’t allow file access
-
For this workshop, select Yes, and remember this folder for future sessions since you’ll be working in this repository throughout.
-
Ask Copilot a simple question to verify it’s working:
What files are in this project? -
Copilot should explore the repository and provide a summary of the project structure.
-
Try the
/helpcommand to see available slash commands:/help -
Exit Copilot CLI by entering the following command in the terminal. We will return back to Copilot CLI in a future exercise!
exit
Summary and next steps
Section titled “Summary and next steps”Congratulations! You’ve successfully installed and authenticated GitHub Copilot CLI. You learned how to:
- install Copilot CLI using npm.
- authenticate with your GitHub account.
- trust a directory for Copilot CLI to work with.
- verify the installation is working correctly.
Now that Copilot CLI is installed, let’s give Copilot some project context. Continue to Exercise 2 - Custom instructions with CLI.