🤖 AI Hot

GitHub Copilot Slash Commands: A Beginner's How-to Guide

A
Alex Chen

If you are still typing out full sentences to tell Copilot what you want, you are working harder than you need to. GitHub Copilot has an entire vocabulary of slash commands that condense common requests into a few keystrokes. Most developers I talk to know about /explain and /fix and stop there. There are at least two dozen more, and some of them—/orchestrate, /compact, /plan—change how you interact with the tool entirely.

I have been using Copilot across VS Code and the CLI for about a year now. This guide covers every slash command I have found useful, organized by where you use them and what they actually do. No filler, no AI-generated fluff about “unlocking productivity.” Just the commands, what they do, and when you should reach for them.

The Two Slash Command Ecosystems

It helps to think of Copilot’s slash commands as belonging to two separate worlds: IDE chat commands and CLI terminal commands. They serve different purposes but the syntax is the same—type / and pick from the list.

IDE commands work inside VS Code, JetBrains, or the GitHub Copilot app. They operate on your codebase: files, diffs, terminal output, and tests.

CLI commands run in your terminal through the gh copilot CLI or the Copilot shell agent. They operate on your filesystem: directories, shell commands, and git operations.

Some commands exist in both contexts (/explain), but most are exclusive to one or the other. I will cover both.

IDE Chat Slash Commands: The Core Set

These are the ones I use every day inside VS Code.

/explain — The Entry Point

Type /explain followed by a code selection and Copilot breaks down what the code does. I use this constantly when reading unfamiliar codebases. It does a better job than I expected at tracing async flows and callback chains.

You can target specific elements: /explain #file:auth.ts or just highlight a block and run it. The explanations are decent at giving you a mental model, though they occasionally hallucinate intent for clever or convoluted code.

/fix — Quick Patches

/fix takes a selection or a file and proposes changes. It handles lint errors well and does a reasonable job with type mismatches. For anything involving business logic or state management, treat its suggestions as a starting point, not a final answer.

/tests — Test Generation

/tests generates unit tests for the selected function or class. The quality varies by language and framework. For JavaScript with Jest and Python with pytest, I have gotten useful output maybe 70% of the time. For Rust and Go, the generated tests more often miss edge cases around ownership and concurrency.

One thing I have learned: always specify the test framework. /tests using vitest produces much better output than /tests alone.

/doc — Documentation Generation

Adds docstrings or JSDoc comments to your code. Works well for straightforward functions. Falls apart when your function has side effects it cannot infer from the signature alone—you will get a clean-looking docstring that misses half the actual behavior.

/simplify — Refactoring Aid

Asks Copilot to rewrite code to be more readable. Hit or miss. Sometimes it genuinely improves things. Sometimes it just renames variables and calls it a day. I use it as a quick “fresh eyes” pass before I do the real refactor myself.

Context Management Commands

/new starts a fresh chat session. /clear wipes the current context but keeps the session alive. I use /new when switching tasks to avoid context pollution.

/compact is newer and more interesting. It summarizes the current conversation to compress the context window. This lets you keep working on the same task without hitting the token limit. For long debugging sessions or multi-file refactors, /compact can save you from starting over mid-stream.

Agentic Commands (GitHub Copilot App)

The Copilot app introduced a set of commands that move beyond Q&A into autonomous work. These are the ones worth learning:

/plan asks Copilot to break a task into steps before executing. This is useful for multi-file changes where you want visibility into what it is about to do before it touches your code. I use /plan for anything involving more than three files.

/orchestrate takes this further—it splits work across multiple focused efforts and coordinates them. For larger features, /orchestrate can identify parallel workstreams and move them forward together. If you are preparing a feature for release (implementation, testing, documentation, deployment), this command maps out all four tracks.

/autopilot puts Copilot into a mode where it continues working with less interaction. It is meant for bounded, well-defined tasks. The key word is “bounded”—do not use this for open-ended exploration or anything involving production infrastructure.

/review runs Copilot’s PR review capabilities on the current changes. It catches style issues and obvious bugs reliably enough to be worth the keystroke, though it will not replace a human reviewer for architecture concerns.

CLI Terminal Slash Commands

The CLI has its own command set, and some of them do things the IDE version cannot.

/help lists all available slash commands in the current mode. I run this once a week to see if anything new has appeared—the list grows faster than I can keep up with.

/list-dirs and /list-files browse the filesystem without leaving the terminal. These are accessibility features first, but they are also convenient when you are SSH’d into a server without a file tree view.

Git Operations

/pr creates or updates pull requests from the CLI. /commit generates a commit message from staged changes. I use /commit regularly but always edit the output—Copilot tends toward verbose, generic messages that do not actually describe what changed.

