Slash Commands in GitHub Copilot CLI: A Developer's Guide

Slash commands in GitHub Copilot CLI give you explicit, keyboard-driven control over context, scope, and automation. Here's how to use them to speed up your terminal workflow.

Slash Commands in GitHub Copilot CLI: A Developer's Guide

TL;DR

  • Slash commands give you explicit, repeatable control over Copilot CLI without writing new prompts each time
  • Commands like /clear, /cwd, and /model let you manage context, scope, and AI model selection directly from your terminal
  • Security-focused commands (/add-dir, /list-dirs) create auditable boundaries for file access in sensitive environments
  • Advanced commands like /delegate and /mcp enable pull request automation and MCP server configuration without leaving the CLI

The Big Picture

Context switching kills productivity. You're writing code, then jumping to a browser to check docs, then back to your editor, then to a different terminal tab to run tests. Each switch costs time and mental overhead.

GitHub Copilot CLI slash commands solve this by giving you explicit, keyboard-driven control over common workflow tasks without leaving your terminal. Instead of crafting natural language prompts that might be interpreted differently each time, you use predictable shortcuts like /clear to reset context or /delegate to generate pull requests.

This isn't about replacing natural language prompts entirely. It's about having fast, repeatable actions for the things you do constantly: managing file scope, switching AI models, auditing session usage, or sharing your work with teammates.

The real win is predictability. Natural language prompts are flexible but inconsistent. Slash commands always trigger the same response. You know exactly what you're getting, every time. For teams working in regulated environments or handling sensitive codebases, that predictability matters for security and compliance too.

How It Works

Slash commands are prefixed instructions that trigger specific Copilot CLI actions. Type / in the CLI and you'll see an autocomplete list of available commands. Type /help for detailed descriptions.

The architecture is straightforward. Commands fall into five categories: session management, directory and file access, configuration, external services, and utilities. Each category controls a different part of your workflow.

Session management commands like /clear and /usage control conversation history and resource tracking. Copilot accumulates context as you work. That's useful until you switch tasks and old context starts polluting new suggestions. /clear wipes the slate. /usage shows session metrics—model calls, API duration, code changes—which is critical for auditing team usage or debugging unexpected behavior.

Directory and file access commands create explicit boundaries. /add-dir <directory> grants Copilot access to a specific path. /list-dirs shows what's currently allowed. /cwd displays or changes your working directory. This matters for security. Instead of giving Copilot blanket access to your filesystem, you scope it to the repository or subdirectory you're actively working in. For teams in regulated industries, this creates an auditable trail of what Copilot can and can't touch.

Configuration commands let you tune Copilot's behavior. /model switches between AI models—Claude Sonnet, GPT-5.1, Gemini 3 Pro, and others. Different models have different strengths. Claude Sonnet 4.5 is the default, but you might want GPT-5-Mini for faster responses or Claude Opus 4.5 for deeper reasoning. /theme adjusts terminal output for readability. /terminal-setup enables multiline inputs for complex prompts. /reset-allowed-tools clears tool permissions when you need a clean slate.

External services commands integrate Copilot with your broader workflow. /delegate <prompt> generates AI-driven pull requests without leaving the terminal. /share [file|gist] exports your session as markdown or a GitHub Gist for async handoffs or documentation. /mcp manages MCP server configurations for enterprise setups. /user handles multi-account workflows, which is essential if you're switching between personal and service accounts.

The command structure is consistent. Most commands work standalone (/clear, /help) or accept arguments (/add-dir /path/to/repo, /model gpt-5.1). Some commands like /theme and /mcp use subcommands (/theme set dark, /mcp add).

Under the hood, slash commands interact with Copilot's session state, file access permissions, and model selection layer. When you run /add-dir, Copilot updates its allowed directories list and scopes future file operations to those paths. When you run /model, it switches the underlying LLM for subsequent requests. When you run /delegate, it generates a pull request using the current session context and pushes it to your remote repository.

