A cheat sheet to slash commands in GitHub Copilot CLI
#DevOps

A cheat sheet to slash commands in GitHub Copilot CLI

Serverless Reporter
7 min read

GitHub Copilot CLI introduces slash commands to streamline terminal workflows, offering explicit control over context, scope, and automation without breaking developer flow.

The GitHub Copilot CLI now includes slash commands—simple, prefixed instructions like /clear or /model—that let you perform predictable actions directly in your terminal. This update addresses a common developer pain point: the friction of switching between tools and crafting repetitive prompts. Instead of writing new natural language instructions for each task, you can use these explicit shortcuts to manage sessions, configure models, control file access, and automate workflows.

Featured image

What slash commands solve

Slash commands in Copilot CLI are designed for terminal-first development. They provide speed and predictability because each command triggers a specific, context-aware action. Unlike natural language prompts, which can be interpreted differently based on phrasing or model state, slash commands always produce the same result. This removes guesswork and makes Copilot's behavior more transparent.

For teams working in sensitive environments, commands like /add-dir and /list-dirs create clear boundaries for file access and maintain an audit trail. This is essential for compliance and security, as it eliminates uncertainty about what Copilot can access. For individual developers, commands like /cwd and /clear help manage context when navigating complex codebases or switching between projects.

Core command categories

Session management

  • /clear: Deletes the current session's conversation history. Use this when switching tasks to prevent context bleed from earlier work.
  • /exit or /quit: Ends the CLI session cleanly, ensuring resource cleanup.
  • /session or /usage: Displays metrics about the current session, including API call duration, code changes, and premium request counts. This is useful for auditing and troubleshooting.

Directory and file access

  • /add-dir <directory>: Grants Copilot access to a specific directory. This scopes Copilot to relevant files and improves security by limiting exposure.
  • /list-dirs: Shows all directories Copilot can currently access, helping verify permissions and troubleshoot access issues.
  • /cwd [directory]: Shows or changes the working directory. This focuses Copilot on the active part of your codebase, improving suggestion relevance.

Configuration

  • /model [model]: Selects an AI model from the available options (e.g., Claude Sonnet 4.5, GPT-5.1, Gemini 3 Pro). This lets you experiment with different models for speed, reasoning depth, or cost optimization.
  • /theme [show|set|list] [auto|dark|light]: Configures the terminal theme for better readability or team standards.
  • /terminal-setup: Enables multiline input, which is helpful for complex instructions or large code changes.
  • /reset-allowed-tools: Resets tool permissions to a clean slate, useful after team changes or demos.

External services and collaboration

  • /agent: Selects a custom agent for specialized tasks or integrations.
  • /delegate <prompt>: Creates an AI-generated pull request directly from the CLI, automating changes across repositories.
  • /share [file|gist] [path]: Exports the session history as a markdown file or GitHub Gist for documentation or async handoffs.
  • /login or /logout: Manages authentication, useful for rotating credentials or switching accounts on shared devices.
  • /mcp [show|add|edit|delete|disable|enable]: Manages Model Context Protocol (MCP) server configurations directly from the terminal, eliminating the need to switch between tools.
  • /user [show|list|switch]: Manages GitHub account switching for multi-user or enterprise environments.

Discovery and feedback

  • /help: Lists all available commands and shortcuts.
  • /feedback: Submits feedback to GitHub about Copilot CLI features or issues.

Practical workflow examples

Switching contexts between projects

When moving from a frontend repository to a backend service, you might need to reset Copilot's context to avoid suggestions referencing the wrong codebase. Use /clear to wipe the session history, then /cwd to change to the new project directory. If the new project has a different AI model preference, use /model to switch. This entire sequence takes seconds without leaving the terminal.

Securing sensitive codebases

For enterprise teams working with proprietary code, /add-dir ensures Copilot only accesses approved directories. Running /list-dirs periodically verifies that permissions are correctly scoped. If a team member rotates roles, /reset-allowed-tools can quickly remove outdated tool permissions.

