Copilot Chat
From the course GitHub Copilot Mastery
Copilot Chat is a conversational AI assistant built into your editor, purpose-built for coding tasks.
Chat Locations
- Chat panel — Side panel for extended conversations
- Inline chat — Ctrl+I to chat about specific code in context
- Quick chat — Ctrl+Shift+I for fast questions without opening a panel
Slash Commands
Copilot Chat has powerful built-in commands:
- /explain — Explain selected code in plain language
- /tests — Generate unit tests for selected code
- /fix — Propose a fix for bugs or errors
- /doc — Generate documentation or comments
- /optimize — Suggest performance improvements
- /new — Scaffold a new project or file
- /newNotebook — Create a Jupyter notebook
Context Variables
Reference specific context with # mentions:
- #file — Reference a specific file
- #selection — Reference selected code
- #editor — Reference the current editor content
- #terminalLastCommand — Reference the last terminal output
- #terminalSelection — Reference selected terminal text
Example: "Using #file:schema.prisma, generate TypeScript types for the User model"
Practical Examples
Debug an error:
I'm getting "Cannot read properties of undefined" on line 42. Here's the error from #terminalLastCommand. What's wrong?
Refactor code:
Refactor #selection to use the Strategy pattern. Keep the same public API.
Learn a library:
How do I use React Query's useMutation with optimistic updates? Show me an example using #file:api.ts
Generate tests:
/tests for #file:auth.service.ts — include edge cases for expired tokens and invalid credentials
Key Takeaways
- •Copilot Chat provides conversational coding help directly in the editor
- •Slash commands (/explain, /tests, /fix, /doc) handle common tasks instantly
- •# context variables reference files, selections, and terminal output
- •Inline chat (Ctrl+I) is the fastest way to modify specific code sections
Progress is kept in this browser only.