The key architectural decision is explicitness. Unlike natural language prompts, which rely on interpretation, slash commands map directly to specific functions. This makes them faster, more predictable, and easier to script or automate.

What This Changes For Developers

Slash commands shift Copilot CLI from a conversational assistant to a programmable workflow tool. You're not just asking questions—you're issuing commands that integrate directly into your development process.

For solo developers, the immediate benefit is speed. You're working on a feature branch, Copilot suggests code based on old context from a different branch, and the suggestions are off. Instead of writing "please forget the previous conversation and focus only on this file," you type /clear and move on. Two seconds instead of twenty.

For teams, the benefits compound. Security-conscious teams can use /add-dir and /list-dirs to enforce strict file access policies. Instead of trusting that Copilot won't accidentally read sensitive config files, you explicitly define what it can access. Compliance teams can audit /usage logs to track model usage and API calls. DevOps teams can use /mcp to configure CI/CD integrations without leaving the terminal.

The /delegate command is particularly powerful for multi-repo workflows. Say you're applying a security patch across ten microservices. Instead of manually creating ten pull requests, you run /delegate Apply security patch for CVE-2025-1234 in each repo. Copilot generates the PR, you review, and you merge. The time savings scale with the number of repositories.

The /share command changes how you document work. You're debugging a tricky issue, you have a long Copilot session with multiple iterations, and you finally solve it. Instead of manually writing up the solution, you run /share gist and send the link to your team. The entire session—prompts, responses, code changes—is captured as a shareable artifact.

For accessibility, slash commands are a win. Keyboard-driven workflows are faster for power users and essential for developers who rely on assistive technologies. Commands like /help and /list-dirs provide instant discoverability without navigating complex UIs.

The workflow integration is seamless if you're already comfortable in the terminal. If you're used to tools like gh (GitHub CLI) or kubectl, slash commands feel natural. They follow the same pattern: explicit commands with predictable outputs.

Try It Yourself

Start with the three most useful commands: /clear, /cwd, and /model. These give you immediate control over context, scope, and output quality.

Open Copilot CLI and run:

/help

This shows all available commands. Next, check your working directory:

/cwd

If you need to switch to a different project, use:

/cwd /path/to/your/project

Now scope Copilot to a specific directory:

/add-dir /path/to/your/project/src

Verify what directories Copilot can access:

/list-dirs

If you want to experiment with different AI models, run:

/model

This opens an interactive menu where you can select Claude Sonnet 4.5, GPT-5.1, or other available models. Try switching models and comparing responses for the same prompt.

When you're done with a task and want to reset context before starting something new:

/clear

To see session metrics—useful for auditing or debugging:

/usage

For advanced workflows, try generating a pull request:

/delegate Add unit tests for authentication module

Or export your session for documentation:

/share gist

If you're working with MCP servers or need to configure external integrations, explore the /mcp command. For multi-user setups, check out /user show and /user switch.

The full command reference is in the official docs.

The Bottom Line

Use slash commands if you live in the terminal and want explicit control over Copilot's behavior. They're faster than natural language prompts for repetitive tasks, more predictable for security-sensitive workflows, and easier to script or automate.

Skip them if you prefer conversational interfaces or rarely use the CLI. Natural language prompts are still the better choice for exploratory work or one-off questions.

The real opportunity is workflow integration. If you're already using GitHub Copilot CLI for agentic workflows, slash commands make those workflows faster and more repeatable. Commands like /delegate and /mcp turn Copilot into a programmable automation layer, not just a chat interface.

The risk is over-reliance on commands without understanding what they do. /add-dir is powerful, but if you don't verify what directories you've allowed, you might accidentally grant access to sensitive files. /delegate is convenient, but you still need to review the generated pull requests before merging.

Start with /clear, /cwd, and /help. Layer in others as your workflows grow. Use /feedback to tell GitHub what's working and what isn't.

Source: GitHub Blog