GITHUB-COPILOT practice question 4 of 15

How do you generate code suggestions with GitHub Copilot in the CLI?

Full set: 65 questions
Answer options
A: Write code comments -> Press the suggestion shortcut -> Select the best suggestion from the list.
B: Use copilot suggest -> Write the command you want -> Select the best suggestion from the list. Correct answer
C: Type out the code snippet -> Use the copilot refine command to enhance it -> Review the suggested command.
D: Describe the project's architecture -> Use the copilot generate command -> Accept the generated suggestion.
Correct Answer:
B. Use copilot suggest -> Write the command you want -> Select the best suggestion from the list.
Explanation

GitHub Copilot in the CLI is an extension for the official GitHub CLI (gh). To generate a command suggestion, the user invokes gh copilot suggest followed by a natural language prompt describing the desired task. Copilot then analyzes the prompt and provides a list of potential commands. The user can then review these suggestions and select the most appropriate one to copy, explain, or execute. This workflow is distinct from the in-editor experience.

Why Incorrect

A. This describes the workflow for using GitHub Copilot within an IDE (like VS Code), not the command-line interface (CLI) tool.
C. The copilot refine command is not a valid command within the GitHub Copilot in the CLI feature set.
D. The copilot generate command does not exist; the correct command to generate suggestions from a prompt is gh copilot suggest.

References

1. GitHub Docs. (n.d.). Using GitHub Copilot in the CLI. GitHub. Retrieved from https://docs.github.com/en/copilot/github-copilot-in-the-cli/using-github-copilot-in-the-cli.

Reference Point: In the "Asking GitHub Copilot in the CLI for a suggestion" section, the documentation explicitly states: "You can ask GitHub Copilot in the CLI to suggest a command for your use case using gh copilot suggest." It then provides the exact workflow: gh copilot suggest "PROMPT". This directly supports option B.

Scroll to Top