Automating repetitive tasks

Instead of writing a long prompt to generate a pull request for a common change (like adding dark mode), you can use /delegate Add dark mode support. This creates a PR in the remote repository without manual intervention. For multi-repo workflows, this command can be scripted or combined with other CLI tools.

Documenting sessions

When collaborating asynchronously, /share file <path> exports the entire session history as a markdown file. This is useful for attaching context to issues or pull requests, or for documenting decisions made during a debugging session.

Trade-offs and considerations

While slash commands improve predictability, they require learning a new set of commands. The /help command provides a quick reference, but teams may need to create internal documentation for custom workflows. Additionally, some commands (like /model) change behavior globally for the session, which could affect other team members if the CLI is shared.

For teams in regulated industries, the audit trail provided by /session and /usage is valuable, but it requires monitoring. The /share command can expose session data, so teams should establish guidelines for what can be exported.

Getting started

To try slash commands, install the GitHub Copilot CLI and open it in your terminal. Type / to see the available commands. Start with /clear, /cwd, and /help to get familiar with the workflow. As you build more complex tasks, layer in commands like /model or /delegate.

For more details, refer to the official Copilot CLI documentation. You can also explore the Copilot feature page for broader context on AI-assisted development.

Decorative illustration featuring Ducky inside a translucent cube surrounded by green geometric blocks.

Quick reference

Slash command What it does When to use
/clear Clears session history/context Shift tasks, reset Copilot’s context, resolve confusion
/exit, /quit Exits the Copilot session Finish a session, reset the CLI
/session, /usage Shows current session and usage stats Audit activity, monitor Copilot CLI usage
/add-dir <directory> Adds allowed directory for file access Limit scope, improve security/auditing
/list-dirs Lists directories Copilot can access Confirm or manage file access permissions
/cwd [directory] Changes/outputs the working directory Navigate projects, limit Copilot context
/model [model] Changes Copilot AI model for the CLI Experiment, troubleshoot, optimize model behavior
`/theme [show set list]`
/reset-allowed-tools Resets allowed external tools Remove tool permissions, reset for audits
/agent Selects a custom Copilot agent When using specialized agents by repo/org
/delegate <prompt> Delegates changes as a PR in a remote repository Automate changes, multi-repo workflows
`/share [file gist]` Shares session as markdown or GitHub Gist
/login, /logout Sign in/out of Copilot in the CLI Change user, rotate credentials
`/mcp [show add edit
`/user [show list switch]`
/help Lists all CLI commands and shortcuts Onboarding, discoverability
/feedback Submit feedback about Copilot CLI Share suggestions or bug reports with GitHub

A decorative image of the GitHub Copilot logo.

Broader implications

Slash commands represent a shift toward more explicit, tool-driven AI assistance. Instead of relying solely on natural language prompts—which can be ambiguous and context-dependent—developers gain deterministic control over Copilot's actions. This aligns with the broader trend in cloud architectures toward event-driven, FaaS-like interactions where each command triggers a specific, auditable function.

For teams adopting Copilot CLI, slash commands reduce the learning curve for new users and standardize workflows across the organization. They also enable better integration with existing CLI tools and scripts, making Copilot a more seamless part of the development pipeline.

As slash command capabilities expand, expect deeper integrations with CI/CD systems, custom agents, and third-party services. The /mcp command already hints at this, allowing direct management of MCP servers from the terminal. This could evolve into a full ecosystem of plugin-like commands that extend Copilot's functionality without requiring a separate UI.

In summary, slash commands in Copilot CLI are a practical step toward making AI assistance more predictable, secure, and integrated into terminal workflows. They address real pain points in developer productivity while maintaining the flexibility to adapt to evolving needs. For teams looking to optimize their development process, this feature offers immediate value with minimal overhead.

Comments

Loading comments...