Skip to content

GH-300 · Domain 5: Improve developer productivity with GitHub Copilot · 13% of the exam

Task 5.1: Enhance productivity and code quality

Code generation, refactoring and documentation, learning faster with less context switching, sample data, and modernizing legacy code.

Study it

  • Generating, refactoring and documenting code with Copilot

    Lesson coming

  • Learning faster, less context switching, sample data and legacy code

    Partly covered by: Measuring AI Value

Sample questions

Try each one before opening the answer. Every option is explained, with the GitHub documentation page that proves it.

Question 1 · choose 1

A Java developer joins a Go project and wants to understand a goroutine-heavy function in the editor without searching the web. Which Copilot Chat slash command, used with the function selected, serves that?

  1. A/fix
  2. B/help
  3. C/explain
  4. D/fixTestFailure
Show the answer and why
  • A/fix

    Incorrect

    /fix proposes a fix for problems in the selected code.

  • B/help

    Incorrect

    /help gives a quick reference to the basics of using Copilot.

  • C/explain

    Correct

    /explain explains how the code in your active editor works.

  • D/fixTestFailure

    Incorrect

    /fixTestFailure finds and fixes a failing test.

Copilot Chat in VS Code offers slash commands for common scenarios: /explain explains how the code in your active editor works, /fix proposes a fix, /help gives a quick reference and /fixTestFailure finds and fixes a failing test. Explaining unfamiliar code in place helps developers learn a new language with less context switching.

Question 2 · choose 1

A QA engineer needs 500 realistic customer records to load-test a signup flow. Production data contains personal information that must not leave the database, and the records must match the current schema. What is the most appropriate use of Copilot?

  1. AExport a production sample and ask Copilot Chat to anonymize it after pasting it in
  2. BAsk Copilot to write a script that copies production rows into the test database
  3. CGive Copilot the schema and ask it to generate realistic synthetic sample data
  4. DAsk Copilot cloud agent to find similar public datasets on GitHub to import
Show the answer and why
  • AExport a production sample and ask Copilot Chat to anonymize it after pasting it in

    Incorrect

    Pasting production personal data into a prompt is what the constraint forbids.

  • BAsk Copilot to write a script that copies production rows into the test database

    Incorrect

    Copying production records keeps the personal data the engineer must avoid.

  • CGive Copilot the schema and ask it to generate realistic synthetic sample data

    Correct

    Copilot can generate realistic sample data for testing, which saves manual data creation without using production records.

  • DAsk Copilot cloud agent to find similar public datasets on GitHub to import

    Incorrect

    Importing third-party data does not guarantee it matches the schema, and it is not the documented use.

Microsoft Learn lists sample data creation among the routine tasks Copilot handles: when testing, it can generate realistic sample data, saving time on manual data creation. Generating synthetic records from the schema meets the need without moving production personal data into prompts or test systems.

Question 3 · choose 1

A reviewer flags a 200-line JavaScript function with parameters named a, b and c, deep nesting and a long if...else chain. The author wants Copilot's help to make it maintainable. Which approach matches GitHub's cookbook guidance?

  1. ASelect it and ask Copilot Chat for clearer names, less nesting and smaller methods
  2. BAsk Copilot to translate the function into another language, which forces a cleaner design
  3. CEnable the public code filter so that Copilot rewrites the function from a known clean source
  4. DRun /tests on the function so that its structure is rewritten to be testable
Show the answer and why
  • ASelect it and ask Copilot Chat for clearer names, less nesting and smaller methods

    Correct

    The cookbook shows Copilot Chat suggesting better variable names, avoiding sequential conditional checks, reducing nested logic and splitting large methods.

  • BAsk Copilot to translate the function into another language, which forces a cleaner design

    Incorrect

    Translation changes the language, not the readability problems the reviewer flagged.

  • CEnable the public code filter so that Copilot rewrites the function from a known clean source

    Incorrect

    The public code filter decides whether matching suggestions are shown; it does not refactor code.

  • DRun /tests on the function so that its structure is rewritten to be testable

    Incorrect

    /tests generates tests for the code; it does not refactor the function itself.

GitHub's cookbook article on readability shows Copilot Chat improving variable names, avoiding sequential conditional checks, reducing nested logic and splitting large methods into smaller ones. You select the code in the editor and ask Copilot Chat for the change, then review the non-deterministic response.

Question 4 · choose 1

