GitHub Copilot

Verified against GitHub Copilot Chat · 2026-08-13

Generate an API reference straight from the route handlers, not from what you remember they do

A Copilot Chat prompt that builds an API reference table by reading the actual route handler code via #codebase, catching drift between what an endpoint was designed to do and what it currently, actually does.

GitHub Copilot Chat4 fillable variables

The prompt

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

Generate an API reference for the endpoints below by reading their actual current implementation — reference the route files with #file or #codebase so you're documenting the real request handling and response shape, not a remembered or assumed version of it.

ROUTE FILES TO DOCUMENT
api/routes/orders.ts and api/routes/orders.[id].ts

AUTH MODEL FOR THESE ROUTES
Bearer JWT required on all routes except GET /orders/public-status, which is intentionally unauthenticated.

RESPONSE-SHAPE NOTES
All success responses are wrapped in { data: ..., meta: { requestId } }; errors use { error: { code, message } }.

WHERE THE OUTPUT SHOULD LIVE
docs/api/orders.md

For each endpoint, read the handler function itself, not just its name or route path — a route named /users/:id/orders could still, in its current implementation, only return the last 30 days of orders, or silently exclude cancelled ones, and that kind of behavior is only visible in the function body, never in the route signature. If the code validates the request body with a schema (Zod, Joi, a class-validator DTO, whatever this codebase uses), pull the actual field names, types, and required/optional status from that schema rather than restating them from memory or from any existing doc comment above the function, since a stale doc comment describing an older version of the schema is a common and specific way documentation drifts out of sync with the code it's supposed to describe.

For each endpoint, note explicitly if the current implementation's behavior looks like it might not match what the route name or an existing comment implies it does — flag that as a discrepancy to confirm with me rather than silently documenting either the name's implication or the code's actual behavior as if there were no conflict.

OUTPUT FORMAT (as a markdown table per endpoint, matching the target file at docs/api/orders.md)
| Field | Value |
|---|---|
| Method + path | |
| Auth required | |
| Request body / params | |
| Success response shape | |
| Error responses | |
| Notes / discrepancies found | |

After the tables, list separately any endpoint where the implementation didn't match its name or existing docs closely enough that you'd want a human to confirm the intended behavior before this reference is treated as authoritative.

Customize

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

Why this works

Copilot Chat's #codebase and #file context references let it read the actual handler implementation rather than pattern-matching on the route's name and an existing doc comment, which matters specifically because API documentation drift almost never comes from someone documenting nothing — it comes from someone documenting the endpoint as it was designed, and the code quietly changing underneath that description over a series of unrelated PRs. Instructing the model to pull field names and required/optional status from the actual validation schema rather than restating a doc comment closes the single most common drift vector directly: a schema is executable and gets exercised by real requests, so it reflects current behavior by construction, while a doc comment is prose that nobody is forced to update when the schema changes, and Copilot Chat has no inherent preference for the more authoritative source unless told which one to trust when they disagree. The explicit instruction to flag a mismatch between a route's name/existing docs and its actual current behavior — rather than silently picking one version to document — matters because a language model asked to 'document this endpoint' will, by default, try to produce a single coherent-sounding description and will tend to smooth over a contradiction rather than surface it, since a clean unified answer looks more complete than one that flags its own uncertainty; without being told explicitly that a discrepancy is a valuable finding rather than an untidy one, it gets silently resolved in whichever direction sounds more natural, which is exactly the kind of silent resolution that produces documentation nobody can trust. The table format per endpoint also keeps this reference machine-comparable against a previous version stored in the same repo, so future re-runs of this same prompt can be diffed against doc_output_path's prior content to catch exactly what changed.

What you get back

| Field | Value | |---|---| | Method + path | GET /users/:id/orders | | Auth required | Yes — Bearer JWT, must match :id or have admin role | | Request body / params | Query param `includeCancelled` (boolean, optional, default false) | | Success response shape | { data: Order[], meta: { requestId } } | | Error responses | 401 unauthenticated, 403 id mismatch without admin role, 404 user not found | | Notes / discrepancies found | The route name implies all orders, but the handler silently filters to the last 30 days unless a `since` param is passed — this isn't mentioned anywhere in the existing docs comment; flagging for confirmation. |

Verified against

GitHub Copilot Chat 2026.08 · 2026-08-13

Changelog

  • 2026-08-13 Initial publish, verified against GitHub Copilot Chat 2026.08.

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