AI Pair Programming with GitHub Copilot
Copilot started the whole category — the autocomplete that made "AI pair programmer" a real phrase. It has since grown chat, an agent mode, and code review, all wired into GitHub. This chapter covers Copilot's surfaces, how to get good suggestions, and the model-choice and governance angles that come with the most widely deployed AI dev tool.
Learning objectives
- Use Copilot's surfaces: completions, chat, agent, review.
- Get better suggestions with context and comments.
- Choose models and use Copilot in the GitHub workflow.
- Govern Copilot across an org.
code/ad5-copilot/ in the course, with a README on how to run it. Read here, run there — no need to copy-paste.1 · The tool that started the category essential
Cast your mind back to before 2021. Writing code meant you typed every character, and "autocomplete" meant your editor guessing a variable name you'd already declared. Then Copilot arrived and finished your whole line — sometimes your whole function — from a comment and a signature, and the phrase "AI pair programmer" stopped being marketing and started being a description of your Tuesday afternoon. Every tool in this section (Cursor, Amazon Q, the rest) is, in some sense, answering the question Copilot asked first: what if the editor could write with you?
Here's the analogy that makes Copilot click. Think of it as a very well-read junior developer sitting beside you who has skimmed an enormous amount of public code. It's astonishingly fast at "I've seen this shape before, here's the obvious next bit" — and exactly as unreliable as that sounds when the answer needs judgement rather than pattern-matching. That single mental model — fast, fluent, pattern-driven, not accountable — explains almost everything in this chapter: why a clear contract gets a great suggestion (§3), why you still verify every line (§5), and why an org has to put guardrails around it (§6).
The common beginner mistake is treating Copilot as one thing — "the autocomplete." It is really four different surfaces, each suited to a different size of task, and using the wrong one is like reaching for a screwdriver to hammer a nail. Inline completion finishes a keystroke; chat handles a scoped request; agent mode takes on a multi-step job; PR review works at the whole-changeset level. Knowing which to reach for is half of using it well, which is why the very next section lays them side by side.
One more thing worth saying up front, because it reframes the whole lesson: Copilot's edge isn't that it writes the best code — several tools are competitive on raw suggestion quality. Its edge is reach and integration. It is the most widely deployed AI dev tool, it lives natively inside GitHub where your issues and pull requests already are, and it ships the org-level governance controls enterprises need to say yes. So this chapter deliberately climbs from the keystroke (completions) all the way to the boardroom (governance) — because with Copilot, both ends of that ladder actually matter.
Start at the box on top, then follow the three arrows fanning down to the sections they explain.
- The top box is the single mental model for Copilot: a very well-read junior developer — fast, fluent, pattern-driven, and not accountable for the result.
- The three blue arrows fan out to the chapter's three payoff sections. Each lower box names the trait that drives it: because it's pattern-driven, a clear contract steers it well (§3); because plausible isn't correct, you verify every line (§5); because it isn't accountable, the org must add guardrails (§6).
- The payoff is the fan itself: you don't memorise three separate rules — one mental model generates all of them, which is why the chapter climbs from keystroke to boardroom.
In short: "fast, fluent, pattern-driven, not accountable" is the one idea that explains steering, verifying, and governing Copilot alike.
Copilot began as the autocomplete that coined "AI pair programmer." It's now the most widely deployed AI dev tool, with completions, chat, an agent mode, and PR review — all wired into GitHub. Its reach and governance features are its distinguishing edge.
2 · The surfaces essential
Imagine a colleague who can help you in four completely different modes, and the trick is asking in the right one. You can lean over and mutter "just finish this line for me" — that's a whisper. You can turn your chair and ask "how does this bit work, and can you write me a test?" — that's a conversation. You can hand them a ticket and say "go make this change across the codebase, I'll review it" — that's delegation. Or you can point at a pull request and ask "what actually changed here?" — that's oversight. Copilot's four surfaces map exactly onto those four modes, and matching the surface to the size of your ask is the single most practical skill in this section.
Why does this deserve its own section rather than a one-line list? Because the failure mode is real and common: people try to drive a whole multi-file refactor through inline completion, accepting one ghost-text nudge at a time, and wonder why it's slow and drifts off course — that's a delegation-sized job crammed into a whisper-sized tool. Or they open chat to finish a line they could have gotten from a single Tab. The table below is a routing guide: read the left column as "how big is what I'm asking for right now," and let that pick the surface. As a rule of thumb — a keystroke → completions; a question or scoped edit → chat; a task with several steps → agent mode; a whole diff → PR review.
Keep in mind these surfaces share one brain but differ in how much rope they get. Completions see your open files and suggest the next token or two; chat can read a selection and hold a back-and-forth; agent mode is allowed to plan, edit multiple files, and iterate; PR review reasons over an entire changeset. More rope means more power and more room to go wrong, which is exactly why the trust-and-verify discipline in §5 scales with the surface you choose. Read the table, then notice as you go through the chapter that each later section is really a deeper dive into getting more out of one of these four rows.
Read the four boxes left to right — that order is the size of the thing you're asking for, from smallest to largest.
- Each box is one Copilot surface with its typical job underneath: Completions finish a keystroke, Chat handles a scoped request, Agent mode takes on a multi-step task, and PR review reasons over a whole changeset.
- The blue arrows between boxes mark the step up in scope — each surface handles a bigger ask than the one to its left.
- The dashed axis underneath is the payoff: moving right means the tool gets "more rope" — more autonomy — so it can do more and has more room to go wrong. That is why the verification discipline of §5 scales with the surface you pick.
In short: pick the surface by how big the ask is — keystroke → completions, question → chat, several steps → agent, whole diff → PR review — and verify harder the further right you go.
| Surface | Use for |
|---|---|
| Ghost-text completions | inline next-line suggestions |
| Copilot Chat | ask about code, generate, explain |
| Agent mode | multi-step tasks in the IDE |
| PR review / summaries | review + describe pull requests |
3 · Intermediate — steering the suggestions intermediate
Here's the frustration nearly everyone hits in their first week. Copilot suggests something almost-but-not-quite right, you delete it, retype, get another near-miss, and start to feel like you're arguing with a slot machine. The instinct is to blame the tool or to "wish harder" — to sit and hope the next Tab is the good one. That instinct is the mistake, and understanding why is what turns Copilot from a lucky-dip into a reliable instrument.
The key realisation: Copilot has no idea what you want. It predicts the statistically likely next code given what it can see — your open files, the nearby lines, the function name, the comment you just wrote. It is not reading your mind; it is reading your context. So the lever is never "hope," it's shaping what it sees. Think of ordering at a restaurant: "something nice" gets you the chef's guess, while "medium-rare ribeye, no butter, extra chips" gets you exactly your meal. A vague, empty function gets a vague, average completion; a precise signature and docstring get a suggestion aimed straight at your intent.
This is why the section is called steering rather than prompting — you're not typing a command, you're setting up the surroundings so the obvious next thing to write is the thing you want. Two concrete moves do most of the work, and both are just "give it more relevant context." First, write the contract before the body: a clear name, real type hints, and a docstring that states the job and its edge cases. That transforms Copilot's task from "guess what this function is for" into "implement this specification," and a spec is something a pattern-matcher is genuinely good at filling. Second, keep a relevant example open nearby — a sibling function in the same style, the module you want it to imitate — so completions get biased toward your conventions instead of the internet's average. A common trap here is leaving twenty unrelated tabs open; irrelevant context is noise that pulls suggestions off-target, so curate what's visible.
The lab below makes this tangible with a single function. Watch what the type hints and the docstring are doing: they're not decoration, they're the highest-signal part of the prompt. As you read it, keep asking the steering question — what is Copilot able to see here, and how does each line make its guess more certain? That question, not blind acceptance, is what separates people who fight Copilot from people who direct it.
Copilot reads open files, nearby code, and your comments. Better inputs = better output: write a clear docstring/signature first, keep relevant files open, and describe intent in a comment right above where you want code.
Read left to right: the two boxes on the left are the context you provide, they both flow through the same Copilot in the middle, and the two boxes on the right are what comes back.
- The red box (top-left) is vague context — an empty function, no type hints, no docstring, plus unrelated open tabs as noise. Its dashed arrow leads to the amber "average guess" on the right: Copilot has to guess what you want.
- The green box (bottom-left) is precise context — a typed signature, a docstring that states the job, and a relevant example open nearby. Its solid blue arrow leads to the green "on-target body": the task became "implement this spec."
- The single Copilot box in the middle is the payoff element: it is the same model both times. What changed the outcome was never the model — it was what you let it see.
In short: you steer Copilot by shaping its context — a clear name, types, docstring, and a nearby example turn a vague completion into the one you meant.
steer.pydef parse_iso_duration(text: str) -> int:
"""Parse an ISO-8601 duration like 'PT1H30M' into total seconds.
Supports hours (H), minutes (M), seconds (S) after 'PT'. Raises ValueError."""
import re
m = re.fullmatch(r"PT(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?", text)
if not m or text == "PT":
raise ValueError(f"bad duration: {text}")
h, mi, s = (int(x) if x else 0 for x in m.groups())
return h*3600 + mi*60 + s
print(parse_iso_duration("PT1H30M")) # 5400
print(parse_iso_duration("PT45S")) # 45
5400
45
This lab shows the contract-first way to use Copilot. You don't write the logic yourself — you write a precise contract (the function name, its inputs and output type, and a docstring saying exactly what it should do), and Copilot fills in the body. Here the function turns an ISO-8601 duration like PT1H30M (1 hour 30 minutes) into a plain number of seconds.
def parse_iso_duration(text: str) -> int:is the signature — the contract's header. It says: give me one string calledtext, and I hand back anint. Those type hints (: str,-> int) tell both Copilot and a human reader what goes in and what comes out.- The triple-quoted
"""..."""lines are the docstring — a plain-English spec of the job: parse hours/minutes/seconds afterPT, and raise an error on bad input. This is the highest-signal prompt you can give Copilot; it turns "guess what I want" into "implement this." re.fullmatch(...)is a regular expression — a pattern that checks the whole string matches the shapePTthen optionalH/M/Sgroups. If it doesn't match (or the string is just"PT"), the coderaises aValueError— its way of saying "that input is invalid."h*3600 + mi*60 + sdoes the arithmetic: each hour is 3600 seconds, each minute is 60, plus the leftover seconds. The line above it turns each captured piece into a number, using0when a piece is missing.
What the output means: PT1H30M is 1 hour + 30 minutes = 3600 + 1800 = 5400 seconds, and PT45S is just 45 seconds — exactly the two lines printed.
Try this: Delete everything from import re down to the return, keep only the signature and docstring, and let Copilot re-suggest the body. Then tighten the docstring (say, "also support days (D)") and watch the suggestion change — the clearer the contract, the more often Copilot's first guess is right.
4 · Advanced — model choice & the GitHub workflow advanced
You wouldn't send a Formula 1 car to pick up groceries, or a delivery van to a race. Yet the default instinct with an AI tool is to run everything through one model and hope it's fine. Copilot's advanced move is letting you pick the engine per task — and once you can, the interesting question stops being "is the model good?" and becomes "is this the right model for this job?" That's a genuinely new decision in a developer's day, and getting the intuition for it is what this section is about.
The tension is a simple trade between speed, cost, and reasoning power. A fast, cheap model is perfect for the thing you do a thousand times an hour — finishing a line, filling boilerplate — where latency matters more than deep thought and a slightly-off guess costs you one Tab-and-retype. A stronger reasoning model is slower and pricier per call, but it earns that cost on the hard stuff: multi-step logic, a gnarly bug, an architecture question where a plausible-but-wrong answer sends you down a costly wrong path. The rule of thumb is match the model to the difficulty and the stakes: reach for the strong model precisely when a wrong answer would cost you more than the extra few seconds of latency. (Notably, the model menu now includes Claude models alongside others — the same "reasoning vs. fast" choice you'll meet throughout this course, surfaced right inside your editor.)
The second half of this section is the one people underrate. Copilot doesn't just live in your editor — it lives across the whole GitHub loop: an issue describes the work, agent mode attempts it, a pull request captures the change, and Copilot review comments on the diff. That means AI now touches every stage of the cycle, not just the moment you're typing. Powerful — and also the place a subtle failure creeps in. When AI both writes the change and summarises it for the reviewer, the human is tempted to skim the AI's summary and rubber-stamp the AI's code, and suddenly nobody actually reviewed anything. The mental guardrail: a Copilot PR summary is a starting point to orient you, never the review itself. Let it tell you where to look first; keep your own eyes and sign-off on correctness and design. Hold that distinction, because §5 turns it into a discipline you apply to every single suggestion.
Copilot now lets you pick the underlying model (including Claude models) per task — reasoning models for hard problems, fast ones for completions. And it lives in the whole GitHub flow: issues → agent → PR → Copilot review, so AI spans the loop, not just the editor.
Follow the top row of blue arrows left to right — that is one trip through the GitHub development loop, with a step below that closes it.
- The four top boxes are the stages: an Issue describes the work, Agent mode attempts the change, a Pull request captures it, and Copilot review comments on the diff. AI can touch every one of them, not just your keystrokes.
- The blue arrow bending down to the green box is the payoff element: Human sign-off. Copilot's review summary orients the reviewer, but the person still owns the decision on correctness and design.
- The dashed arrow looping back from sign-off to the agent is the "changes requested" path — the loop repeats until a human is satisfied. That gate is what stops AI writing and rubber-stamping its own change.
In short: AI now spans issue → agent → PR → review, but the human sign-off stays the gate — use the summary to orient, never to decide.
5 · Professional — trust but verify professional
Here is the uncomfortable truth that separates a professional from a hobbyist with Copilot: when the commit ships and it breaks production at 2am, "Copilot wrote it" is not on the incident report. Your name is on the commit. The tool authored the text; you authored the decision to ship it. Internalising that one fact — you are accountable for code you didn't type — is what makes the rest of this section a habit rather than a nag.
The danger is specifically subtle wrongness, and that's what makes it hard. Copilot produces the statistically likely next code, which means its output is fluent, confident, and conventional-looking — it reads like correct code because it's built from a million examples of correct-looking code. So the bugs it introduces aren't the obvious kind that fail loudly; they're the quiet kind that pass the happy path and fail on the empty list, the null, the boundary, the error branch it never bothered to pattern-match. Think of a suggestion as a confident answer from that well-read junior who has genuinely never run the code — it might be right, it is often plausible, and plausible is not the same as correct.
Which is why the professional move is a shift in framing: treat every suggestion as a draft, not as typing to approve. A draft gets reviewed before it becomes yours. Concretely, run the same checklist you'd apply to a pull request from a new teammate — does it handle the edge cases or only the happy path? Any hard-coded secret, injection-prone string-building, or insecure default it copied from somewhere? For a large verbatim block, is there a licensing/provenance concern worth the duplication-detection setting? Does it use our utilities and conventions or reinvent them? And is the behaviour pinned by a test, especially the branches it generated for you? Notice that several of those — security, provenance, fit — are things a passing test simply cannot see, so "it runs" is never the finish line.
The trap that makes this a professional-level skill rather than a beginner one is that the failure grows with your fluency. The faster and more accurate Copilot gets, the more you relax, the more you skim — and its very ubiquity means everyone is quietly relaxing at once. Complacency, not incompetence, is the real risk here. The counter-habit is to deliberately pause on anything non-trivial and ask "is this correct, or just likely?" That half-second of friction is the entire price of admission for authoring at Copilot's speed while keeping human-quality code.
Read left to right: a suggestion enters on the left, passes through the checklist in the middle, and exits to one of two outcomes on the right.
- The amber Suggestion box on the left is deliberately labelled "a draft, not typing" — the whole discipline starts with that reframing.
- The big central checklist box is the five dimensions you apply like a pull request from a new teammate: correctness/edge cases, security, provenance, fit, and a pinning test. The note underneath flags that three of them — security, provenance, fit — are exactly what a passing test can't check.
- The two branches are the payoff. The green "Ships" box (pass all) is the only path to your commit — and it ships under your name. The red "Back to fix" box (fail any) sends it back as a draft. There is no arrow straight from suggestion to commit.
In short: treat each suggestion as a draft that must clear correctness, security, provenance, fit, and a test before it earns your name — because you sign the commit.
Copilot suggestions can be subtly wrong, outdated, or insecure. Keep the same bar as human code: tests, review, and never accept security-relevant code on faith. Its ubiquity makes complacency the real risk — treat every suggestion as a draft.
6 · Tech-lead — org-wide governance tech-lead
Everything so far has been about one developer at one keyboard. Now zoom out to a thousand of them. The §5 discipline — verify every draft — is a personal virtue, and personal virtues do not scale reliably across an entire engineering org. Someone, somewhere, on a Friday afternoon, will paste a Copilot suggestion straight into a commit without reading it. A tech lead's job is not to trust that nobody does that; it's to build the system that stays safe even when someone does. That shift — from "I verify" to "the org's controls make verification the default" — is what governance means.
The reason this matters more for Copilot than for niche tools is precisely its ubiquity. Because nearly anyone can flip it on, the risk isn't a bold new capability slipping in unnoticed — it's complacency at scale: a hundred small unverified acceptances a day, quietly eroding quality and leaking context you didn't mean to send. That reframes the lead's task from "should we allow this?" (the ship has sailed; people want it) to "how do we control the data flow and preserve review discipline while capturing the velocity?" It becomes a compliance question, not a preference — which, incidentally, is why the same enterprise governance surface that makes it a chore is also a big part of why enterprises choose Copilot in the first place.
The controls group into a few intuitive buckets, and it helps to picture what each is actually protecting. Data and IP: content exclusions decide which repos and paths the model never sees, duplication filtering guards against large verbatim blocks of licensed code, and you confirm the enterprise data-handling terms meet policy — this bucket controls what leaves your walls. Secrets: secret-scanning in CI as a hard gate, because you never rely on a probabilistic model to remember not to leak a key. Review and access: AI-authored code is reviewed like any other code with the human author accountable, PR summaries orient reviewers but don't replace them, and you scope which teams and repos get it — keeping sensitive repos opted out where required. The common failure here is enabling Copilot as a one-click checkbox and walking away; a written acceptable-use policy and a pilot before broad rollout is the difference between governance and hope.
The last piece is the one leads forget until it bites: measure both sides of the trade. It is easy to celebrate velocity — PR throughput up, time-to-first-commit down — and easy to miss the quality signal moving the other way — defect rate, security findings, incident count creeping up. If you only measure speed, you'll congratulate yourself right up to the outage. So track velocity and quality together, review the settings quarterly because models and features change fast, and treat the whole thing as a living configuration rather than a one-time switch. Get that balance right and you capture the real productivity win without quietly trading it away.
Read it top to bottom: the personal habit on the left can't scale, so it feeds into the big org-controls box, which then produces the outcome at the bottom.
- The red box on the left is the §5 personal discipline — "I verify" — which is a virtue that doesn't scale across a thousand developers.
- Inside the big box are the three control buckets a lead configures: Data / IP (content exclusions, duplication filtering — what leaves your walls), Secrets (secret-scanning in CI as a hard gate), and Review / access (scope which teams/repos, PR summaries orient but don't replace review). The amber band underneath is the process wrapper: pilot first, write a policy, and measure velocity and quality together.
- The green box at the bottom is the payoff: because the controls — not any one person's diligence — enforce the checks, the org stays safe at scale even when someone skips a verification.
In short: governance converts "I verify" into system controls (data/IP, secrets, review/access) plus dual velocity-and-quality metrics, so safety no longer depends on any single developer.
At org scale a lead configures Copilot centrally: content exclusions (repos/paths the model never sees), a policy on public-code matching, seat management, and audit. Because Copilot is so widely used, getting these controls right is a compliance issue, not a preference — the governance surface is a big reason enterprises pick it.
Exercise AD5.1 — Contract-first suggestions
Context: Copilot is at its best when you give it a contract to satisfy. Writing precise signatures with docstrings and watching the first-suggestion hit rate rise shows directly how contract clarity drives quality.
Your task: Write three function signatures with precise docstrings, let Copilot fill the bodies, and note how contract clarity changes the hit rate.
Requirements:
- Write three function signatures each with a precise docstring (like
steer.py) - Let Copilot fill each body from the contract
- Note how often the first suggestion is correct
- Observe how the clarity of the contract changes the first-suggestion hit rate
💡 Hint: The precise signature + docstring is the highest-signal prompt — the clearer the contract, the more often the first suggestion is right.
🪜 Practice ladder beginner → industry
Six graded exercises, easy to real-world. Try each before opening its solution.
Context: Copilot started the category with inline completion and has grown into chat and GitHub-native features. Knowing which surface is best for which task is the foundation for using it well.
Your task: Name Copilot's main surfaces (inline completion, chat, PR/workflow features) and give the one task each is best at.
Requirements:
- Inline completion (ghost text): finishing the line/block you're already writing — instant, in-flow
- Copilot Chat: explaining code, scoped edits, generating a test or function on request
- GitHub workflow features: summarizing a diff, suggesting review comments, answering ‘what changed’
- Note Copilot began as inline completion and extended toward workflow assistance
💡 Hint: Map each surface to the size and stage of the task — a keystroke, a scoped request, or a whole PR.
Show solution
| Surface | Best at |
|---|---|
| Inline completion (ghost text) | Finishing the line/block you're already writing — instant, in-flow |
| Copilot Chat | Explaining code, scoped edits, generating a test or function on request |
| GitHub workflow (PR summaries, review, Copilot in the repo) | Summarizing a diff, suggesting review comments, answering ‘what changed’ |
Copilot started the category with inline completion; the chat and GitHub-native features extend it from ‘autocomplete’ toward workflow assistance.
Context: Copilot predicts from surrounding code, open files, and what you've typed — so you steer it by shaping that context, not by wishing harder. Two concrete moves do most of the work.
Your task: Show two concrete ways to steer Copilot toward the completion you want, given that its suggestions are driven by nearby context.
Requirements:
- Explain that Copilot predicts from surrounding code, open files, and typed text
- Move 1: write a precise signature + docstring first, then let it fill the body toward that contract
- Move 2: keep a relevant example / sibling function open nearby to bias it toward your conventions
- Conclude the lever is context: a clear name, types, docstring, and nearby example turn vague suggestions into on-target ones
💡 Hint: A typed signature plus a docstring is the highest-signal prompt you can give — it turns ‘guess what I want’ into ‘implement this spec.’
Show solution
Copilot predicts from the surrounding code, open files, and what you've typed — so you steer it by shaping that context, not by wishing harder.
- Write a precise signature + docstring first, then let it fill the body:
def parse_iso_timestamp(s: str) -> datetime: """Parse an ISO-8601 string; raise ValueError if invalid. Assume UTC if no tz.""" # Copilot now completes toward THIS contract - Keep a relevant example open / nearby — a sibling function in the same style biases completions toward your conventions. Open the file you want it to imitate.
The lever is context: a clear name, types, docstring, and a nearby example turn vague suggestions into on-target ones.
Context: Copilot now lets you pick among models and integrates at the PR level — both change how you work, but the PR features especially risk reviewers rubber-stamping an AI summary instead of reviewing.
Your task: Say when you'd switch Copilot models and how PR-level features change the review loop.
Requirements:
- Model choice: fast/cheap model for routine completion; stronger reasoning model for hard multi-step logic, tricky debugging, or architecture questions
- Match model to the difficulty and stakes of the task
- PR features (diff summaries, suggested review comments) speed a reviewer's first pass
- State the risk: reviewers rubber-stamping the AI summary; keep human sign-off on correctness and design
- Frame the summary as a starting point to orient, not the review itself
💡 Hint: Use the strong model where a wrong answer costs more than the extra latency, and let PR summaries orient you, not decide for you.
Show solution
Model choice: use a fast/cheap model for routine completion and boilerplate; switch to a stronger reasoning model for hard, multi-step logic, tricky debugging, or architecture questions where a wrong answer costs more than the extra latency. Match model to the difficulty and stakes of the task.
PR-level features change the loop: Copilot can summarize a diff and suggest review comments, which speeds a reviewer's first pass — but its summary is a starting point, not the review. The risk is reviewers rubber-stamping the AI summary. Keep human sign-off on correctness and design; use the summary to orient, not to decide.
Context: Inline completion is fast but subtly degrades quality over time: it suggests the statistically likely next code, nudging you toward conventional — and sometimes subtly wrong — patterns, and it amplifies existing mistakes in nearby code.
Your task: Describe a subtle way inline completion degrades code quality over time and the habit that counters it.
Requirements:
- Name the degradation: convergence to the plausible-average (common-but-wrong patterns that look right)
- Note the second effect: it completes toward nearby code, propagating an existing mistake into new functions
- Explain the shift from actively designing to ratifying suggestions
- Give the counter-habit: treat each accepted suggestion as a diff to review, pausing to ask ‘is this correct, or just likely?’
- Add: fix bad nearby patterns quickly because Copilot amplifies them
💡 Hint: The danger is accepting the flow — pause on anything non-trivial and ask whether it's correct or merely the most likely next tokens.
Show solution
Subtle degradation: convergence to the plausible-average. Completion suggests the most statistically likely next code, which nudges you toward conventional patterns — including subtly wrong ones (off-by-one, wrong default, deprecated idiom) that look right because they're common. Accepting the flow repeatedly means you stop actively designing and start ratifying.
A second effect: it completes toward the shape of nearby code, so an existing mistake gets propagated into every new function.
Counter-habit: treat each accepted suggestion as a diff to review, not typing to approve — pause on anything non-trivial and ask ‘is this correct, or just likely?’ And fix bad nearby patterns quickly, because Copilot will amplify them.
Context: Copilot's speed of authoring is real; the professional discipline is a ‘trust but verify’ checklist applied before the suggestion becomes your commit — because you sign the commit, not Copilot.
Your task: Write the ‘trust but verify’ checklist a professional applies to Copilot output before committing.
Requirements:
- Correctness: does it handle edge cases (empty, null, boundary, error paths) or only the happy path it pattern-matched?
- Security: no hard-coded secrets, no injection-prone string-building, no insecure default
- Provenance/licensing: be wary of a large verbatim block; use duplication detection
- Fit: does it use our utilities and conventions or reinvent them?
- Tests: is the behavior pinned by a test, especially for generated branches?
- State the framing: trust the authoring speed, verify correctness/security/fit — you sign the commit
💡 Hint: Verify the dimensions tests can't see — security, provenance, and fit — not just whether it runs.
Show solution
- Correctness: does it handle the edge cases (empty, null, boundary, error paths), or only the happy path it pattern-matched?
- Security: no hard-coded secrets, no injection-prone string-building, no insecure default it copied.
- Provenance/licensing: for a large verbatim block, be wary of copied licensed code; use the org's duplication-detection setting.
- Fit: does it use our utilities and conventions, or reinvent them?
- Tests: is the behavior pinned by a test, especially for the branches it generated?
Trust the speed of authoring; verify the correctness, security, and fit before it becomes your commit — you sign the commit, not Copilot.
Context: Because Copilot is the most widely deployed AI dev tool, complacency is the real enterprise risk. Governance is about controlling data flow and preserving review discipline while capturing the velocity — and measuring both sides.
Your task: Design the governance to roll Copilot out across an enterprise with security and compliance obligations: policy, controls, and metrics.
Requirements:
- Data/IP controls: duplication filtering, configure what code context may be sent, confirm enterprise data-handling terms meet policy
- Secrets: secret-scanning in CI as a hard gate; never rely on the model to avoid leaking
- Review: AI-authored code reviewed like any code, author accountable, PR summaries orient but don't replace review
- Access: scope which repos/teams have it; keep sensitive repos opted out if required
- Pilot + written acceptable-use policy before broad enablement; review settings quarterly
- Measure both velocity (PR throughput, time-to-first-commit) and quality (defect/incident rate, security findings) to catch a bad trade
💡 Hint: The failure mode is enabling it as a checkbox and measuring only speed — watch data flow, review discipline, and quality signals too.
Show solution
| Area | Control |
|---|---|
| Data / IP | Enable duplication filtering; configure what code context may be sent; confirm the enterprise data-handling terms meet policy |
| Secrets | Secret-scanning in CI as a hard gate; never rely on the model to avoid leaking |
| Review | AI-authored code reviewed like any code; author accountable; PR summaries orient reviewers but don't replace review |
| Access | Scope which repos/teams have it; keep sensitive repos opted out if required |
| Training | Teach steering + verify habits, not just install it |
- Pilot & policy first: a written acceptable-use policy (verification required, no unowned code) before broad enablement.
- Measure both sides: velocity (PR throughput, time-to-first-commit) and quality (defect rate, security findings, incident rate) so you catch a speed-for-quality trade early.
- Review quarterly: models and features change fast; revisit settings and policy.
Lesson: enterprise governance is about controlling data flow and preserving review discipline while capturing the velocity — the failure mode is enabling it as a checkbox and measuring only speed.
✓ Checkpoint — you can move on when you can…
- Use completions/chat/agent/review appropriately.
- Steer with contracts + context.
- Choose models; use the full GitHub loop.
- Verify every suggestion; govern Copilot org-wide.
Knowledge check check yourself
The parse_iso_duration lab demonstrates "contract-first" use of Copilot. Why is a precise signature plus docstring called the highest-signal prompt you can give it?
Show answer
Copilot is described as the most widely deployed AI dev tool, and the lesson says its ubiquity makes complacency the real risk. How does that reframe an org lead's governance job?