The Chat Experience in Practice: Chat Participants and Shortcuts
Practical Examples
Copilot as Your Terminal Assistant
Whether you're using Windows, MacOS, or Linux, you can ask Copilot how to perform tasks in your terminal. This can be anything from installing an npm package, running a complex git command, creating a file, finding text in files, finding a process ID, or any other terminal-related task.
To perform such a task, use the following syntax:
@terminal [Your question or instruction]
Example:
@terminal How do I install the Click package in Python?
The answer will include the command you need to run. You can either copy it or click on the "Insert into terminal" button to run it directly in the terminal.
GitHub Copilot Terminal
Asking Questions About Your Workspace
We've seen that Copilot can use the context of open files or those selected as context. However, if you want to ask questions about your entire workspace, it could be tricky to drag and drop all the files into the chat window. This is where the @workspace command comes in handy.
When you type @workspace in a chat prompt, the Copilot extension gathers context from your entire local project (open workspace in VS Code) - not just the current file. So instead of feeding the remote LLM only the prefix/suffix of the active file, Copilot’s prompt-builder (an internal component tool that prepares the prompt for the LLM) includes:
- File paths from the VS Code workspace.
- File metadata from the VS Code workspace.
- Imports and symbols relevant across the workspace.
- Recent changes in the workspace.
- And more.
Here's how to ask questions about your entire workspace:
@workspace ["Your question"]
For example:
@workspace Where is the definition of the function "calculate_average"?
@workspace How to better organize my code in this project?
@workspace Is my project structure following the best practices?
@workspace Write a form validation function for the form in "form.html".
@workspace How to start the web server for the development environment?
If you ask a question without specifying the @workspace command, Copilot will try to provide an answer from the open files in the editor, using some special files like the custom instructions file and by scanning key files in the codebase, such as README.md, package.json, or requirements.txt. However, using the @workspace command ensures that Copilot considers the entire project context.
Try It Yourself: Start by cloning the spring-projects/spring-petclinic project locally by executing the following command:
git clone https://github.com/spring-projects/spring-petclinic.git
Then, go to the root directory of the project:
cd spring-petclinic
Open VS Code and initiate a chat session with Copilot:
code .
Spring PetClinic is a simple application that demonstrates the use of the Spring Framework in a real-world scenario. The application manages a pet clinic, including the management of pets, owners, and more. Our goal through this exercise is to understand the following 10 points:
- How is the project structured?
- What are the main technologies used in the project?
- Are there any specific requirements to install before running the application locally?
- What does the application do? What are its main features?
- Ask Copilot to summarize the README file of the project and provide only the main points in an easy-to-understand way.
- How can the application be run locally?
- How can a Docker image for the application be created?
- What are the current issues in the project?
- Choose an issue and ask Copilot to provide a solution.
- If the issue is fixed, ask Copilot to contribute the fix to the project.
Hint: Use the @workspace command to formulate your questions, provide more context to Copilot, and receive accurate answers. You can iterate on your questions and enhance them based on the outputs you receive.
For example, this is what Copilot might respond when you ask the first question (@workspace How is the project structured?):
The project follows a typical Spring Boot application structure with the following key directories and files:
- Root Level: Contains build files (pom.xml, build.gradle), Docker configuration (docker-compose.yml), wrapper scripts for Maven and Gradle, and documentation (README.md, LICENSE.txt).
- .github/: Contains GitHub workflow files for CI/CD.
- .devcontainer/: Configuration for development containers.
- src/: Main source code and resources.
- src/main/java/: Java source files, organized by package (e.g., OwnerController.java).
- src/main/resources/: Application resources, including Thymeleaf templates (e.g., ownersList.html, layout.html), static assets, and configuration files.
- src/test/: Test source code.
- src/checkstyle/: Code style configuration.
- k8s/: Kubernetes deployment files.
The application is modular, separating controllers, models, repositories, and templates. It uses Maven or Gradle for building, supports Docker and Kubernetes for deployment, and includes configuration for CI/CD and development environments.
For more details, see the README.md file.
To get a more detailed answer, you can ask follow-up questions like:
@workspace Can you provide more details about each of these directories and files?
@workspace What are the main classes and their responsibilities in the project?
Asking Questions About VS Code
If you're using Visual Studio Code, you can ask Copilot questions about the editor itself. These questions can be about settings, extensions, shortcuts, or any other feature of VS Code.
To use this feature, you need to start your prompt with @vscode. For example, if you need to change the theme in VS Code, you can ask Copilot the following question:
@vscode How do I change the theme in Visual Studio Code?
The answer might include the steps to change the theme, and in many cases, it will include a button that you can click to accomplish the task directly in the editor. This useful feature can save you time and help you learn more about VS Code.
Changing Theme in VS Code
Try It Yourself: Ask Copilot the following questions about VS Code:
- How do I add vertical rulers in Visual Studio Code, and when is it useful?
- Can you provide a list of the most useful keyboard shortcuts in Visual Studio Code?
- How do I compare files in Visual Studio Code (diff)?
- How do I create extensions for Visual Studio Code?
- How do I create a new theme for Visual Studio Code?
- How do I use the integrated terminal in VS Code?
- What are the most useful extensions for Python development in VS Code?
- How do I "beautify" code in VS Code?
- List some useful settings to improve productivity in VS Code.
- How do I manage multiple Git accounts in VS Code?
Web and Code Search to Get Up-to-Date and Relevant Answers
GitHub Copilot, like any other assistant, is trained on a large dataset, but the training data has a cutoff date. For example, GPT-5's knowledge cutoff date is October 1, 2024, while gpt-5-mini and gpt-5-nano have a cutoff of May 31, 2024. The model you're using might have a different cutoff date. Therefore, a model is never aware of any information that was created after its cutoff date unless it has access to the web.
Copilot, fortunately, has a feature that can answer questions by grounding its responses in three types of sources:
Web search: Retrieves up-to-date information from the internet to answer general or technical questions.
Examples:
# Use `#web` to trigger a web search
@github #web What's the latest stable version of Python?
# Or use a more natural prompt
@github Search the web for the latest stable version of Python.
Code search: Looks through public GitHub repositories to find relevant code examples or definitions.
Example:
@github Search GitHub for examples of how to generate an image using OpenAI GPT-5
Enterprise knowledge base: If your organization has Copilot for Business or Enterprise, it can also include private documentation, wikis, and code repositories configured as part of your internal knowledge system.
You can also ask Copilot to generate a wiki page for your project based on the code in your workspace. You can then use this wiki page as a source of information and context for the assistant to make it faster and more accurate. To do this, you need to grant Copilot access to your internal knowledge base. This is described in detail in the official documentation.
Here are some examples of questions you can ask when you have these features enabled:
@github How do we handle user authentication in our project?
@github How to integrate with "Team X" API in our codebase?
@github Who are the main contributors to "project X" in our organization?
@github Does this project follow a microservices architecture?
# ..etc.
To explore more about @github commands, you can ask Copilot the following question:
@github What are the available tasks I can perform using the @github command?
At the time of writing, with the @github command, you can perform a variety of tasks related to repositories, issues, pull requests, workflows, and more, including:
Repositories
- Create, delete, or update repositories.
- Fork a repository.
- List branches, tags, and commits.
- Star or unstar repositories.
- Manage repository notifications.
Issues
- Create, update, and close issues.
- Add comments to issues.
- Assign issues to users.
- List and search for issues.
- Add or remove sub-issues.
Pull Requests
- Create, update, and close pull requests.
- Merge pull requests.
- Request or manage reviews for pull requests.
- Add comments or reviews to pull requests.
- Get the status, files, or diffs of pull requests.
Files & Code
- Create, update, or delete files.
- Search for code within repositories.
- Perform semantic code searches.
- Get the contents of files or directories.
Workflows & Actions
- List workflows and workflow runs.
- Trigger or rerun workflows.
- Cancel workflow runs.
- Get logs and artifacts for workflows.
Notifications
- View notifications (e.g., issues, pull requests, reviews).
- Dismiss notifications or mark them as read.
- Manage notification subscriptions for repositories or threads.
Projects
- Create or update issues or pull requests in projects.
- Manage project items (add, delete, or reprioritize).
Security
- List or manage Dependabot alerts, secret scanning alerts, and code scanning alerts.
- Get details about security advisories.
Discussions
- List discussions and categories.
- Get or add comments to discussions.
Gists
- Create, update, or list gists.
Teams & Organizations
- List teams and their members.
- Search for organizations or users.
Copilot Features
- Assign GitHub Copilot to work on issues.
- Leverage semantic code searches and AI-powered reviews.
Try It Yourself: Ask Copilot to perform the following tasks using a mix of regular and @github queries:
- Create a "Hello World" app in your workspace.
- Create an empty private repository in your GitHub account, initialize the current workspace as a git repository, and add the remote URL of the repository you just created.
- Add all files in the current workspace to the staging area.
- Commit the changes with a meaningful message.
- Push the changes to the main branch of the remote repository.
- Create a new issue in the repository you just created.
- List all issues in the repository.
- Create a new branch called
feature-1and switch to it. - Add a README.md file to the repository with a project description.
- Create a pull request to merge the
feature-1branch into themainbranch.
Explaining Code and Commands
One of the most useful features of Copilot is its ability to explain code. This can be particularly powerful when you're working with different programming languages, frameworks, or libraries that you're not familiar with, or when the code is not well documented.
To do this, the best way is to use the /explain slash command followed by the context. You have two options here:
- Use the
/explaincommand with the workspace context. - Use the
/explaincommand with the command line context.
The first option is used to explain how the code in your active editor works. It is used by typing:
@workspace /explain [Your question (optional)]
Let's examine an example before we move on to the second option. Start by creating a folder called myworkspace and a file called main.py inside it. Add the following code to the main.py file:
import random
def generate_secret_code():
return [random.randint(0, 9) for _ in range(4)]
def get_user_guess():
while True:
guess = input("Enter four digits: ")
if len(guess) == 4 and guess.isdigit():
return [int(digit) for digit in guess]
print("Invalid.")
def provide_feedback(secret_code, user_guess):
hits = sum(
1 for i in range(4) if user_guess[i] == secret_code[i]
)
blows = sum(
min(
user_guess.count(digit), secret_code.count(digit)
) for digit in set(user_guess)
) - hits
return hits, blows
def game():
secret_code = generate_secret_code()
print("Enter the secret:")
attempts = 0
while attempts < 10:
user_guess = get_user_guess()
hits, blows = provide_feedback(
secret_code,
user_guess
)
if hits == 4:
print(f"Congratulations! {attempts + 1} tries.")
break
print(
f"Attempt {attempts + 1}: {user_guess} - "
f"Hits: {hits}, Blows: {blows}"
)
attempts += 1
if attempts == 10 and hits != 4:
print(f"Game over! {secret_code}.")
if __name__ == "__main__":
game()
The code is a simple implementation of a number guessing game. The computer generates a secret code consisting of four random digits, and the player has ten attempts to guess the code. After each guess, the player receives feedback in the form of "hits" (correct digits in the correct position) and "blows" (correct digits in the wrong position). If the player guesses the code correctly within ten attempts, they win; otherwise, the game ends with a reveal of the secret code.
Our objective is to understand how this game functions and whether it has a name. To provide a general explanation of the code, you can use the following command:
@workspace /explain Explain the code in my workspace in a very concise way.
Or simply:
@workspace /explain
Copilot will strive to select the most crucial blocks of your code and explain them in a clear, concise manner. However, if you need to explain a specific part of the code, you can select it and repeat the same command.
To identify the name of the game, you can pose a more specific question:
@workspace /explain What is the name of the game in this code?
The second option is used to explain a terminal command, such as git commands and Docker CLI commands. It is used by typing:
@terminal /explain [Your question (optional)]
For example, if you type the following command:
./mvnw spring-boot:run -Dspring-boot.run.profiles=postgres
Then, you can ask Copilot to explain this command by typing:
@terminal /explain Where should I run this command, and what does it do?
Copilot will provide an answer based on the context of the command you've typed and its output.
Example:
The last command attempted to start a Spring Boot application using Maven with the postgres profile.
However, it failed because the JAVA_HOME environment variable is not set correctly. Maven requires JAVA_HOME to point to a valid Java installation to run Java-based projects.
Fixing Problems
Another useful slash command you can use with Copilot is /fix. This command is used to ask Copilot to fix a problem in your code. Syntax errors, logical errors, performance issues, security vulnerabilities, or any other problem.
The fix command will automatically include the workspace as a context (when you run /fix, Copilot will convert it to @workspace /fix). The command is also executed against the current open files in the editor or any code snippet you selected.
Let's see an example with a simple code snippet that has a security vulnerability:
import sqlite3
def connect_db():
"""Connect to the SQLite database."""
return sqlite3.connect('example.db')
def get_user_data(username):
"""Fetch user data from the database based on username"""
connection = connect_db()
cursor = connection.cursor()
query = f"SELECT * FROM users WHERE username = '{username}'"
cursor.execute(query)
result = cursor.fetchall()
cursor.close()
connection.close()
return result
def mainBuilding with GitHub Copilot
From Autocomplete to Autonomous AgentsEnroll now to unlock all content and receive all future updates for free.