Only one engineer still knows Perl, and the team wants a Perl word-count script moved to TypeScript. How can Copilot help most directly?

  1. AUse /tests on the Perl script to rewrite it in TypeScript
  2. BAsk Copilot Chat to translate it and explain how to run it
  3. CEnable next edit suggestions so the Perl file changes language as you type
  4. DAsk Copilot to add comments, because commented Perl no longer needs translating
Show the answer and why
  • AUse /tests on the Perl script to rewrite it in TypeScript

    Incorrect

    /tests generates unit tests; it doesn't translate code.

  • BAsk Copilot Chat to translate it and explain how to run it

    Correct

    Copilot can translate code to another language; translating a standalone script is straightforward, and it can explain how to run the result.

  • CEnable next edit suggestions so the Perl file changes language as you type

    Incorrect

    Next edit suggestions predict edits; they don't convert languages.

  • DAsk Copilot to add comments, because commented Perl no longer needs translating

    Incorrect

    Comments help readability but don't move the code to a maintained language.

Copilot Chat can rewrite code to perform the same operations in a different language, for example to move code from a language few people know, such as Perl, to Python or TypeScript. Translating a standalone file, such as a script, is straightforward, and Copilot can explain how to run the new file.

Question 5 · choose 1

A team's service has almost no documentation. Which documentation tasks does Microsoft Learn describe Copilot helping with?

  1. AOnly README files, because Copilot can't see function bodies
  2. BOnly translating existing documentation into other languages
  3. CInline comments, function descriptions and README files
  4. DDocumentation is out of scope; Copilot only writes executable code
Show the answer and why
  • AOnly README files, because Copilot can't see function bodies

    Incorrect

    Copilot also suggests inline comments and function descriptions.

  • BOnly translating existing documentation into other languages

    Incorrect

    Learn describes generating new documentation, not only translation.

  • CInline comments, function descriptions and README files

    Correct

    Copilot generates inline comments, suggests function descriptions including parameters and return values, and helps create README files.

  • DDocumentation is out of scope; Copilot only writes executable code

    Incorrect

    Documentation writing is one of the listed productivity use cases.

Microsoft Learn lists enhanced documentation writing among Copilot's productivity benefits: contextually relevant inline comments for complex sections, function descriptions with parameter and return value details, README generation based on the codebase, and consistent documentation style across a project.

Question 6 · choose 1

A new team member wants to understand how an unfamiliar repository handles HTTP requests and responses, without cloning it. What is a good way to use Copilot?

  1. AAsk Copilot Chat on GitHub how the repository handles HTTP requests
  2. BRun Copilot code review on the default branch to get a summary
  3. CAssign an issue to Copilot cloud agent asking it to rename the HTTP classes
  4. DGenerate a pull request summary of the latest commit
Show the answer and why
  • AAsk Copilot Chat on GitHub how the repository handles HTTP requests

    Correct

    With a repository context, Copilot Chat uses the semantic code search index to reference relevant code in its answer.

  • BRun Copilot code review on the default branch to get a summary

    Incorrect

    Code review reviews pull request changes, not a whole repository's design.

  • CAssign an issue to Copilot cloud agent asking it to rename the HTTP classes

    Incorrect

    That asks for changes, not an explanation.

  • DGenerate a pull request summary of the latest commit

    Incorrect

    A summary of one change won't explain how the repository works.

When you start a Copilot Chat conversation with a repository context, the repository is indexed automatically to improve answers about the code's structure and logic. For example, you can ask "How does this repo manage HTTP requests and responses?" and Copilot Chat will reference relevant sections of the code.

Question 7 · choose 1

A developer editing files in the GitHub web editor wants help writing a clear commit message. What can Copilot do there?

  1. ANothing; commit message generation is only available in the CLI
  2. BGenerate the message only after the pull request is merged
  3. CSuggest a title and description at Commit changes, for her to edit
  4. DCopy the pull request summary into every commit automatically
Show the answer and why
  • ANothing; commit message generation is only available in the CLI

    Incorrect

    Commit message generation is available on GitHub.com and in GitHub Desktop.

  • BGenerate the message only after the pull request is merged

    Incorrect

    The message is suggested when you commit, before merge.

  • CSuggest a title and description at Commit changes, for her to edit

    Correct

    On GitHub.com, Copilot generates a suggested summary and description from the changes in the selected files when you click Commit changes.

  • DCopy the pull request summary into every commit automatically

    Incorrect

    Commit messages are generated on request from the selected changes.

On GitHub.com, when you click Commit changes, Copilot can generate a suggested commit summary (title) and description based on the changes in the selected files; in GitHub Desktop you can select lines or files for more context. Review and edit the suggestion before committing; English is the only supported language.

Practise domain 5 →Practise all domains →