Command | Description | Example |
---|---|---|
/fix |
Ask Copilot to fix issues in your code | /fix This code has a bug where it doesn't handle empty arrays |
/explain |
Request an explanation of selected code | /explain What does this regex pattern do? |
/tests |
Generate tests for selected code | /tests Generate unit tests for this function |
/doc |
Generate documentation for selected code | /doc Create JSDoc for this function |
/optimize |
Suggest optimizations for your code | /optimize This function is slow with large inputs |
/clear |
Clear the current conversation | /clear |
Command | Description | Example |
---|---|---|
@workspace |
Reference your entire workspace | How do I use the User class from @workspace? |
@file:<path> |
Reference a specific file | Help me understand @file:src/utils/helpers.js |
@selection |
Reference currently selected code | Refactor @selection to use async/await |
@clipboard |
Reference content in clipboard | Create tests for @clipboard |
#<n> |
Reference a specific message | Can you elaborate on what you meant in #2? |
Intent | Description | Example Prompt |
---|---|---|
Generate | Create new code from scratch | Generate a React component for a navigation bar |
Complete | Finish partially written code | Complete this function to parse CSV data |
Transform | Convert code from one form to another | Convert this JavaScript function to TypeScript |
Refactor | Restructure existing code | Refactor this to use the strategy pattern |
Debug | Find and fix issues in code | Debug why this function throws on empty input |
Explain | Understand what code does | Explain this recursive algorithm |
Good: Generate a Python function using pandas that cleans CSV data by removing duplicates
Bad: Write a function to process data
Good: Our app uses Express for routing. Add an endpoint to handle user registration
Bad: Add a signup endpoint
`variable_name`
```code here```
The function should convert "2023-01-15" to "Jan 15, 2023"
Let's refine this further by adding error handling
Generate a solution that doesn't use external libraries
This needs to be compatible with Python 3.8+
Refactor this function to use async/await, then optimize it for performance
/explain this code, then @workspace how it integrates with our authentication system
Generate a function and provide example usage as comments
Let's refine this further by adding error handling
Tab
to accept suggestionsCtrl+I
(Windows/Linux) or Cmd+I
(Mac)Alt+/
(Windows/Linux) or Option+/
(Mac)@github-copilot
in PR comments/clear
to start fresh