GitHub Copilot (GH-300) · 15% practice allocation

GitHub GH-300: Improve Developer Productivity with GitHub Copilot Practice Questions

5 free sample questions from the Improve Developer Productivity with GitHub Copilot domain, with answers and explanations. The full GH-300 bank has 115 questions across 6 domains. Questions are scenario-based and written from the official GitHub exam guide.

1.

A developer runs a failing shell command in their terminal and receives a cryptic error message. They want to use GitHub Copilot CLI to get a natural-language explanation of what went wrong. Which command should they run?

  • A. gh copilot suggest "explain last error"
  • B. gh copilot explain "$(cat ~/.bash_history | tail -1)"
  • C. gh copilot explain✓ Correct
  • D. gh copilot suggest --shell
Explanation

gh copilot explain is the correct CLI subcommand for getting a plain-language explanation of a command or its output — the developer can pass the failing command as an argument or respond to the interactive prompt. gh copilot suggest is used to generate a new shell command from a natural-language description, not to explain existing output. The second option attempts to pass history manually but is not the standard interface and would not explain error output. gh copilot suggest --shell specifies the target shell type for command generation, not error explanation.

2.

A senior developer uses GitHub Copilot to refactor a 200-line function into smaller, well-named helper functions. After accepting Copilot's refactored output, which THREE practices represent responsible follow-up steps?

  • A. Delete the original function immediately to prevent Copilot from referencing outdated code
  • B. Immediately commit and push the refactored code to main without review, trusting Copilot's output
  • C. Run the existing test suite to verify the refactored code preserves original behavior✓ Correct
  • D. Accept all future Copilot suggestions for this file without review, since the context is now established
  • E. Check that no security-sensitive logic (e.g., authentication, input validation) was silently altered or omitted✓ Correct
  • F. Review each extracted function to ensure names and logic accurately reflect intent✓ Correct
Explanation

Running the test suite confirms behavioral equivalence — refactoring should not change external behavior, and tests are the safety net. Reviewing extracted function names and logic ensures Copilot's interpretation of intent is correct; subtle misunderstandings can produce logically renamed but functionally different code. Checking security-sensitive sections is critical because Copilot can silently drop, reorder, or subtly alter validation and auth logic during refactoring, which represents a serious risk. Committing directly to main without review is dangerous and violates responsible AI-assisted development practices. Deleting the original immediately removes the ability to diff and verify correctness. Blind trust in all future suggestions is contrary to Copilot's documented limitations around hallucinations and security misses.

3.

A developer is reviewing a pull request that contains an unfamiliar recursive algorithm written six years ago. They highlight the entire function in VS Code and want Copilot to walk them through what it does step by step. Which action is MOST appropriate?

  • A. Use /tests to generate tests, then infer behavior from the test cases
  • B. Type a comment above the function and wait for Copilot autocomplete to describe it
  • C. Run /fix on the selection to reveal hidden bugs that explain its behavior
  • D. Run /explain on the selection in inline chat or Copilot Chat✓ Correct
Explanation

/explain is the purpose-built command for getting a natural-language walkthrough of selected code — it is the most direct and reliable way to understand unfamiliar logic. /fix looks for bugs to repair, not to explain behavior; using it here is off-label and may produce unnecessary changes. Generating tests with /tests can indirectly hint at behavior, but it is an indirect and inefficient approach to understanding. Waiting for autocomplete to fill in a comment is unreliable and passive — Copilot may produce a partial or inaccurate description without the full selection context that /explain uses.

4.

A developer wants GitHub Copilot to generate more accurate and context-aware code completions for a new module. Which TWO of the following practices BEST optimize the context available to Copilot?

  • A. Keep related files (e.g., interfaces, utility modules) open in editor tabs alongside the file being edited✓ Correct
  • B. Restart VS Code before each coding session to clear Copilot's memory
  • C. Set the file language mode to Plain Text to avoid syntax interference
  • D. Write descriptive comments above the function or class explaining intent before writing the implementation✓ Correct
  • E. Close all other editor tabs so Copilot only focuses on the current file
Explanation

Keeping related files open in editor tabs provides Copilot with broader context (imports, types, interfaces) that directly improves suggestion relevance — Copilot uses open tabs as part of its context window. Writing descriptive comments before the implementation acts as a natural-language prompt that steers Copilot's suggestions toward the intended behavior. Closing all tabs does the opposite of context optimization — it removes potentially valuable context. Restarting VS Code does not affect Copilot's suggestion quality; Copilot does not retain memory between sessions in a way that restarting would improve. Changing the language mode to Plain Text disables syntax-aware completions and would reduce, not improve, suggestion quality.

5.

A developer highlights a JavaScript function in VS Code that is throwing an unexpected TypeError at runtime. They want GitHub Copilot to diagnose and rewrite the function to fix the error. Which inline chat command is most appropriate?

  • A. /fix✓ Correct
  • B. /doc
  • C. /tests
  • D. /explain
Explanation

/fix is specifically designed to analyze highlighted code with an error and propose a corrected version — it is the correct command for diagnosing and rewriting buggy code. /explain describes what code does but does not rewrite it. /tests generates unit tests for the selected code, which would not directly repair the TypeError. /doc generates documentation comments and does not address runtime errors.

Test yourself across every GH-300 domain

The free GH-300 practice test mixes about 20 questions weighted like the exam. The full 115-question bank adds instant grading, flashcards and a timed mock exam.

Study this domain

Improve Developer Productivity with GitHub Copilot study guide (GH-300) →

Other GH-300 domains

← All GitHub Copilot study resources