Skip to main content

Introduction

This cheat sheet summarizes key practices from the GitHub Copilot Playbook for .NET & Azure developers.

Foundations πŸ§ β€‹

  • πŸ’‘ Copilot is an assistant, not an authority

    • You own design, correctness, security, and compliance.
  • βœ… Use in supported environments

    • Visual Studio 2022 version 17.8 or later for C#/.NET and Azure projects.
    • VS Code for full-stack work (C#, TypeScript, Bicep/Terraform, YAML, etc.).
  • 🧰 Core capabilities

    • Inline completions, Chat, PR review, Copilot CLI, custom prompts, instructions, agents, and MCP-backed tools.

Copilot Modes (When to Use What) πŸŽ›οΈβ€‹

  • Ask (chat) – Questions, explanations, small suggestions.
  • Edit – Scoped changes to selected code or files; keep diffs small.
  • Plan – Larger work (migrations, new features, major refactors); get a step-by-step plan first.
  • Agent – Copilot Coding Agent or specialized agents to execute plans across files/tools; always tightly scope and review via PR.
  • Custom – Repo/org-specific prompts, instructions, and agents (including from awesome-copilot) for repeatable workflows.

βœ… Rule of thumb: Ask β†’ Plan β†’ Edit/Agent, always with human review and tests.


Choosing Models πŸ§ͺ​

  • GPT-5.1 (Preview) – Complex refactors, architecture, security-sensitive flows, large documentation.
  • GPT-4o – Fast, localized edits, prototypes, simple scripts, lightweight docs.
  • Coding-optimized variants (e.g., GPT-5.1 Codex) – Code-heavy work in one stack, stronger completions.
  • Reasoning-optimized models (e.g., Claude Sonnet 4.5, Claude Opus 4.5, Gemini 3 Pro) – Deep analysis of specs/logs, cross-system design, trade-off analysis.

πŸ“Š Check LiveBench and your org’s evaluations to keep defaults up to date.


High-Value Workflows πŸš€β€‹

  • πŸš€ Greenfield features

    • Clarify user story β†’ ask Copilot for design outline β†’ generate scaffolding β†’ refine β†’ review & test.
  • πŸ”§ Maintenance / refactors

    • Explain legacy code β†’ propose safer modern patterns (DI, async, logging) β†’ refactor in small steps β†’ run tests.
  • πŸ§ͺ Tests & automation

    • Generate xUnit/NUnit/MSTest, bUnit, and integration tests; you add edge cases and prune brittle tests.
  • πŸ“ Docs & knowledge capture

    • Use Copilot to write XML docs, architecture notes, and playbook updates close to the code.
    • GPT models are better for writing XML docs, while Claude models are better for writing Markdown files.
  • ☁️ Azure workflows

    • IaC (Bicep/Terraform/ARM), Azure Functions, CI/CD (GitHub Actions/Azure DevOps) with Copilot scaffolding followed by manual hardening.

Prompting Essentials βœοΈβ€‹

  • βœ… Good patterns

    • Role + context + constraints.
    • Step-by-step (outline first, then details).
    • Ask for specific formats (checklists, tables, PR descriptions).
  • ⚠️ Avoid

    • "Do everything" prompts that produce huge diffs.
    • Policies/legal text/compliance commitments from Copilot.
    • Suggestions that introduce secrets or personal data.

Context & Slash Commands πŸŽ―β€‹

  • Implicit context
    • Copilot pays extra attention to open tabs. Keep relevant files open and close noisy ones before asking for help.
  • Explicit context variables
    • @workspace – ask about the overall project/solution.
    • #file – point Copilot at a specific file.
    • #selection – focus on the currently selected code.
  • Slash commands (VS Code/VS)
    • /explain – explain selected code.
    • /fix – propose a fix for an error or warning.
    • /tests – generate tests for the selection.
    • /doc – generate documentation/comments.

Prompt Templates (Examples) πŸ§Ύβ€‹

  • New feature – Design + implement
    • "You are assisting with a .NET [app type] deployed to Azure [service]. I need to implement [feature]. Given these files [list], propose a design and then generate minimal code changes following our existing patterns, DI, async, and logging conventions."
  • Bug fix – Root cause + focused patch
    • "In this .NET [project type], observed behavior: [x], expected: [y]. Here is the relevant code: [files]. Identify likely root cause and propose a small, focused fix plus any missing tests."
  • Tests – Coverage you can trust
    • "Generate [xUnit/NUnit/MSTest] tests for this class. Cover happy path, validation failures, and key edge cases using Arrange-Act-Assert and clear test names."

Promote successful patterns into shared .prompt.md files under .github/prompts.


Safety & Responsible Use πŸ›‘οΈβ€‹

  • πŸ” Secrets & data

    • No passwords, connection strings, tokens, certificates, or real customer data in prompts.
    • Use Key Vault, managed identity, environment variables, and user secrets.
  • πŸ‘€ Human-in-the-loop

    • All Copilot-assisted changes go through normal design/code review and appropriate tests.
  • βœ… Quality & security

    • Run tests, linters, and security tools. Be extra careful with auth, crypto, input validation, data access, and infra.
  • βš–οΈ Bias & fairness

    • Avoid logic based on protected characteristics; test AI-influenced logic with diverse synthetic data.
  • πŸ”Œ MCP servers

    • MCP servers can execute code and access system resources, posing security risks if compromised.
    • Only use MCP servers from trusted sources and verify their code before installation.
    • Apply least-privilege principles and monitor MCP server activity for suspicious behavior.

Team Practices πŸ‘₯​

  • πŸ”Ž Code review with Copilot

    • Use Copilot to summarize PRs, suggest tests, and flag risky changesβ€”but reviewers remain accountable.
  • πŸ“¦ Shared assets

    • Store prompts, instructions, and agents in the repo (.github/prompts, .github/instructions, *.agent.md).
    • Reuse and adapt high-quality assets from awesome-copilot.
  • 🧭 Onboarding

    • Walk new devs through this cheat sheet, playbook, your Copilot instructions, prompts, agents, MCP setup, and review expectations.

Key External Resources πŸ”—β€‹

  • πŸ”— GitHub Copilot Quickstart

    • Official getting-started guide, installation, and basic workflows
  • 🧰 awesome-copilot

    • Curated prompts, instructions, agents, and patterns to extend this playbook
  • 🧩 awesome-mcp-servers

    • Catalog of Model Context Protocol (MCP) servers you can connect to Copilot-compatible tools for controlled access to external systems
  • πŸ’‘ MDC GitHub Copilot Playbook

    • Day-to-day workflows, prompt patterns and guardrails to help MDC developers

🧭 Use this cheat sheet as a quick reference; consult the full playbook for deeper guidance and examples.