Domain 3 of 6 · Chapter 1 of 2

Enhance Productivity and Code Quality

Unlock the complete study guide.

Bundled into the existing GitHub Copilot premium course — no separate purchase.

14-day money-back guarantee — no questions asked.

Included in this chapter:

  • One loop for every productivity task
  • Generating code from comments and prompts
  • Breaking a complex generation task into steps
  • Reviewing generated code before you accept it
  • Refactoring: new structure, same behavior
  • Generating documentation from code
  • Learning in the editor: explanations and follow-ups
  • Debugging with evidence: error text and expected behavior
  • Generating sample data that respects the schema
  • Modernizing legacy code: the two documented approaches
  • The chat-driven modernization workflow
  • Assessing and upgrading with the app modernization extension
  • Finishing a modernization after the conversion
  • Practice scenarios: productivity tasks

One loop, different baselines: what to supply, what to state, what to check per task

TaskContext to supplyTarget to stateBaseline to check against
Code generationSurrounding code, relevant open files, example inputs and outputsGoal, then inputs, outputs, error handling and frameworkYour stated requirements, through review and tests
RefactoringThe selected code, understood first through an explanationTarget structure or convention, such as the syntax of the language version the project targets, or a naming styleExisting behavior, through the existing tests
DocumentationThe code; for project docs also configuration, existing docs and audienceContract and rationale: inputs, outputs, dependencies, assumptionsThe current implementation
ExplanationThe selected code or fileThe part to clarify and the language you already knowThe code itself
DebuggingError message and the relevant codeExpected behavior versus actual behaviorThe expected behavior, after the fix runs
Sample dataSchema or a representative structured sampleCount, patterns, uniqueness and which keys must resolve to parent rowsConstraints, relationships and business rules
ModernizationLegacy files, dependencies and data flowTarget language or framework, one bounded part at a timeThe legacy system's behavior; in the chat-driven workflow, a stakeholder-validated test plan

Decision tree

Does the code give an erroror unexpected output?YesDebuggingNoNeed test or mock data thatfits a table schema?YesSample dataNoMoving code to another languageor a newer framework version?YesModernizationNoRestructure existing codewithout changing what it does?YesRefactoringNoNeed to understandunfamiliar code?YesExplanationNoNeed comments, docstringsor a README for the code?YesDocumentationNoWriting new code from a commentor a chat request?YesCode generationNoTests, security or performancelisted under Support testing and securityCheck Copilot's work: always validate the code it suggests

Cheat sheet

  • Natural-language comments can cue code suggestions
  • Specific requirements constrain generated code
  • Complex generation tasks should be decomposed
  • Examples steer generated interfaces and behavior
  • Generated code requires review and execution
  • Refactoring preserves observable behavior
  • Understand code before refactoring it
  • Repeated logic can be extracted for reuse
  • Multi-purpose functions can be split into focused units
  • Refactors should name the target convention
  • Code context can seed API documentation
  • Project documentation needs project context
  • Documentation should capture contracts and rationale
  • Generated documentation must be reviewed
  • In-context explanations reduce reference switching
  • Follow-up prompts can adapt an explanation
  • Comparisons can accelerate language learning
  • Debugging prompts need symptoms and expectations
  • Schema context shapes usable sample data
  • Sample-data prompts should state the required shape
  • Relational sample data should preserve valid links
  • Generated data needs integrity validation
  • Explain the legacy system before converting it
  • A test plan baselines legacy behavior
  • Modernization starts with dependencies and blockers
  • Legacy migration should proceed incrementally
  • Build-and-test loops validate modernization
  • Modernization continues after mechanical conversion

Unlock with Premium — includes all practice exams and the complete study guide.

References

  1. https://github.com/github/docs/blob/871db5e8a4122d0c6d218f08a64e7e95b950c448/content/copilot/tutorials/refactor-code.md
  2. https://learn.microsoft.com/en-us/credentials/certifications/resources/study-guides/gh-300
  3. https://docs.github.com/en/copilot/concepts/prompting/prompt-engineering
  4. https://docs.github.com/en/copilot/tutorials/copilot-cookbook/refactor-code/translate-code
  5. https://docs.github.com/en/copilot/concepts/completions/code-suggestions
  6. https://docs.github.com/en/copilot/get-started/best-practices
  7. https://docs.github.com/en/copilot/how-tos/get-code-suggestions/get-ide-code-suggestions?tool=vscode
  8. https://docs.github.com/en/copilot/tutorials/review-ai-generated-code
  9. https://github.com/github/docs/commit/e69e757062
  10. https://docs.github.com/en/copilot/tutorials/copilot-cookbook/refactor-code
  11. https://docs.github.com/en/copilot/tutorials/copilot-cookbook/refactor-code/improve-code-readability
  12. https://github.blog/ai-and-ml/github-copilot/documenting-and-explaining-legacy-code-with-github-copilot-tips-and-examples/
  13. https://docs.github.com/en/copilot/reference/cheat-sheet
  14. https://learn.microsoft.com/en-us/training/modules/generate-documentation-using-github-copilot-tools/6-generate-inline-code-documentation-using-github-copilot
  15. https://learn.microsoft.com/en-us/training/modules/generate-documentation-using-github-copilot-tools/5-generate-project-documentation-using-github-copilot
  16. https://code.visualstudio.com/docs/chat/copilot-chat-context
  17. https://docs.github.com/en/copilot/tutorials/customization-library/prompt-files/document-api
  18. https://learn.microsoft.com/en-us/training/modules/generate-documentation-using-github-copilot-tools/4-analyze-explain-code-using-github-copilot
  19. https://github.blog/changelog/2026-05-18-ask-questions-in-context-with-copilot-on-web/
  20. https://docs.github.com/en/get-started/learning-to-code/finding-and-understanding-example-code
  21. https://docs.github.com/en/get-started/learning-to-code/setting-up-copilot-for-learning-to-code
  22. https://docs.github.com/en/get-started/learning-to-code/learning-to-debug-with-github-copilot
  23. https://learn.microsoft.com/en-us/sql/tools/visual-studio-code-extensions/github-copilot/test-and-mocking-data-generator?view=sql-server-ver17
  24. https://github.com/github/docs/blob/871db5e8a4122d0c6d218f08a64e7e95b950c448/content/copilot/tutorials/modernize-legacy-code.md
  25. https://github.com/github/docs/blob/871db5e8a4122d0c6d218f08a64e7e95b950c448/content/copilot/tutorials/migrate-a-project.md
  26. https://github.com/github/docs/blob/871db5e8a4122d0c6d218f08a64e7e95b950c448/content/copilot/tutorials/modernize-java-applications.md
  27. https://learn.microsoft.com/en-us/java/upgrade/