Back to exam

GH-300 Cheatsheet

GitHub Copilot

Download free PDF

Use GitHub Copilot responsibly (15–20 %)

Responsible AI principles

  • **Fairness** addresses unjust differences in treatment or outcomes. Use representative data, fairness measures and ongoing human review to detect and reduce bias.
  • **Inclusiveness** considers people with different abilities, backgrounds and needs. Accessibility contributes to inclusion; it does not by itself eliminate model bias.
  • **Reliability and safety** require predictable behavior under expected conditions and safeguards for failures. **Privacy and security** protect data, identities and systems from exposure or misuse.
  • **Transparency** explains capabilities, limitations and how AI contributes to a result. **Accountability** keeps people responsible for decisions, oversight and remediation.

Risks and human validation

  • **Generative AI** predicts plausible output from learned patterns. Incomplete context, biased data and outdated examples can produce confident errors, deprecated APIs or insecure code.
  • Treat suggestions as **candidate code**. Inspect logic, dependencies and error handling; run builds, tests, linters and security checks before integrating changes.
  • Validate **mathematics and statistics** independently: formulas, units, assumptions, numerical stability and dataset suitability. A fluent explanation does not establish a correct computation.
  • **Human oversight** remains necessary for requirements, design trade-offs, licensing and release decisions. Copilot assistance does not certify correctness, compliance or security.

Use GitHub Copilot features (25–30 %)

Plans, access and billing

  • A **personal subscription** serves an individual developer. **Copilot Business** provides centrally managed seats, policies and organizational controls. **Copilot Enterprise** adds enterprise capabilities; verify each feature's plan and client support.
  • **Repository hosting** and Copilot licensing are separate decisions. IDE assistance can work with code hosted outside GitHub, including Azure DevOps or Bitbucket; migrating code is not inherently required.
  • For company adoption, evaluate **central administration**, identity-provider integration, data controls and required features. A personal plan does not supply organization-wide governance.
  • Personal subscriptions can use **monthly or annual billing**. Free access for qualifying students, teachers or maintainers depends on eligibility; working on any open-source project does not automatically qualify.

IDE completions and Chat

  • **Inline suggestions** appear as you type and can span multiple lines. Accept, dismiss, cycle alternatives or accept part of a suggestion using the editor's supported shortcuts; a completions panel can show alternatives.
  • **Chat** supports questions, explanations and planning before coding. **Inline Chat** targets selected code in place. **Edit** workflows propose changes across chosen files; **agent mode** can coordinate edits and tools with permissions.
  • Common IDE commands include **/explain** for understanding, **/fix** for proposed corrections and **/tests** for test generation. **/optimize** in supported Visual Studio experiences asks for performance improvements. Command availability varies by client.
  • Enable the supported **Copilot extension**, sign in with the licensed account and check organization policy. Feature parity is not guaranteed across VS Code, Visual Studio, JetBrains, Vim/Neovim and other clients.
  • Use **response feedback** controls in the IDE or GitHub Mobile to flag poor answers. Include a concise description of the issue without exposing confidential code or personal data.

Organization governance and metrics

  • Configure **Copilot policies** in organization or enterprise settings. Enterprise-enforced choices constrain downstream settings; users cannot bypass an enforced policy by changing local preferences.
  • Use **subscription REST APIs** to inspect seats and billing summaries and add or remove eligible users or teams. A seat assignment grants Copilot access; it does not independently grant repository access.
  • **Usage metrics** describe adoption and supported suggestion or Chat activity, often broken down by language or editor. Acceptance counts and rates are indicators, not proof of code quality or individual productivity.
  • **Audit logs** record administrative events such as seat, policy and content-exclusion changes. Find them in organization settings; distinguish configuration history from aggregate usage metrics and generated-code content.

