GitHub Copilot

Verified against GitHub Copilot Chat · 2026-07-31

Generate docstrings that describe what the code actually does, not what its name implies

A documentation-generation prompt that requires each docstring claim to be checked against the real function body first, so documentation does not quietly repeat a misleading name or a stale comment instead of the real behavior.

GitHub Copilot Chat (VS Code)4 fillable variables

The prompt

Ready to copy — highlighted parts are example details you can swap.

Write documentation for the getUserTier function in lib/billing/tier.ts in TSDoc, matching the /** */ block style already used elsewhere in lib/billing/ format. Before writing
anything, read the actual function body — every branch, every early return, every thrown error —
and check whether its name and any existing comment already describe that behavior accurately,
because a docstring generated from the name and surrounding comments alone just restates whatever
those already claim, right or wrong, and a wrong claim documented confidently is worse than no
documentation at all.

AUDIENCE
Other engineers on this team calling this function from a new feature, not external API consumers.

KNOWN NON-OBVIOUS BEHAVIOR TO MAKE SURE IS SURFACED
getUserTier returns 'free' for a user with a cancelled subscription still inside its paid billing period, not 'paid' — this surprises people.

FOR EACH FUNCTION OR EXPORT, DOCUMENT
1. What it actually does, in one sentence, checked against the real logic — not the name. If the
   name suggests something the code does not actually do, say so as a separate note rather than
   writing around the discrepancy silently.
2. Every parameter, with its real constraint as enforced by the code, not just its type — if a
   parameter's type allows a value the function will actually throw on or silently misbehave for,
   document that constraint explicitly rather than letting the type signature imply it is always
   safe to pass.
3. What it returns in every branch, not just the main one — including what happens on an empty
   result, an error path, or an early return, since a docstring that only describes the success
   path is describing a fraction of the function's real contract.
4. Any side effect beyond the return value — a mutation of an argument, a write to storage, a
   network call, a thrown exception — stated explicitly, since a caller reading only the return
   type has no way to know about a side effect the code performs but the signature does not
   surface.

CONSTRAINTS
- Do not describe an implementation detail that could change without changing the contract, such
  as which specific loop construct is used internally, as if it were part of the guaranteed
  behavior — document what callers can rely on, not how today's version happens to achieve it.
- If getUserTier returns 'free' for a user with a cancelled subscription still inside its paid billing period, not 'paid' — this surprises people. names something the current code does not actually do, or does differently
  than described, flag the mismatch explicitly rather than writing the docstring to match the
  gotcha note over the real code — the note might itself be stale.
- Match TSDoc, matching the /** */ block style already used elsewhere in lib/billing/ exactly, including whether examples are expected inline — a generated block
  that is close to the right format but not quite in the project's actual convention creates
  visible inconsistency across a codebase where every other function follows the real convention.

Customize

Optional — swap in your own details for the highlighted parts above.

Why this works

Reading every branch and early return before writing anything counters the specific and common failure mode of documentation generation: pattern-matching from a function's name and any existing comment, which reproduces whatever those already claim, correct or not, because nothing forces the generation step to check the claim against the actual logic first. Documenting every return branch and every side effect beyond the signature targets a real gap between what a TypeScript type signature guarantees and what a function actually does — types capture shape, not behavior, so they say nothing about which branch returns what, whether an argument gets mutated, or whether a network call happens along the way, and a docstring that only restates the type signature in prose has added no information a caller could not already see. The distinction between a documented contract and an incidental implementation detail matters because it determines what stays true across a future refactor — a docstring describing an internal loop construct as guaranteed behavior goes stale the moment someone rewrites that loop for an unrelated performance reason, even though nothing about the function's actual contract changed, while a docstring scoped to what callers can rely on survives exactly the kind of internal change it should be indifferent to. Cross-checking known_gotchas against the real code rather than writing the docstring to match the gotcha note on faith closes a specific risk in any tribal-knowledge input: the note itself might be stale, describing a behavior from a version of the function that has since changed, and a documentation pass that trusts it uncritically can bake an outdated claim into a freshly generated docstring with the same false confidence as if it had been verified.

Verified against

GitHub Copilot Chat Copilot Chat 1.269 (VS Code) · 2026-07-31

Changelog

  • 2026-07-31 Initial publish, verified against Copilot Chat 1.269 (VS Code).

Need this built into your business?

If a prompt isn't enough — custom software, built and maintained for you — that's Scult's day job.

EXPLORE CUSTOM SOFTWARE
Write a .github/copilot-instructions.md file Copilot actually followsA repository-wide custom-instructions file that Copilot loads automatically into every Chat request, code-review pass, coding-agent session, and commit or PR-description generation in this repo, written so each rule holds up standing alone instead of only in the context it was written in.GitHub Copilot Chat (VS Code)GitHub Copilot code review2026-07-20Scope Copilot's instructions to one directory with an applyTo instructions fileA path-scoped .github/instructions/*.instructions.md template using the applyTo frontmatter glob, so a directory-specific rule — a different test framework, a stricter API contract, a legacy pattern that must not spread — applies only where it is actually true instead of polluting the repo-wide instructions file.GitHub Copilot Chat (VS Code)GitHub Copilot coding agent2026-07-21Define a custom Copilot Chat mode instead of re-explaining your workflow every sessionA .github/chatmodes/*.chatmode.md definition — scoped tools, a fixed model, and a narrow system prompt — that turns a repeated review-and-plan style of conversation into a mode you switch into once, instead of a persona you re-describe in the first message every time.GitHub Copilot Chat (VS Code)2026-07-22Turn a prompt you keep retyping into a Copilot prompt file instead of pasting it againA .github/prompts/*.prompt.md reusable prompt file with input placeholders, invoked as a slash command from the Chat input box, so a well-tuned multi-paragraph prompt becomes one command instead of a paste you have to keep re-finding.GitHub Copilot Chat (VS Code)2026-07-22
All GitHub Copilot prompts

Check your AI visibility

One URL in, a 0–100 score and the exact fixes out.

RUN THE CHECK

Browse all the tools

15 tools across six categories
13 of them never send your data anywhere

Free · No signup · No trial clock

SEE THE DIRECTORY