Context-aware code completion, unit test scaffolding, repository exploration, Git commit message drafting, and multi-file refactoring with Copilot Edits.
Recommended Prompt Architecture
### The Copilot 4-Pillar Context Pattern
1. **File Anchoring**: Keep relevant schema and interface files open in adjacent editor tabs so Copilot includes them in prompt context.
2. **Top-Level Intent**: Start new files with a concise comment block outlining the component purpose, external contracts, and constraints.
3. **Slash Commands**: Leverage /fix, /tests, /explain, and /doc to invoke specialized model fine-tunings.
4. **Iterative Stepping**: Prompt one logical sub-routine at a time rather than asking for 500 lines in a single generation.
Output Formatting Tips
• Use strict JSDoc/TSDoc comments above functions to steer parameter and return types.
• Specify exact test frameworks (e.g. 'Use Vitest and @testing-library/react').
• Instruct Copilot to preserve existing code style and naming conventions.
Common Pitfalls to Avoid
• Having dozens of irrelevant open tabs polluting Copilot's prompt context window.
• Vague comments like '// make this better' instead of '// refactor to reduce time complexity to O(n) using Map lookup'.
• Not reviewing generated dependencies before installing.
Advanced Techniques & Power Features
• Copilot Edits: Use multi-file sessions to orchestrate refactors across controllers, models, and test suites simultaneously.
• .github/copilot-instructions.md: Commit persistent project instructions for framework rules, forbidden libraries, and type requirements.
• Inline Ghost Text Stepping: Type function signatures with explicit type annotations to force deterministic completions.
Tested GitHub Copilot Templates
Copy, customize, and paste these verified templates directly into GitHub Copilot.
TestingGitHub Copilot
Exhaustive Edge-Case Unit Test Suite
Produces thorough, edge-case resilient unit test suites targeting 100% code coverage.
You are a Principal QA Automation Engineer.
Review the active function and generate an exhaustive test suite covering:
1. Standard happy-path executions
2. Edge cases (null, empty strings, zero, negative values, boundary thresholds)
3. Exception handling and error throwing validation
Constraints:
- Use 'should [expected behavior] when [condition]' test descriptions.
- Mock all database and HTTP boundaries.
Ready to paste
CodingGitHub Copilot
Multi-File Clean Refactor with Copilot Edits
Standard architectural pattern for decoupling database queries into reusable service functions using Copilot.
You are a Senior Systems Architect reviewing our TypeScript codebase.
Context:
The active file handles database operations directly inside API handlers. We need to separate concerns into our service layer.
Task:
Extract database logic into a dedicated function in @/lib/services, refactor the route handler to call it, and supply unit tests.
Constraints:
- Strictly adhere to existing project error handling conventions.
- Maintain full type safety with zero 'any' types.
- Ensure database instances are never exposed to client-side code.
Ready to paste
Skills & Extensions for GitHub Copilot
Supercharge GitHub Copilot with verified MCP servers, plugins, and integrations.