CLI installation, sessions and trust

  • Install **Copilot CLI** on Windows with **winget install GitHub.Copilot**. From the project root, run **copilot** to start an interactive session; complete sign-in when prompted and confirm access to the intended folder.
  • Use **copilot --resume** to choose a saved session and **copilot --continue** to reopen the most recent session. Resuming restores context; begin a new session when that history would be irrelevant.
  • During a session, **/add-dir /repo/tests** adds that directory to allowed file access. **--add-dir** supplies a directory at startup. Directory access and permission to execute particular tools are separate controls.
  • The **gh-copilot extension** uses **gh copilot suggest**, **gh copilot explain** and **gh copilot config**. Its configuration includes usage analytics and execution confirmation. It is distinct from the interactive **copilot** application; review commands before running them.

Repository knowledge and pull requests

  • **Knowledge bases** grouped selected repository documentation for Enterprise Chat. **Copilot Spaces** replaced that feature and organize task context. Curated context is not automatic access to every repository or file type.
  • Repository-aware questions can use relevant **documentation**, code examples and design guidance available to the user. Retrieval adds context to a request; it is different from training or fine-tuning a model on organization patterns.
  • **Pull request summaries** describe key changes. Chat and code review can help explain a diff or propose improvements, but people and required checks still validate behavior and authorize merging.

Understand GitHub Copilot data and architecture (10–15 %)

Context to suggestion flow

  • A **prompt** combines the user's request with selected context. In an IDE this can include cursor position, surrounding code, selection, relevant open files and project information; it is not necessarily the whole repository.
  • **Pre-processing** assembles and enriches the request before model inference. Authorized retrieval or search can add information when available; external web search is not involved in every answer.
  • **Fill-In-the-Middle (FIM)** uses code before the cursor, the prefix, and code after it, the suffix, to generate a suitable middle segment.
  • The **service/proxy** mediates requests and applies supported safeguards. Model output passes applicable post-processing and policy checks before display; these checks do not prove compilation, correctness or safety.
  • **Inference** generates a response from model parameters and request context. It does not retrain the model in real time. Training, contextual retrieval and feedback collection serve different purposes.

Privacy, training and retention

  • Distinguish **prompts and suggestions** from **engagement data**, such as feature use and acceptance activity. Data transmission, storage, model training and usage reporting are separate questions.
  • **Business and Enterprise** customer data is not used to train AI models without customer authorization. Personal plans have a **model-training setting** that users can disable in Copilot settings.
  • **Retention** depends on the feature, plan and applicable terms. IDE completions and stored Chat/session history need not share one retention rule; a training opt-out does not by itself mean no data is processed or stored.

Apply prompt engineering and context crafting (10–15 %)

Clear prompts and examples

  • State the **goal**, language and framework, constraints, expected output and success criteria. Meaningful names and focused comments clarify intent better than vague requests to improve everything.
  • **Zero-shot prompting** gives instructions without demonstrations. **Few-shot prompting** supplies a small set of input/output examples that demonstrate the desired behavior, structure or style.
  • **Role prompting** supplies a relevant perspective, such as a security reviewer or language tutor. Specify the audience and desired explanation depth; a role does not confer authority or expertise.
  • Break a complex task into **bounded steps**. Inspect each result and refine the next request with concrete feedback, error messages or missing cases. Provide relevant documentation as accessible context rather than assuming a URL was read.

Select context and control history

  • Attach the **relevant files**, select the target function and open related implementation or test tabs. Include interface contracts and dependencies when the task crosses file boundaries.
  • Supported participants such as **@workspace** and context references such as **#file**, **#selection** or **#editors** help target information. Names and syntax depend on the IDE; these are context selectors, not access-control rules.
  • **Chat history** supplies conversational context for follow-up requests. Start a **new chat** or clear the conversation when changing tasks to prevent unrelated earlier instructions from shaping the response.
  • A fresh conversation removes the old thread from that conversation's prompt context; it does not erase training or disable active editor context. Supply the needed files and constraints again.

Improve developer productivity with GitHub Copilot (10–15 %)

