Coding · guidance updated 4 Oct 2026
GitHub Copilot (chat/agent) prompt guide
Copilot supports GPT-5.x/6.x, Claude Sonnet/Opus 5.5 and Fable, Gemini 3.x, Grok and others, with auto model selection (GPT-5.3-Codex is the fallback). Use faster models for simple edits and reasoning models for planning and debugging.
How to prompt GitHub Copilot (chat/agent)
- Start with the broad goal, then list the specific requirements.
- Name exact symbols and files ('the createUser function in #file:src/users.ts'), never 'this' or 'it'.
- Pull in context with #file, #folder, #symbol, #codebase or #fetch for docs, or by selecting code.
- Give examples of inputs, expected outputs or a reference implementation.
- Break complex work into steps, and use Plan for multi-file changes before handing them to Agent.
- State constraints and how to verify the work (tests to run, expected output).
- Keep conventions, build and test commands in .github/copilot-instructions.md (about 2 pages max).
- Use path-scoped .github/instructions/*.instructions.md with applyTo globs, or AGENTS.md, for area-specific rules.
- Use /explain, /fix and /tests for quick targeted tasks.
- Start a new thread for a new task and delete stale turns to keep history relevant.
The shape of a good prompt
[Goal: broad intent] [Context: #file / #codebase / selection] [Requirements: bullet list] [Example input -> output] [Constraints] [Verification: tests/commands to run] [Mode: Plan then Agent for multi-file]
Avoid
- Ambiguous references like 'fix this' with no file or symbol
- One giant multi-feature request
- Task-specific details in copilot-instructions.md (it should be general)
- Long, stale chat threads carried over from previous tasks
Example
Request add input validation to the signup API
Add request validation to the signup endpoint.
Context: #file:src/routes/auth.ts (POST /signup handler) and #file:src/lib/errors.ts for our error format.
Requirements:
- email: required, valid format, lowercased and trimmed
- password: 12+ chars, at least one number and one letter
- displayName: optional, 2-40 chars
- On failure return 400 with { error: 'VALIDATION_ERROR', fields: { <field>: <message> } }
Example: { email: 'bad', password: 'short' } -> 400 with messages for both fields.
Use zod (already a dependency); don't change the success response. Add unit tests in tests/auth.signup.test.ts and run `npm test`.