GH-300 · Domain 2: Use GitHub Copilot features · 29% of the exam
Task 2.2: Use GitHub Copilot CLI
What Copilot CLI is, how to install and sign in to it, its interactive and programmatic modes, slash commands, tool approvals, sessions, and scripting and file work from the terminal.
Study it
Copilot CLI: installing, signing in, interactive and programmatic use
Lesson coming
Copilot CLI: tool approvals, trusted directories, sessions, autopilot and /delegate
Try each one before opening the answer. Every option is explained, with the GitHub documentation page that proves it.
Question 1 · choose 1
A build script runs copilot -p "Prepare the release branch" --allow-all-tools --deny-tool='shell(git push)'. During the run, Copilot decides it needs to push the branch. What happens?
AThe push is not allowed, because --deny-tool takes precedence over --allow-all-tools
BThe push runs, because --allow-all-tools appears first on the command line and wins over later options
CCopilot pauses and asks for approval, because the two options conflict
DThe run fails at start-up, because the two options cannot be combined
Show the answer and why
AThe push is not allowed, because --deny-tool takes precedence over --allow-all-tools
Correct
The documentation states that --deny-tool takes precedence over the --allow-all-tools and --allow-tool options.
BThe push runs, because --allow-all-tools appears first on the command line and wins over later options
Incorrect
Option order does not decide it: the deny option has precedence.
CCopilot pauses and asks for approval, because the two options conflict
Incorrect
A programmatic run with these options does not turn the conflict into a prompt; the denial applies.
DThe run fails at start-up, because the two options cannot be combined
Incorrect
Combining them is the documented way to allow everything except selected tools.
--allow-all-tools lets Copilot CLI use any tool without approval, --allow-tool allows a specific tool, and --deny-tool prevents a specific tool. --deny-tool takes precedence over both allow options, so copilot --allow-all-tools --deny-tool='shell(git push)' allows everything except git push.
A Windows developer with PowerShell 7 and Node.js 22 wants to install Copilot CLI. Which commands are documented ways to install it on Windows? (Choose TWO.)
Abrew install --cask copilot-cli
Bcurl -fsSL https://gh.io/copilot-install | bash
Cnpm install -g @github/copilot
Dpip install github-copilot-cli
Ewinget install GitHub.Copilot
Show the answer and why
Abrew install --cask copilot-cli
Incorrect
The Homebrew cask is documented for macOS and Linux.
Bcurl -fsSL https://gh.io/copilot-install | bash
Incorrect
The install script is documented for macOS and Linux.
Cnpm install -g @github/copilot
Correct
The npm package installs Copilot CLI on all platforms and needs Node.js 22 or later.
Dpip install github-copilot-cli
Incorrect
Copilot CLI is not distributed as a Python package.
Ewinget install GitHub.Copilot
Correct
WinGet is the documented Windows installation method.
Copilot CLI can be installed with WinGet on Windows (winget install GitHub.Copilot), Homebrew on macOS and Linux (brew install --cask copilot-cli), npm on all platforms (npm install -g @github/copilot, with Node.js 22 or later), or the install script on macOS and Linux. On Windows it also needs PowerShell v6 or higher.
A workflow in an organization-owned repository runs Copilot CLI and exports a classic personal access token with the repo scope as GH_TOKEN. The job fails to authenticate, and the security team doesn't want any long-lived credential stored for this automation. Which credential should the job use?
AA classic personal access token with the copilot scope added
BThe workflow's built-in GITHUB_TOKEN, which GitHub recommends for automations in organization repositories
CA fine-grained personal access token owned by the organization, with read access to the repository
DAn SSH key registered on the user's account and loaded with ssh-agent
Show the answer and why
AA classic personal access token with the copilot scope added
Incorrect
Classic personal access tokens (ghp_) are not supported by Copilot CLI at all.
BThe workflow's built-in GITHUB_TOKEN, which GitHub recommends for automations in organization repositories
Correct
Copilot CLI can authenticate in Actions with GITHUB_TOKEN; in an organization-owned repository this is the recommended approach, and each run gets a short-lived, scoped token.
CA fine-grained personal access token owned by the organization, with read access to the repository
Incorrect
The Copilot Requests permission is only available on user-owned fine-grained tokens, and any personal access token is a stored, long-lived credential.
DAn SSH key registered on the user's account and loaded with ssh-agent
Incorrect
Copilot CLI authenticates with OAuth or with a token in an environment variable, not with SSH keys.
Copilot CLI doesn't support classic personal access tokens. In GitHub Actions it can authenticate with a personal access token, as the user who created it, or with the built-in GITHUB_TOKEN, as an installation with no individual user. For automations in an organization-owned repository, GitHub recommends GITHUB_TOKEN: each workflow run receives a short-lived, scoped token, so no long-lived credential has to be stored or rotated. A personal access token for the CLI must be a fine-grained token owned by a personal account with the Copilot Requests permission.
Before leaving for the day, a developer in a Copilot CLI session types /delegate add retry logic to the payments client. What does the documentation say happens next? (Choose TWO.)
AThe work runs on GitHub, so it continues even if the developer shuts down the laptop
BCopilot runs the task in a local sandbox with all permissions granted
CThe task runs against the developer's own model provider key that is configured for the CLI
DThe task starts only after the developer adds the --yolo option
ECopilot cloud agent opens a draft pull request and works on it in the background
Show the answer and why
AThe work runs on GitHub, so it continues even if the developer shuts down the laptop
Correct
/delegate pushes the task to Copilot cloud agent, which runs remotely and keeps going if the local machine is shut down.
BCopilot runs the task in a local sandbox with all permissions granted
Incorrect
That describes autopilot mode in a local session, not /delegate.
CThe task runs against the developer's own model provider key that is configured for the CLI
Incorrect
/delegate transfers the session to GitHub's server-side Copilot, not a BYOK provider.
DThe task starts only after the developer adds the --yolo option
Incorrect
/delegate needs no permission flag; the cloud agent works in its own environment.
ECopilot cloud agent opens a draft pull request and works on it in the background
Correct
Copilot creates a branch, opens a draft pull request, makes changes in the background and requests a review.
Copilot CLI offers autopilot mode for hands-free local work and /delegate (or a prompt prefixed with &) to hand a task to Copilot cloud agent. With /delegate, Copilot asks to commit unstaged changes as a checkpoint in a new branch, the cloud agent opens a draft pull request and works in the background, and the work continues even if the local machine is shut down.
A developer wants a cron job to ask Copilot CLI one question and exit when it is done, without starting an interactive session. Which option provides the prompt on the command line?
A--plan
B-p (or --prompt)
C--resume
D--allow-all-tools
Show the answer and why
A--plan
Incorrect
--plan starts with planning; it doesn't pass a one-off prompt by itself.
B-p (or --prompt)
Correct
Including -p or --prompt passes a single prompt; the CLI completes the task and exits.
C--resume
Incorrect
--resume selects and resumes an interactive session.
D--allow-all-tools
Incorrect
--allow-all-tools lets Copilot use tools without approval; it does not supply a prompt.
Copilot CLI has two interfaces. Entering copilot starts an interactive session; including -p or --prompt passes a single prompt programmatically, and the CLI completes the task and then exits. To let it modify or execute files in that mode, you also pass an approval option such as --allow-tool.
In an interactive Copilot CLI session, a developer wants Copilot to explain the file config/ci/ci-required-checks.yml. How does she add the file's contents to the prompt?
APrefix the path with ! so that the CLI reads the file
BPrefix the path with & so that Copilot opens it
CPrefix the path with # so that it becomes a context variable
DWrite @config/ci/ci-required-checks.yml in the prompt
Show the answer and why
APrefix the path with ! so that the CLI reads the file
Incorrect
The ! prefix does not add a file's contents to the prompt.
BPrefix the path with & so that Copilot opens it
Incorrect
& delegates the prompt to Copilot cloud agent.
CPrefix the path with # so that it becomes a context variable
Incorrect
In the CLI, # references a GitHub issue or pull request number.
DWrite @config/ci/ci-required-checks.yml in the prompt
Correct
@ followed by the relative path adds the file's contents to the prompt as context.
To add a specific file to a Copilot CLI prompt, use @ followed by the relative path, for example Explain @config/ci/ci-required-checks.yml. Matching paths appear as you type and Tab completes them, and the file's contents are added to the prompt as context.
Mid-session in Copilot CLI, a developer just wants to run git status herself without spending AI credits on a model call. What should she type?
A/run git status
B@git status
C!git status
D/delegate git status
Show the answer and why
A/run git status
Incorrect
/run is not the documented way to run a shell command directly.
B@git status
Incorrect
@ adds a file to the prompt.
C!git status
Correct
Prepending input with ! runs the shell command directly, without making a call to the model.
D/delegate git status
Incorrect
/delegate hands a task to Copilot cloud agent.
In Copilot CLI you can prepend your input with ! to run a shell command directly, without making a call to the model, for example !git clone https://github.com/github/copilot-cli. Prompts without the prefix go to the model and consume AI credits.
A developer closed a Copilot CLI session by mistake and wants to pick it up again with its saved context as quickly as possible. Which command does that?
Acopilot --continue
Bcopilot --cloud
Ccopilot -p "resume my session"
Dcopilot --yolo
Show the answer and why
Acopilot --continue
Correct
copilot --continue quickly resumes the most recently closed local session.
Bcopilot --cloud
Incorrect
--cloud starts a new session in a cloud sandbox.
Ccopilot -p "resume my session"
Incorrect
This sends the words as a one-off prompt instead of restoring a session.
Dcopilot --yolo
Incorrect
--yolo enables all permissions; it does not resume a session.
You can use --resume or the /resume slash command to select and resume an interactive Copilot CLI session with its saved context. To quickly resume the most recently closed local session, enter copilot --continue.