GH-300 — GitHub Copilot Cheat Sheet
Compact GH-300 Cheat sheet for GitHub Copilot exam prep: Copilot surfaces, plans, prompts, governance, security, privacy, testing, and troubleshooting.
Use the tables for a quick pre-exam check. Expand a topic’s notes for explanations, examples, and additional distinctions.
Scope and study context
This page is IT Mastery exam-prep support. It is not affiliated with GitHub and does not replace GitHub documentation, hands-on product use, or your organization’s policies.
Exam focus at a glance
This Cheat Sheet supports candidates preparing for the GitHub GitHub Copilot (GH-300) exam, code GH-300. Expect scenario questions about using GitHub Copilot effectively, selecting the right Copilot surface, applying responsible AI practices, and administering Copilot in an organization.
| Area | What to know for GH-300 | Common exam angle |
|---|---|---|
| Copilot surfaces | Inline suggestions, Copilot Chat, GitHub.com experiences, CLI assistance, IDE integrations | Choose the best surface for a task |
| Prompting | Clear intent, constraints, examples, context, iteration | Improve vague prompts |
| Context | Open files, selected code, repository context, chat references, exclusions | Diagnose poor or unsafe output |
| Plans and administration | Personal vs organization/enterprise management, seat assignment, policy controls | Pick admin-controlled option |
| Privacy and data handling | Business/Enterprise protections, public-code matching, content exclusions | Distinguish privacy controls from security scanning |
| Responsible AI | Human review, hallucination risk, bias, license awareness, secure coding review | Identify unsafe overreliance |
| Developer workflows | Generate, explain, refactor, test, document, debug, review | Use Copilot without skipping validation |
| Troubleshooting | Auth, license, IDE extension, policy, network, exclusions, context | Resolve “Copilot is not working” scenarios |
Copilot surface selection matrix
| Use case | Best Copilot surface | Why | Exam trap |
|---|---|---|---|
| Complete current line, function, or boilerplate | Inline code completion in IDE | Fastest for local coding flow | Not ideal for architectural explanations |
| Ask about selected code | Copilot Chat in IDE | Uses selected code and workspace context | Chat still needs precise instructions |
| Explain an unfamiliar function | Copilot Chat with selected code | Natural language explanation, examples, edge cases | Explanation may be incomplete or wrong |
| Generate unit tests | Copilot Chat or inline suggestions near test file | Can follow nearby test patterns | Generated tests may assert implementation, not requirements |
| Refactor code | Copilot Chat with selected block and constraints | Allows step-by-step transformation | Must rerun tests and review behavior changes |
| Debug an error message | Copilot Chat with error, stack trace, relevant code | Can reason over symptoms and code | Do not paste secrets from logs |
| Learn a shell command | GitHub Copilot in the CLI | Suggests or explains commands | Always inspect destructive commands |
| Understand repository-level code | Copilot Chat with workspace/repository context where supported | Can reason across project files | Depends on permissions, indexing, exclusions, and feature support |
| Summarize or work with PRs on GitHub.com | GitHub Copilot features on GitHub.com where available | Useful for review context | Not a substitute for code review |
| Enforce organization policy | Copilot Business or Enterprise admin settings | Centralized governance | Personal settings do not control an organization |
Plans and feature distinctions
Feature packaging can change, but GH-300 scenarios usually test the distinction between individually managed Copilot use and organization-managed Copilot use.
| Plan category | Primary audience | Key management model | High-yield distinction |
|---|---|---|---|
| Personal Copilot plan | Individual developer | User manages subscription/settings | Good for personal productivity; limited centralized governance |
| Copilot Business | Organizations | Admin-managed seats and policies | Designed for business control, privacy expectations, and policy enforcement |
| Copilot Enterprise | Enterprises using GitHub at scale | Enterprise/org-level management plus deeper GitHub.com context features | Adds enterprise-oriented GitHub.com and repository knowledge capabilities where enabled |
Notes and examples
Business vs Enterprise exam cues
| If the scenario says… | Prefer… | Reason |
|---|---|---|
| “An organization needs centralized seat assignment and policy control” | Copilot Business or Enterprise | Admin governance, not personal subscription |
| “Developers need Copilot experiences integrated with GitHub.com and enterprise repository knowledge” | Copilot Enterprise | Enterprise-level GitHub context features |
| “A single developer wants suggestions in an IDE” | Personal plan or assigned business seat | Depends on whether use is personal or organization-managed |
| “Company policy must block matching public-code suggestions” | Organization/enterprise policy | Centralized setting is the governance answer |
| “Sensitive files must not be used as Copilot context” | Content exclusions | Exclusion controls context sent to Copilot, not repository access |
Core terminology
| Term | Meaning | GH-300 reminder |
|---|---|---|
| Prompt | User instruction or question to Copilot | Better prompts produce better, more constrained output |
| Context | Code, comments, selected text, open files, repo data, or chat references Copilot can use | Wrong or insufficient context causes poor answers |
| Inline suggestion | Code completion generated while editing | Best for local implementation flow |
| Copilot Chat | Conversational interface for coding questions and tasks | Good for explanation, refactoring, tests, debugging |
| Completion | Suggested code or text output | Must be reviewed before acceptance |
| Hallucination | Plausible but false output | Verify APIs, commands, security claims, and dependencies |
| Public-code matching | Detection of suggestions that match public code | Blocking reduces risk of accepting matching public snippets |
| Content exclusion | Admin/user-configured exclusion of specified content from Copilot context where supported | Not the same as access control or secret scanning |
| Seat assignment | Admin grants Copilot access to users | User still needs correct IDE/auth setup |
| Responsible AI | Using AI with human oversight, fairness, privacy, security, and accountability | “Copilot said so” is never sufficient validation |
| User engagement data | Usage/interaction data about Copilot use | Different from source code content; know the distinction |
| Prompt injection | Malicious or misleading instructions embedded in content | Treat untrusted instructions in issues, docs, or comments carefully |
Prompting quick reference
Strong prompt pattern
Use this structure when asking Copilot Chat for substantial work:
Goal: What you want built, changed, explained, or tested.
Context: Relevant files, selected code, framework, language, versions, constraints.
Requirements: Behavior, edge cases, performance, security, style, compatibility.
Output format: Code only, step-by-step explanation, test cases, checklist, diff-style plan.
Validation: Ask for risks, assumptions, and how to test the result.
Notes and examples
Prompt improvement examples
| Weak prompt | Stronger prompt | Why stronger |
|---|---|---|
| “Fix this” | “Explain why this Python function fails for an empty list, then provide a minimal fix and two pytest cases.” | Includes language, failure condition, output, validation |
| “Write tests” | “Generate Jest tests for calculateDiscount. Cover zero quantity, expired coupon, maximum discount, and invalid input. Follow the style in this test file.” | Defines framework, function, edge cases, style |
| “Make it secure” | “Review this Express route for injection, authz, input validation, and error disclosure. Return prioritized findings and patched code.” | Names security categories and expected output |
| “Refactor” | “Refactor this method to reduce duplication without changing public behavior. Keep method names stable and list any assumptions.” | Prevents unwanted API changes |
| “Explain repo” | “Using the selected files, explain request flow from controller to database. Include key classes and where validation occurs.” | Narrows scope and requested structure |
Inline completion prompting
For code completion, comments and naming often matter more than long chat prompts.
## Create a function that validates a password.
## Requirements:
## - at least 12 characters
## - at least one uppercase letter
## - at least one lowercase letter
## - at least one digit
## - at least one symbol
## Return True or False; do not raise exceptions.
def is_valid_password(password: str) -> bool:
| To improve inline suggestions | Do this |
|---|---|
| Ambiguous output | Add a precise function name and docstring/comment |
| Wrong framework | Open nearby files using the correct framework |
| Wrong style | Provide examples in the same file |
| Missing edge cases | List edge cases before the function |
| Unsafe implementation | Add explicit security constraints |
Context rules and decision points
| Context source | How it helps | Risk or limitation |
|---|---|---|
| Current file | Strong signal for inline completions | May overfit to local mistakes |
| Open tabs / workspace context | Helps follow project patterns | Feature support varies by IDE/surface |
| Selected code | Best way to focus Copilot Chat | Selection may omit required dependencies |
| Comments and docstrings | Guide intent | Bad comments produce bad code |
| Test files | Teach expected behavior and style | Weak tests can reinforce bugs |
| Repository context on GitHub.com | Helps with repo-aware answers where supported | Depends on permissions, indexing, plan, and exclusions |
| Terminal output | Useful for debugging | Logs may contain secrets or private data |
| Issues/PR descriptions | Useful for intent | Treat untrusted text as potentially misleading |
Notes and examples
High-yield context traps
| Trap | Correct understanding |
|---|---|
| “Copilot knows my whole codebase automatically” | It uses available context, which depends on surface, permissions, feature support, and exclusions |
| “More context is always better” | Relevant context is better; unrelated files can degrade answers |
| “Content exclusion removes repository access” | It limits Copilot context; it is not repository authorization |
| “Copilot output is verified because it compiles” | Compilation does not prove correctness, security, licensing, or maintainability |
| “Chat can safely process any log” | Logs may contain secrets, tokens, customer data, or internal URLs |
Admin and governance reference
| Admin task | Where it belongs | What to remember |
|---|---|---|
| Assign Copilot access | Organization or enterprise administration | A license/seat must be assigned before use |
| Configure public-code matching policy | Copilot policy settings | Common answer for reducing matched public-code suggestions |
| Configure content exclusions | Organization/enterprise/repository-related settings where supported | Prevents selected content from being used as Copilot context |
| Enable or restrict features | Admin policy controls | Feature availability may depend on plan and policy |
| Manage user access at scale | Teams, organizations, enterprise accounts | Prefer centralized controls for business scenarios |
| Review usage/adoption | Admin reporting where available | Usage metrics are not code quality metrics |
| Educate developers | Internal secure AI guidelines | Governance includes human process, not only settings |
Notes and examples
Governance decision table
| Requirement | Best control | Not enough by itself |
|---|---|---|
| Prevent Copilot from using sensitive paths as context | Content exclusions | Telling users “be careful” |
| Reduce chance of accepting public-code matches | Block matching public-code suggestions | Manual review only |
| Keep Copilot use limited to approved users | Seat assignment and access policies | IDE extension installation alone |
| Protect secrets in repositories | Secret scanning and secure SDLC controls | Copilot policy alone |
| Detect vulnerable dependencies | Dependabot/dependency review/security tooling | Asking Copilot if dependencies are safe |
| Enforce code quality | Code review, tests, branch protections, CI | Accepting Copilot suggestions without review |
| Standardize acceptable AI use | Organization policy and training | Individual preference settings |
Privacy, security, and responsible AI
Privacy and data handling distinctions
| Concept | What it means | Exam reminder |
|---|---|---|
| Prompt | The instruction and context sent to Copilot | Do not include secrets or unnecessary sensitive data |
| Suggestion | Copilot-generated output | Review before accepting |
| Accepted code | Code the developer commits | The organization is responsible for it |
| Business/Enterprise protection | Organization-oriented data handling and admin controls | Prefer these in company governance scenarios |
| Public-code matching setting | Allows or blocks suggestions detected as matching public code | It is not a full license-compliance system |
| Content exclusion | Excludes configured content from Copilot context where supported | It is not retroactive code removal from all systems |
| Feedback | User feedback about suggestions | Can be separate from source code content |
Notes and examples
Responsible use checklist
Before accepting Copilot output, verify:
- Correctness against requirements, not just syntax.
- Security: authn/authz, validation, injection, error handling, secrets, crypto misuse.
- Licensing and provenance concerns for substantial or matching code.
- Maintainability: readability, project conventions, dependency choices.
- Test coverage: positive, negative, edge, regression, and failure paths.
- Performance and scalability assumptions.
- Accessibility and internationalization where relevant.
- Whether generated comments accurately describe the code.
Security review prompts
Review the selected code for security issues.
Focus on input validation, authorization, injection, secret exposure,
error handling, insecure dependencies, and unsafe defaults.
Return findings with severity, evidence, and a safer code example.
Threat-model this API endpoint.
List assets, trust boundaries, likely attacker goals, abuse cases,
required controls, and test cases to verify the controls.
Security and privacy review
GH-300 candidates should be ready to identify safer Copilot usage patterns.
Sensitive data rules
Do not paste or prompt with:
- API keys, tokens, passwords, private keys, or certificates.
- Customer personal data unless explicitly approved and handled under policy.
- Unapproved proprietary code, internal incidents, legal documents, or confidential business plans.
- Vulnerability details that your organization restricts from external tools.
- Any content your organization has excluded from Copilot use.
Security checks to apply to generated code
| Check | Questions to ask |
|---|---|
| Authentication | Does the code correctly verify identity? |
| Authorization | Does it enforce who can perform the action? |
| Input validation | Are untrusted inputs validated or safely parsed? |
| Injection resistance | Are SQL, command, template, path, and LDAP injection risks controlled? |
| Secrets handling | Are secrets avoided in code, logs, tests, and prompts? |
| Error handling | Does the code avoid leaking sensitive details? |
| Dependencies | Are packages necessary, reputable, and maintained? |
| Cryptography | Does it use standard libraries and safe defaults? |
| Logging | Does it avoid logging credentials or personal data? |
| Performance | Could generated code create excessive queries, loops, or memory use? |
Public-code matching and content exclusions
| Control | Purpose | Trap |
|---|---|---|
| Suggestions matching public code setting/filter | Helps manage suggestions that may match public code | It is not a legal opinion or complete license review |
| Content exclusions | Prevents specified content from being used as Copilot context where the feature supports exclusions | It is not a substitute for user judgment or a full data-loss prevention program |
| Organization/enterprise policy | Enforces approved usage at scale | Personal preferences may not override organization policy |
| Security scanning tools | Detect classes of vulnerabilities or secrets | Copilot is not a replacement for CodeQL, secret scanning, dependency review, or human review |
Developer workflow reference
| Workflow | Effective Copilot use | Validation step |
|---|---|---|
| New function | Provide signature, requirements, edge cases, style constraints | Run tests and inspect edge handling |
| API integration | Provide endpoint contract, auth method, error model, retry expectations | Verify with official API docs |
| Refactoring | Ask for behavior-preserving change and list assumptions | Compare tests before/after |
| Debugging | Provide exact error, stack trace, relevant code, recent changes | Reproduce and confirm root cause |
| Documentation | Ask for concise docs based on actual code | Ensure docs do not invent behavior |
| Code explanation | Select code and ask for flow, dependencies, side effects | Confirm against source |
| Performance improvement | Ask for bottleneck hypotheses and measurement plan | Benchmark before changing |
| Test generation | Provide requirements and edge cases | Ensure tests can fail for wrong behavior |
| PR support | Use summaries and review assistance where available | Human reviewer remains accountable |
| CLI command help | Ask for command and explanation | Inspect flags before execution |
Notes and examples
Implementing a feature
- Ask Copilot to summarize the relevant existing code.
- Provide the requirement and constraints.
- Request a small implementation plan.
- Generate or edit one focused section at a time.
- Ask for tests and edge cases.
- Run tests and linters.
- Review for security, maintainability, and policy compliance.
- Open a PR with a clear human-written summary, optionally assisted by Copilot.
Debugging
Use Copilot to:
- Explain a stack trace.
- Identify likely root causes.
- Compare expected and actual behavior.
- Suggest logging or test cases.
- Propose a minimal fix.
Do not use Copilot as the final authority. Reproduce the bug, validate the fix, and add a regression test.
Refactoring
Good refactoring prompts include:
- “Preserve public behavior.”
- “Keep the same function signature.”
- “Do not introduce new dependencies.”
- “Follow the style already used in this file.”
- “Add tests or explain which existing tests should cover this.”
Avoid large, unreviewable rewrites unless the scenario explicitly calls for them.
Documentation
Copilot can help create:
- Function comments.
- README sections.
- API usage examples.
- Migration notes.
- PR descriptions.
- Developer onboarding notes.
Always verify that generated documentation matches actual behavior.
Testing with GitHub Copilot
Test-generation decision table
| Goal | Prompt Copilot with | Watch for |
|---|---|---|
| Unit tests | Function/class, expected behavior, test framework | Tests that mirror implementation bugs |
| Regression tests | Bug description, failing input, expected output | Test that passes without catching the bug |
| Edge cases | Boundaries, null/empty, invalid input, limits | Missing negative cases |
| Mocking | External services, expected calls, failure modes | Over-mocking internal behavior |
| Integration tests | Components, environment assumptions, database/API setup | Flaky tests and hidden dependencies |
| Security tests | Abuse cases, injection payloads, authz scenarios | Unsafe payload handling in test logs |
| Property-style tests | Invariants and valid input ranges | Too broad or impractical generated data |
Notes and examples
Better test prompt
Generate pytest tests for `normalize_username`.
Requirements:
- trim surrounding whitespace
- lowercase ASCII letters
- reject empty result
- reject names longer than 30 characters
- preserve digits, hyphen, and underscore
Include positive, negative, and boundary cases.
Do not change production code.
Testing traps
| Trap | Correct action |
|---|---|
| Copilot generated many tests, so coverage is adequate | Review assertions and map tests to requirements |
| Tests pass, so code is secure | Add security-focused tests and review |
| Generated mocks are fine by default | Ensure mocks represent real service behavior |
| Copilot can infer all edge cases | Provide known edge cases explicitly |
| Snapshot tests prove behavior | Confirm snapshots capture meaningful output |
Testing with Copilot
Copilot is useful for testing, but generated tests need the same scrutiny as generated production code.
| Testing task | How Copilot helps | Candidate mistake to avoid |
|---|---|---|
| Generate unit tests | Creates test cases from function behavior and examples | Only testing the happy path |
| Add edge cases | Suggests null, empty, boundary, invalid, permission, timeout, and error cases | Accepting irrelevant edge cases without understanding requirements |
| Explain failing tests | Helps interpret error messages and likely causes | Treating the explanation as proof |
| Create mocks | Drafts mocks for services, APIs, databases, or filesystem calls | Over-mocking so the test no longer validates real behavior |
| Refactor tests | Improves readability and removes duplication | Changing test meaning accidentally |
| Improve coverage | Identifies untested branches | Confusing coverage with correctness |
| Test-driven development | Drafts tests before implementation | Letting generated tests define requirements without review |
Testing decision rules
- If Copilot writes implementation code, ask for tests that check requirements, not just the implementation.
- If Copilot writes tests, inspect assertions carefully.
- If a test passes too easily, check whether it actually fails for the wrong behavior.
- Prefer clear tests with meaningful names over clever generated test code.
- Run the tests locally or in CI; do not rely on Copilot’s explanation alone.
GitHub Copilot in the CLI
Use Copilot CLI assistance for command suggestions and explanations, especially when the task is command-line focused.
gh extension install github/gh-copilot
gh copilot suggest "find large files in this repository"
gh copilot explain "git reset --soft HEAD~1"
| CLI scenario | Good practice |
|---|---|
| Command may delete, overwrite, or publish data | Ask for explanation before running |
| Command includes secrets or tokens | Do not paste the secret; replace with placeholders |
| Command uses production resources | Verify flags, target, and environment |
| Command is unfamiliar | Ask Copilot to explain each option |
| Command came from generated output | Cross-check with official tool help or documentation |
IDE and feature troubleshooting
| Symptom | Likely cause | Practical response |
|---|---|---|
| No suggestions appear | Not signed in, no assigned seat, extension missing, unsupported file, policy disabled | Verify authentication, license, extension, policy, file type |
| Chat unavailable | Plan/policy/IDE support issue | Check feature enablement and supported surface |
| Suggestions are irrelevant | Poor context, wrong open files, vague comments, generated code drift | Add precise comments, open relevant files, select code |
| Copilot ignores repository files | Repo context not available, permissions missing, content excluded, feature unsupported | Confirm permissions, surface, and exclusions |
| Suggestions stopped in one file | File may be excluded, too noisy, unsupported, or policy-restricted | Try another file and check exclusion policy |
| Authentication loops | IDE/GitHub auth state or SSO issue | Reauthenticate and confirm org access |
| Slow responses | Network/proxy/service/extension issue | Check connectivity, update extension, retry later |
| Unsafe-looking code | Model output issue or weak prompt | Reject, refine prompt, run security review |
| Public-code match warning/block | Matching filter policy triggered | Use another approach or write original code |
| Copilot suggests deprecated API | Model/context limitation | Verify against current docs |
Common GH-300 traps
| Exam statement | Best response |
|---|---|
| “Copilot replaces code review” | False. Human review remains required |
| “Generated code is automatically secure” | False. Review and test security |
| “Content exclusions are the same as repository permissions” | False. Exclusions control Copilot context |
| “Blocking public-code matches guarantees license compliance” | False. It reduces one risk but does not replace legal review |
| “Business use should rely on each user’s personal settings” | Usually false. Use centralized policies |
| “Copilot can only write new code” | False. It can explain, test, refactor, debug, document, and assist CLI work |
| “A vague prompt is fine because Copilot infers everything” | False. Specific context and constraints improve output |
| “Passing tests prove Copilot’s answer is correct” | Not necessarily. Tests may be incomplete or generated from the same flawed assumptions |
| “It is safe to paste production logs into chat” | Only after removing secrets and sensitive data |
| “Copilot Chat always has full repository knowledge” | False. Context depends on product surface, permissions, plan, indexing, and exclusions |
Quick prompt recipes
Explain code
Explain the selected code for a new maintainer.
Cover purpose, inputs, outputs, side effects, dependencies,
error handling, and any risky assumptions.
Refactor safely
Refactor the selected code to reduce duplication and improve readability.
Do not change public behavior, function names, return types, or error semantics.
List assumptions and recommend tests to run.
Generate tests
Create unit tests for the selected function using the existing project test style.
Include normal cases, edge cases, invalid input, and one regression test
for the described bug. Explain why each test matters.
Debug
Given this error and selected code, identify the most likely root cause.
Provide a minimal fix, explain why it works, and list how to verify it.
Secure coding review
Review this code for security issues.
Prioritize findings by severity and exploitability.
Provide safer code only where a concrete issue exists.
Last-minute checklist
- Know when to use inline suggestions, Copilot Chat, GitHub.com features, and CLI assistance.
- Distinguish personal Copilot use from Copilot Business or Enterprise governance.
- Understand seat assignment, policy controls, public-code matching, and content exclusions.
- Remember that context quality drives answer quality.
- Use prompts with goal, context, constraints, output format, and validation.
- Treat generated code as a draft requiring review, tests, and security checks.
- Do not paste secrets, private customer data, or unnecessary sensitive logs.
- Validate commands before running them, especially destructive CLI commands.
- For business scenarios, choose centralized admin controls over individual preferences.
- For testing scenarios, ensure generated tests map to requirements and edge cases.
Notes and examples
Last-hour checklist
Before you move to practice questions, make sure you can answer these quickly:
- What is the difference between code completions, chat, inline edits, CLI assistance, and PR assistance?
- What context can influence a Copilot response?
- What makes a prompt strong?
- Why must generated code be reviewed and tested?
- How can Copilot help with testing without replacing test design?
- What should a developer avoid putting into prompts?
- What are content exclusions used for?
- What is the purpose of suggestions matching public code controls?
- How do organization or enterprise policies affect individual users?
- Which scenarios require GitHub Actions, CodeQL, Dependabot, or secret scanning instead of Copilot?
- What is the safest response when Copilot output is plausible but unverified?
High-yield exam map
| Area | What to know quickly | Common exam trap |
|---|---|---|
| Copilot capabilities | Code completions, chat, inline edits, CLI help, PR assistance, GitHub.com and IDE workflows where enabled | Treating Copilot as one single feature instead of a set of surfaces |
| Context | Copilot uses available context such as nearby code, open files, selected text, repository/workspace context, chat history, and prompt details depending on feature and settings | Assuming Copilot automatically understands every file, system, policy, or business rule |
| Prompting | Good prompts include goal, context, constraints, examples, expected format, and edge cases | Asking vague questions and blaming Copilot instead of refining context |
| Responsible AI | Suggestions may be incorrect, insecure, outdated, biased, or noncompliant; humans must review and validate | Accepting generated code without tests, review, or security checks |
| Testing | Copilot can help create, explain, and improve tests, but tests must verify real requirements | Letting Copilot write tests that simply mirror a buggy implementation |
| Privacy and IP | Do not paste secrets or unapproved sensitive data; understand plan-specific controls, public-code matching, and content exclusions | Believing a filter or exclusion is a complete legal, privacy, or DLP solution |
| Administration | Organization and enterprise controls manage access, policies, feature availability, and governance | Assuming an individual user setting overrides organization policy |
| Adjacent GitHub tools | Copilot assists development; GitHub Actions, CodeQL, Dependabot, secret scanning, and PR review solve different problems | Choosing Copilot when the scenario asks for CI/CD, vulnerability scanning, or dependency remediation |
Core mental model
For GH-300, think of GitHub Copilot as an AI coding assistant that improves productivity when the user gives useful context and validates the output.
- Define the development goal.
- Provide relevant context.
- Ask Copilot for a suggestion, explanation, edit, command, or test.
- Review the result critically.
- Run tests, linters, security tools, and human review.
- Iterate or reject the suggestion when it is not correct.
flowchart TD
A[Developer goal] --> B[Relevant context]
B --> C[Prompt, comment, selection, or chat]
C --> D[Copilot suggestion]
D --> E{Correct, safe, and policy-compliant?}
E -- No --> F[Refine prompt, add context, or edit manually]
F --> C
E -- Yes --> G[Run tests, review, and security checks]
G --> H[Commit or open PR]
H --> I[Human review and CI validation]
Copilot surfaces to distinguish
| Surface | Best used for | What to remember for exam questions |
|---|---|---|
| Code completions | Inline code suggestions while editing | Suggestions are influenced by nearby code, comments, names, and file context |
| Copilot Chat in IDE | Explaining code, generating snippets, debugging, refactoring, test help | Better questions produce better answers; verify all generated code |
| Inline chat / edits | Changing selected code, refactoring, adding comments, converting patterns | Selection matters; Copilot acts on the code you give it |
| Workspace or repository-aware chat, where available | Asking about project structure, dependencies, or code relationships | Repository context helps, but it is not the same as guaranteed full-system understanding |
| GitHub.com Copilot features | Explaining code, working with issues or pull requests, summaries, and reviews where enabled | Copilot can assist review workflows but does not replace maintainers |
| Copilot in the CLI | Suggesting or explaining shell, Git, and GitHub CLI commands | The user should review commands before execution |
| PR summaries and review assistance | Drafting summaries, identifying possible issues, improving reviewer efficiency | Generated summaries and comments still need human judgment |
| Extensions or integrations, where enabled | Connecting Copilot to approved external systems or specialized tools | Check governance and data-sharing implications before using third-party extensions |
How Copilot uses context
Copilot does not simply “know what you mean.” It generates responses based on the prompt and available context.
High-yield context sources
| Context source | Example | Why it matters |
|---|---|---|
| Nearby code | Function names, imports, comments, existing patterns | Helps Copilot match local style and APIs |
| Open files or selected code | A selected function or test file | Focuses the response on the exact code under discussion |
| File names and project structure | models/user.py, auth.service.ts | Gives clues about architecture and intent |
| Natural-language comments | // Validate JWT and return claims | Comments can steer completions |
| Chat history | Previous instructions or constraints | Later responses may rely on earlier conversation |
| Repository/workspace context, where available | Cross-file references and project conventions | Useful for larger-codebase questions |
| Organization policies and exclusions | Repositories or paths excluded from Copilot context | Limits what Copilot can use as context |
Notes and examples
Context traps
- More context is not always better. Relevant context is better.
- Copilot may invent APIs, parameters, dependencies, or configuration names.
- Copilot may miss hidden business rules not present in code or prompts.
- A generated answer can be syntactically correct but semantically wrong.
- If a file, path, or repository is excluded from Copilot context, Copilot may not be able to use that content to answer.
- If a user manually pastes sensitive content into a prompt, technical exclusions may not protect that action.
Prompting decision rules
Strong GH-300 answers usually favor prompts that are specific, contextual, constrained, and verifiable.
Good prompt structure
Use this pattern:
- Goal — What should Copilot produce?
- Context — What code, framework, file, API, or business rule matters?
- Constraints — Performance, security, style, compatibility, dependencies.
- Examples — Input/output examples, edge cases, existing patterns.
- Output format — Code only, table, steps, tests, patch, explanation.
- Validation request — Ask for risks, assumptions, or test cases.
Weak vs strong prompts
| Weak prompt | Stronger prompt |
|---|---|
| “Fix this.” | “Refactor the selected function to handle null input, preserve the existing return type, and avoid changing public behavior. Explain any assumptions.” |
| “Write tests.” | “Generate unit tests for this function covering valid input, empty input, invalid IDs, and permission errors. Use the existing test style in this file.” |
| “Make it secure.” | “Review the selected Express route for authentication, authorization, input validation, SQL injection, and secret-handling issues. Suggest minimal code changes.” |
| “Explain repo.” | “Summarize how requests flow from the API route to the service and database layer. Include key files and unresolved assumptions.” |
| “Create command.” | “Suggest a Git command to undo the last commit while keeping changes in the working tree. Explain before running.” |
Exam-friendly prompting principles
- Ask Copilot to explain before changing when the code is unfamiliar.
- Ask for small, reviewable changes rather than broad rewrites.
- Provide language, framework, version, and dependency constraints when relevant.
- Ask for edge cases and tests after generating implementation code.
- Ask Copilot to list assumptions when requirements are incomplete.
- Treat Copilot as an assistant, not as an authority.
Responsible AI and validation
GitHub Copilot can improve speed, but professional use requires human oversight.
| Risk | What can happen | Better practice |
|---|---|---|
| Hallucinated APIs | Copilot suggests nonexistent methods or packages | Check docs, imports, builds, and tests |
| Insecure code | Weak validation, injection risk, poor crypto, exposed secrets | Review with secure coding practices and security tools |
| License/IP uncertainty | Suggested code may resemble public patterns | Use public-code matching controls where appropriate and follow organization policy |
| Outdated assumptions | Generated output uses deprecated syntax or old APIs | Confirm version-specific behavior |
| Business-rule gaps | Code passes syntax but violates requirements | Add requirement-specific tests and human review |
| Overconfidence | Candidate assumes generated answer is complete | Ask for limitations, then verify independently |
| Sensitive data exposure | User pastes secrets, credentials, customer data, or private policy text into prompts | Do not provide unapproved sensitive data; use approved workflows |
Notes and examples
High-yield responsible-use statement
For exam questions, the best answer is usually the one that keeps a human in the loop: review the suggestion, test it, scan it if appropriate, and ensure it follows security, privacy, license, and organizational requirements.
Administration and governance
For organization-managed Copilot usage, know the difference between user productivity features and administrative controls.
| Administrative concern | Typical action |
|---|---|
| Access | Assign or remove Copilot access for users or groups according to the organization’s plan and policy |
| Feature availability | Enable, disable, or configure features based on organization requirements |
| Policy enforcement | Apply organization or enterprise settings rather than relying on individual behavior |
| Content exclusions | Exclude selected repositories, paths, or files from Copilot context where supported |
| Public-code suggestion policy | Configure how suggestions matching public code are handled |
| Usage visibility | Review adoption or usage information for governance and rollout decisions |
| Onboarding | Provide approved IDE setup, CLI setup, prompt guidance, security rules, and escalation paths |
| Compliance alignment | Ensure use follows internal policy, contractual obligations, and data-handling rules |
Notes and examples
Admin traps
- Installing an IDE extension is not enough if the user is not authenticated and licensed.
- A repository maintainer may not have the same authority as an organization or enterprise administrator.
- A user-level preference may be overridden by organization policy.
- Usage metrics show adoption, not code quality or security.
- Content exclusions reduce available context; they do not make unsafe prompts safe.
- Plan features and controls can vary, so exam answers should respect the plan or policy described in the question.
Copilot versus adjacent GitHub tools
Many GH-300 questions are easier if you identify the real need.
| Need | Better fit | Why |
|---|---|---|
| Generate or explain code | GitHub Copilot | AI coding assistance |
| Run builds and tests on push or PR | GitHub Actions | CI/CD automation |
| Find code vulnerabilities with static analysis | CodeQL / code scanning | Security analysis, not code generation |
| Detect committed credentials | Secret scanning | Secret detection workflow |
| Update vulnerable or outdated dependencies | Dependabot | Dependency alerts and update PRs |
| Develop in a cloud-hosted environment | GitHub Codespaces | Development environment |
| Review a pull request for correctness | Human reviewers, CI, and optional Copilot assistance | Accountability remains with maintainers |
| Manage repository permissions | GitHub repository/org settings | Access control, not Copilot prompting |
| Explain a shell or Git command | Copilot in the CLI, where enabled | Command assistance with user review |
Scenario decision table
| If the question says… | Prefer an answer that… | Avoid an answer that… |
|---|---|---|
| “Copilot generated insecure code” | Reviews, edits, tests, and scans the code | Accepts the code because Copilot suggested it |
| “The prompt returns irrelevant output” | Adds context, narrows scope, provides examples, or selects code | Repeats the same vague prompt |
| “A team handles confidential data” | Follows policy, avoids sensitive prompts, configures admin controls and exclusions | Pastes secrets or customer data into chat |
| “Need to know whether generated code is legally safe” | Uses organization policy, review, and public-code matching controls as appropriate | Claims Copilot guarantees license compliance |
| “Need to create a Git command” | Uses Copilot CLI help and reviews before executing | Runs a generated destructive command blindly |
| “Need to test a new function” | Generates tests for normal, boundary, invalid, and error cases | Tests only the exact implementation path |
| “Need to understand a large repo” | Uses repository/workspace context where available and verifies assumptions | Assumes Copilot has perfect full-repo knowledge |
| “Need governance for many developers” | Uses organization or enterprise policies and seat management | Relies only on individual developer settings |
| “Need vulnerability detection” | Uses security tools and review, with Copilot as assistance | Treats Copilot as a complete scanner |
| “Need CI on every PR” | Uses GitHub Actions | Uses Copilot alone |
Common candidate mistakes
- Confusing Copilot assistance with automated validation.
- Forgetting that generated code can be wrong even when it looks polished.
- Choosing the most productive answer instead of the safest professional answer.
- Treating public-code matching as a complete license solution.
- Treating content exclusions as a complete data-loss prevention system.
- Ignoring organization-level controls in Business or Enterprise scenarios.
- Assuming Copilot can see all files, all history, all issues, and all private knowledge automatically.
- Overlooking the user’s responsibility to review commands before execution.
- Letting Copilot-generated tests define the requirements.
- Selecting Copilot when the better GitHub tool is Actions, CodeQL, Dependabot, or secret scanning.
Practice plan
Use this Cheat Sheet first, then move into IT Mastery practice:
- Topic drills — Start with Copilot features, context, prompting, privacy, testing, and administration.
- Original practice questions — Focus on scenario wording and decision points, not memorization.
- Detailed explanations — Review why the correct answer is safer or more complete than the distractors.
- Mock exam — Practice pacing and mixed-topic recognition.
- Error log — Track whether you missed questions because of product knowledge, privacy assumptions, tool confusion, or weak prompt reasoning.
Next step: take a focused GH-300 question bank drill on Copilot workflows and privacy controls, then review the detailed explanations for every missed or guessed question.