GitHub Copilot Commands: Choose the Right Action for the Task

GitHub Copilot offers chat commands, slash commands, and agent actions that vary by editor and interface. Here is how to find what is available to you, when to use each type, and how to build a library of reusable work prompts.

Updated 4 min read

GitHub Copilot exposes different types of commands depending on where you use it: slash commands in the chat panel, context menu actions in the editor, keyboard shortcuts for completions, and agent mode tasks. The available set varies by editor and by your Copilot subscription. Rather than memorizing every command, the useful practice is to know which type of action fits each kind of task, and to save the prompts and procedures that work so you do not write them from scratch each time. fenbs stores those reusable prompts as Skills so any connected assistant can read them at the start of a session.

Types of Copilot commands

Copilot commands fall into a few categories. Chat slash commands start with / and trigger a specific type of response. Context variables use # to reference a file, selection, or symbol. Agent participants use @ to direct a question to a specific context, such as the workspace or the terminal. Inline completions use keyboard shortcuts rather than text commands.

  • /explain — asks Copilot to explain the selected code or a specific function.
  • /fix — asks Copilot to propose a fix for an error or a highlighted problem.
  • /tests — generates unit tests for the selected code.
  • /doc — generates documentation comments for the selected code.
  • /new — scaffolds a new file or project component.

Not all slash commands are available in all editors. Type / in the chat panel to see the list that is actually available in your current interface. Do not assume a command listed in a tutorial applies to your setup.

Context variables: files, symbols and selections

In VS Code, you can use #file:filename to include a specific file's content in the chat context, and #selection to refer to highlighted code. These let you ask questions about code that is not in the currently active editor file. For example: "What does this method do?" with #file:OrderService.cs in the message gives Copilot the right context to answer accurately.

Discovering what is available to you

The best way to know what commands are available is to open the chat panel and type /. The editor shows a list of recognized commands for your current context. Similarly, right-clicking selected code in the editor shows the Copilot actions available on that selection. Features roll out at different times to different subscriptions and editors, so checking within the tool is more reliable than any external list.

Writing better prompts for recurring tasks

Beyond built-in commands, the most useful Copilot capability is the free-form chat prompt. A well-written prompt for a recurring task — adding logging to a function, writing a migration, reviewing a security-sensitive change — produces consistent results. The prompt you wrote this week should not have to be rewritten next week.

A reusable prompt describes the task, names the conventions to follow, and states any constraint the output must satisfy. It is short enough to paste quickly and specific enough to produce a useful first draft. The difference between a prompt that takes ten tries and one that works on the first is usually the specificity of the constraint.

Agent participants and workspace context

In VS Code with Copilot, you can use @workspace in a chat message to tell Copilot to search the whole repository for relevant context rather than just the open file. @terminal directs a question to the terminal output — useful when you want to ask about a compiler error or a test failure without copying and pasting the stack trace. @vscode answers questions about the VS Code interface itself.

These participants are not available in all versions and not all editors support them. Check which @ participants appear in your chat panel's autocomplete list. Using them when they are available makes the response more relevant, because Copilot is searching the right context rather than guessing from the active file alone.

Inline edit commands

In VS Code, you can invoke an inline chat directly on selected code by pressing the inline chat shortcut (Ctrl+I or Cmd+I on Mac). This opens a small text input anchored to the selection, where you can type an instruction like "add error handling" or "convert to async". The result appears as an inline diff that you accept or reject without leaving the editor. This is faster than switching to the chat panel for a targeted, single-function change.

Use inline edit for changes where the scope is one function or one block. Use the chat panel for tasks that require reasoning about multiple files, for generating tests, or for explaining code. Switching between them based on scope keeps the workflow fast. If an inline edit produces a diff you did not expect, dismiss it and try the same task in the chat panel with more context.

How fenbs helps

Store prompts your team uses with Copilot

Add a fenbs project and save your best Copilot prompts in Skills and prompts. Give each a short name and the full prompt text. Any connected assistant reads them at the start of a session, so every developer on the team uses the same proven procedures rather than starting from scratch each time.

Create a free account

Free for one person · No credit card · Works with Claude, ChatGPT, Cursor and more

How to do this with fenbs

  1. Create a free account and add a project for the codebase you work on with Copilot.
  2. After each session, save the prompts that worked well in Skills and prompts: the name, the full prompt, and a short note on when to use it.
  3. Add Decisions and rules for any standing conventions: the code style, the test requirement, the forbidden patterns.
  4. Connect GitHub Copilot from Integrations. It reads the Skills and rules before the first chat message.
  5. Review and refine the prompt library every few weeks. Remove prompts that no longer fit the project and update ones where your conventions changed.

Questions people ask.

What slash commands does GitHub Copilot support?

The available slash commands depend on your editor and Copilot subscription. Common ones include /explain, /fix, /tests, /doc, and /new. Type / in the chat panel to see the full list available in your current interface, since not every command works in every editor.

How do I reference a specific file in a GitHub Copilot chat message?

In VS Code, use #file:filename in your chat message to include that file's content in the context. You can also use #selection to reference highlighted code in the active editor. The available context variables differ by editor version.

What is the difference between a Copilot slash command and a free-form prompt?

Slash commands trigger a predefined type of response, like generating a test or explaining code. Free-form prompts are plain text questions or instructions. Both are useful. Slash commands are faster for common tasks; free-form prompts are more flexible for specific, complex requests.

Where should I store the Copilot prompts that work well?

In a place every developer on the team can read before starting work. fenbs stores prompts as Skills and prompts that any connected assistant can read at the start of a session. A shared document or a context file in the repository root also works; the key is that the prompts are accessible before work starts, not after.

More in Agent harness (for developers)

All Agent harness (for developers) articles

Start with one thing.

Free for one person · No credit card · Works with Claude, ChatGPT, Cursor and more

There is nothing to set up first. Write one line and you’ve started.