GitHub Copilot CLI: Bringing AI Assistance to Your Terminal
GitHub Copilot is no longer confined to your IDE or browser. With GitHub Copilot CLI, you can interact with the assistant directly from your command line, asking it to generate scripts, explain commands, refactor code, or execute tasks without switching contexts.
Copilot CLI works by letting you converse with your terminal in natural language. Instead of running predefined commands, you describe what you want to accomplish, and Copilot determines the necessary steps. It also supports slash commands and integrations with MCP to extend its capabilities.
You can interact with Copilot CLI in two modes:
- Interactive mode (default): Start a session with the
copilotcommand and have a back-and-forth conversation, refining tasks as you go. - Programmatic mode: Pass a one-off request directly with
-por--promptfor an inline response.
Before reading, modifying, or executing any files, Copilot CLI will always ask for your confirmation. One exception: if you choose “Yes, and remember this folder for future sessions” or “Yes, and approve TOOL for the rest of the session” when prompted, Copilot will follow those instructions instead.
Installing and Starting Copilot CLI
To use GitHub Copilot CLI, you need a GitHub Copilot subscription (Pro, Pro+, Business, or Enterprise plans), Node.js version 22 or later, and npm version 10 or later. If your access comes from an organization, the Copilot CLI policy must be enabled in your organization’s settings.
Install Copilot CLI with this command:
npm install -g @github/copilot
Once installed, navigate to the folder containing your code and type copilot into the terminal. You’ll be asked to confirm that you trust the contents of the folder. Copilot may read, modify, and execute files in or below this directory, so only proceed if you trust the files in that location. You can choose:
- Yes, proceed: Copilot can access and use the files for only this session.
- Yes, and remember this folder for future sessions: Trusts the folder for current and future sessions.
- No, exit (Esc): Ends the Copilot CLI session.
If you're not logged in, you’ll be prompted to use the /login slash command and follow the on-screen instructions for authentication. Then enter your prompt.
When Copilot needs to modify or execute files, you’ll be asked to approve its use of tools. Your options are:
- Yes: Allow Copilot to use the tool once.
- Yes, and approve TOOL for the rest of the session: Grant full permission for the current session. Be aware of the security implications—for example, approving the
rmcommand lets Copilot delete files without further confirmation. - No, and tell Copilot what to do differently: Copilot ends the operation and waits for your next instruction.
Practical Use Cases and Prompts
GitHub Copilot CLI shines in a variety of everyday development tasks. Below are some common scenarios with example prompts you can try.
Creating Issues, Pull Requests, and Custom Instructions
Log actionable tasks that keep progress visible by asking Copilot to create a GitHub Issue:
Create an issue for adding GitHub Copilot instructions
Give Copilot more context about your project so it can deliver better assistance:
Create a branch for GitHub Copilot custom instructions
Propose changes that enhance code quality by creating a pull request:
Create a pull request with the changes we have made
Attach this pull request to issue #4
Show the content of issue #4
What pull requests are attached to this issue?
Use the MCP server to list all open issues and pull requests
Extending Capabilities and Streamlining Workflows
Access official Microsoft Learn content directly from the CLI using MCP servers:
Using the Microsoft Learn MCP server, tell me all the GitHub Copilot Microsoft Learn modules that exist
What are the names of the hands-on Skills exercises that exist in each module?
Create a README with all the Microsoft Learn GitHub Copilot modules and the hands-on skills with headings and subheadings
Reduce repetitive effort with shortcuts or aliases:
alias grep copilot
cpcli='copilot --allow-all-tools -p "$@"'
Diagnose script errors and apply fixes:
cpcli "Explain each of these scripts and offer improvements"
Codebase Maintenance and Documentation
Handle security patches, upgrade dependencies, and perform focused refactoring:
Generate a bash script to run npm audit and apply fixes automatically
Upgrade all npm dependencies to their latest safe versions
Generate or update project documentation that improves clarity:
Review the project README to make it easier for newcomers to understand
Understanding Your System
Ask questions about system resources, like storage usage or running processes:
What is taking up the most space on my own laptop?
Improving Test Coverage
Add new test suites and enhance existing ones. Ask Copilot to create a command for generating Jest test files, run coverage analysis, or provide best practices for integration tests:
Generate a command to scaffold new Jest test suites for uncovered components
Create a bash script to run npm test with coverage and output a summary report
Suggest steps to add integration tests for API endpoints using Supertest
Prototyping New Projects
Kick off greenfield projects by asking Copilot to build a proof-of-concept application from scratch:
Use create-next-app with Tailwind CSS to build a Next.js dashboard. The dashboard should pull data from the GitHub API and display metrics like build success rate, average build time, failed builds count, and automated test pass rate. After setup, provide clear steps to build, run, and view the app locally in a browser.
Setting Up Your Environment
Run terminal commands to configure your local environment for existing projects:
Provide commands to set up a Python virtual environment and install requirements.txt
Generate a bash script to clone a GitHub repo, install dependencies, and start the dev server
Suggest commands to build and run a Docker container for this project
Finding and Understanding Commands
Get suggestions for commands relevant to your current task, such as undoing a Git commit or squashing commits:
What is the Git command to undo the last commit but keep the changes staged?
Provide the Git command to squash the last three commits into one
Receive natural-language explanations of unfamiliar commands:
Explain docker run -it --rm ubuntu bash
Explain git rebase --interactive HEAD~3
Looking Ahead
Copilot CLI is currently in public preview. Your feedback will help shape its roadmap, and you can share your experience using /feedback. Whether launching a new project or tackling a backlog of fixes, Copilot CLI puts agentic AI right where you work—your terminal.