Session Modes

The CLI has three session modes that change how Copilot behaves. You switch between them with their corresponding slash commands:

/standard is the default. Copilot responds to each prompt and waits for your next instruction. Use this for tight steering and when you are exploring.

/plan mode makes Copilot think through multi-step work before touching anything. Same idea as the IDE /plan command, but it applies to all subsequent interactions until you switch modes.

/autopilot mode lets Copilot continue working through a task with less back-and-forth. It is the CLI equivalent of the app’s autopilot. Good for “refactor all the API routes to use the new error handler” type tasks where you know exactly what you want.

Permission and Safety Commands

/reset-allowed-tools revokes all permissions you previously granted. I use this when switching between repos—a project where I let Copilot edit files freely might not be one where I want the same level of trust.

/permissions shows what Copilot currently has access to. Worth checking periodically, especially after a long session where you might have granted more access than you remember.

Slash Commands I Actually Use vs. Ones I Skip

If I had to pick a top five based on how often I reach for them:

  1. /explain — daily, multiple times
  2. /tests — whenever I write new functions
  3. /plan — before any non-trivial multi-file change
  4. /compact — during long sessions
  5. /commit — at the end of every work chunk

The ones I rarely use: /simplify (too unpredictable), /doc (I prefer writing my own), and /autopilot (requires more trust than I have for production code).

What Slash Commands Cannot Do

It is worth being clear about the limits. Slash commands are shortcuts for prompting patterns, not magic. They cannot:

  • Understand your architecture decisions or why you chose one pattern over another
  • Know your team’s conventions unless they are documented in the repo
  • Guarantee correctness for /fix or /tests output
  • Replace code review or manual testing

The commands that work best are the ones where you bring specific knowledge and Copilot brings speed. /explain works because you can verify its output against the actual code. /tests works when you already know what edge cases matter and can spot what it missed.

Common Pitfalls and How to Avoid Them

After a year of using these commands, here is what regularly trips people up.

Context window blindness. Copilot’s context window is finite, and slash commands do not change that. If you have been chatting for 30 minutes about auth middleware and then run /explain #file:payment.ts, Copilot still has all that auth context filling its window. The explanation might be colored by irrelevant history. Run /new before switching topics.

Trusting /fix on stateful code. Copilot sees the function body, not the state transitions across your app. A /fix on a Redux reducer or a Zustand store might compile and still introduce a subtle state bug. I let /fix handle lint and type errors but review anything touching state myself.

The auto-accept trap. When you run /tests and the generated tests pass, the instinct is to commit. Do not. Generated tests often test the implementation rather than the behavior—they assert that fetchUser(3) calls the API with ID 3, not that the function handles a 404 or a network timeout. Always add your own edge case tests on top of what Copilot generates.

Forgetting /permissions. I once granted Copilot file write access in a side project, forgot about it, and then ran commands in my main work repo assuming it was sandboxed. It was not. Now I run /permissions at the start of every session and /reset-allowed-tools when I switch projects.

A Full Workflow Example

Here is how these commands fit together in a real session. Say you are adding pagination to an API endpoint.

Start with /new to get a clean slate. Run /explain #file:routes/users.ts to understand the existing endpoint structure. Then /plan "add cursor-based pagination to the GET /users endpoint, with a limit parameter defaulting to 50". Copilot lays out the steps: modify the route handler, update the query function, add pagination metadata to the response, write tests.

You review the plan, and it looks reasonable. Execute the changes. Then run /tests using vitest on the modified files. Review the generated tests, add missing edge cases for empty results and invalid cursors. Run /review to check the diff for obvious issues. Finally /commit to generate a message, edit it to be specific, and push.

The whole thing takes maybe 15 minutes for a feature that would have been 45 without the commands. The speed comes from not having to type out “explain this code” or “write tests for this” in full sentences—not from trusting the AI blindly.

Getting Started Without Memorizing Everything

You do not need to memorize commands. Type / in the chat box or terminal and Copilot shows you what is available. Pick a few that match your workflow and build from there.

I suggest starting with /explain, /tests, and /plan. Those three cover understanding code, verifying it, and planning changes—the core loop of most development work. Once those feel natural, add /compact for longer sessions and /orchestrate for larger features.

The slash command system is still evolving. GitHub adds new ones regularly, and the Copilot app commands in particular are expanding fast. The /help command is your friend here—run it every couple of weeks to see what showed up.


Sources:

Disclosure: CarCare Guide is reader-supported. When you buy through links on our site, we may earn an affiliate commission at no extra cost to you. Learn more.
A
Alex Chen