GitHub Copilot
2 min read
June 10, 2025

Essential GitHub Copilot Chat Commands and Variables

Master GitHub Copilot Chat with essential commands, chat variables, and expert participants to boost your productivity

By GitHub Copilot
Beginner Level

Essential GitHub Copilot Chat Commands and Variables

GitHub Copilot Chat offers powerful commands and variables to help you code more efficiently. This guide covers essential slash commands, chat variables, and specialized chat participants that can enhance your development workflow.

Quick Reference Guide

Slash Commands

Start your chat with these useful commands:

/explain - Explain how code works
/fix - Get fixes for problems
/tests - Generate unit tests
/doc - Add documentation comments
/new - Create a new project

Example usage:

/explain 
// Your code will be explained in detail

/fix
// Copilot will suggest fixes for highlighted issues

/tests
// Generates comprehensive unit tests for your code

Chat Variables

Include specific context by using these variables:

#file - Include current file content
#selection - Include selected text
#block - Include current code block
#function - Include current function/method
#project - Include project context

Example usage:

Explain how #function works
// Explains the function you're currently in

What dependencies does #file have?
// Analyzes current file's dependencies

How can I improve #selection?
// Gets suggestions for selected code

Expert Chat Participants

Engage specialized experts with @ mentions:

@workspace - For project structure and patterns
@terminal - For shell command help
@vscode - For VS Code features help
@azure - For Azure services guidance

Example usage:

@workspace What's the best place to add this new feature?
// Gets project-aware suggestions

@terminal How do I set up this development environment?
// Gets terminal command guidance

@azure How do I deploy this to Azure?
// Gets Azure-specific deployment help

Pro Tips

  1. Combine Commands and Variables

    /explain #selection
    // Get detailed explanation of selected code
    
  2. Use Project Context

    @workspace Is #file following our project patterns?
    // Gets project-aware code review
    
  3. Get Specific Help

    @vscode What's the best way to debug #function?
    // Gets VS Code-specific debugging tips
    

Best Practices

  1. Start Broad, Then Narrow Down

    • Begin with general queries
    • Use variables to add specific context
    • Engage expert participants for specialized help
  2. Leverage Multiple Tools

    • Combine slash commands with variables
    • Use expert participants for domain-specific questions
    • Reference multiple files when needed
  3. Maintain Context

    • Use #project for broader context
    • Reference specific code with #selection or #block
    • Switch experts when changing domains

Common Scenarios

Code Review

@workspace Review #file for potential improvements
/fix #selection
@terminal How can I test these changes?

Documentation

/doc #function
@workspace How should I document this API?

Project Architecture

@workspace How does #file fit into our architecture?
@azure What's the best way to structure this for Azure deployment?

Working with Multiple Files

Compare implementation between #file and <filename>
@workspace How are these components connected?

Reference

For a complete reference of all available commands and features, visit the GitHub Copilot Chat Cheat Sheet.


Pro Tip: Keep this guide handy while working with Copilot Chat. The more you use these commands and variables, the more natural and efficient your coding workflow will become.

Share this tip:
Related Tips
Understanding GitHub Copilot: Ask Mode vs. Agent Mode

Learn the key differences between GitHub Copilot's Ask and Agent modes and when to use each for maximum productivity

GitHub Copilot 2 min
Automate Project Documentation with GitHub Copilot

Learn how to leverage GitHub Copilot to efficiently write, maintain, and organize your project documentation in the /docs folder

GitHub Copilot 2 min
Level Up GitHub Copilot with copilot-instructions.md

Learn how to use copilot-instructions.md files to enhance GitHub Copilot's code suggestions and align them with your project's standards

GitHub Copilot 2 min
Explore More Tips

Discover more AI productivity tips and tricks

Back to All Tips More from GitHub Copilot