SDLC, learning and documentation

  • During **requirements and design**, ask for requirement templates, acceptance criteria, design patterns and alternatives. Validate assumptions with stakeholders and fit choices to the actual architecture.
  • During **implementation**, generate repetitive scaffolding and small reusable functions from explicit contracts. IDE assistance reduces context switching while keeping code and explanations together.
  • For **onboarding and learning**, ask Chat to explain unfamiliar code, trace data flow or compare language idioms. Check explanations against the implementation and authoritative language documentation.
  • Generate **comments, docstrings and README sections** from code and intended behavior. Review for missing limitations, invented functionality and stale usage examples.

Refactoring and optimization

  • For **refactoring**, identify the target and desired quality: readability, maintainability, reduced duplication or simpler control flow. Preserve observable behavior and review the resulting diff.
  • For **modernization**, supply the target runtime and library versions. Copilot can suggest translations and modern patterns, but large codebases require dependency analysis and staged validation.
  • For **performance**, request alternative algorithms or data structures and discuss complexity. Benchmark representative workloads; a plausible optimization can change behavior or be slower in practice.

Unit tests, assertions and coverage

  • Provide the **implementation**, specification, test framework and representative tests. Ask **/tests** or Chat to generate unit tests consistent with company naming, setup and assertion conventions.
  • Request **normal, boundary and failure cases**: empty input, invalid values, exceptions and relevant dependencies. For integration or performance tests, state the environment and scenario explicitly.
  • Validate **assertions** against intended behavior, not only the current implementation. A generated test can reproduce the same misunderstanding as generated production code.
  • **Generating tests** is different from executing them. Run the suite, inspect failures and measure meaningful coverage; passing tests or a high coverage percentage do not establish complete correctness.

Sample data and security review

  • Generate **synthetic sample data** from schemas, API documentation and constraints. Ask for valid records and deliberate edge cases; check types, ranges, uniqueness and relationships.
  • Use fictional values instead of **personal data or secrets**. A request to generate sample records does not itself authorize database access, service creation or writes to production.
  • Ask Copilot to explain risks and propose **security fixes**, then verify with review, static analysis, dependency scanning and tests. Built-in safeguards can miss vulnerabilities and do not replace security tooling.

Configure privacy, content exclusions, and safeguards (10–15 %)

Content exclusion scope and effects

  • **Content exclusions** are administrative controls for Business and Enterprise organizations. Authorized repository, organization or enterprise administrators configure repository and path patterns, including files and folders.
  • In supported experiences, excluded files do not receive **inline suggestions**, and their contents are withheld from applicable context and review. Exclusions target paths, not selected lines within a file.
  • **.gitignore** controls Git tracking behavior and is not a substitute for Copilot content exclusions. A prompt reference such as **#file** also does not configure an exclusion policy.
  • Exclusions are a **guardrail**, not a filesystem security boundary. Indirect semantic information may still arrive through the IDE; symlinks, remote filesystems and third-party tools have limitations. Enforce sensitive-data access separately.

Public code filters and output review

  • The **Suggestions matching public code** setting controls duplicate detection. **Block** suppresses detected matches in supported products; administrators can enforce the policy centrally.
  • Matching checks compare suggestions with surrounding code of about **150 characters** against public GitHub code. This is not a complete license audit, vulnerability scan or comparison with all private repositories.
  • For applicable **IP protection commitments**, keep required mitigations, including public-code blocking, enabled and follow the relevant terms. A filter setting alone is not a blanket guarantee of protection.
  • **Toxicity filters** address harmful material such as hateful, discriminatory or sexually explicit content. They serve a different purpose from public-code matching; review outputs for quality, safety and licensing obligations.

Troubleshoot access and exclusions

  • When suggestions stop, check **network access**, sign-in, entitlement, extension status, editor settings and policy. Inspect the Copilot status indicator and diagnostic logs for the relevant reason.
  • For exclusion problems, verify the **licensed organization**, repository identity, matching path pattern and client support. Changes can take **up to 30 minutes** to propagate to already loaded IDE settings; reload them when needed.
  • Test with an **included file and an excluded file** after refreshing policy. Distinguish an intended exclusion from a general connectivity or authorization failure.