Posted 11/12/2024
GitHub Copilot is getting smarter every month — and both VS Code and Visual Studio offer features beyond simple inline suggestions. Here’s a collection of practical tips, commands, and best practices to get the most out of it.
@workspace – a chat participant that understands your workspace, codebase, and project structure. It’s ideal for explaining code, generating tests, or helping with refactors.
Slash commands – shorthand for common tasks:
/new – create a new file or workspace element
/fix – suggest a fix for the current issue or error
/test – generate unit tests for the selected code
/explain – describe what a method or block of code does
/optimize – refactor or improve performance and readability
/doc – create or update documentation and XML comments
Type / in the chat input to see all supported commands.
Copilot performs best when you give it context. Instead of vague prompts like “optimize this code”, try being explicit:
// Optimize this method for readability and performance.
// Use LINQ and avoid multiple enumerations.
“Refactor this class to use dependency injection but keep public API unchanged.”Copilot can understand your entire workspace when you use @workspace. This is especially powerful for large projects or when working across multiple files.
Tip: You can index your workspace in VS Code settings so Copilot can search and reason across the entire solution.
You can snooze inline suggestions if you want Copilot to stay silent for a while (Ctrl + . → “Snooze”).
In Visual Studio, Copilot is tightly integrated with Solution Explorer — you can invoke it directly on classes or files.