GitHub Blog

GitHub Copilot CLI 初学者指南:常用斜杠命令概览

本文概述了 GitHub Copilot CLI 中的斜杠命令,这些内置控制可用于引导 Copilot 行为、管理上下文、切换模型、检查更改、导航项目和管理权限。关键命令包括 /model、/context、/compact、/clear、/resume、/diff、/cwd 和 /reset-allowed-tools。文章强调掌握这些命令可以提高 CLI 工作流的效率和可控性。

状态已摘要
抓取快照1
AI 输出2
开放问题0

已验证摘要

英文摘要

GitHub Copilot CLI for Beginners: Overview of common slash commands

This article provides an overview of slash commands in GitHub Copilot CLI, which are built-in controls for guiding Copilot's behavior, managing context, switching models, inspecting changes, navigating projects, and managing permissions. Key commands include /model, /context, /compact, /clear, /resume, /diff, /cwd, and /reset-allowed-tools. The article emphasizes that mastering these commands enhances efficiency and control over the CLI workflow.

  • Slash commands act as a control surface within Copilot CLI, accessible by typing '/'.
  • Use /model to switch between different AI models with varying capabilities and costs.
  • Manage context window usage with /context (check tokens) and /compact (summarize conversation).
  • /clear resets the session, and /resume lets you pick up previous sessions.
  • Inspect file changes with /diff and navigate directories with /cwd.
  • Reset tool permissions with /reset-allowed-tools for safety in different projects.
  • Familiarity with slash commands improves workflow efficiency and control.

中文摘要

GitHub Copilot CLI 初学者指南:常用斜杠命令概览

本文概述了 GitHub Copilot CLI 中的斜杠命令,这些内置控制可用于引导 Copilot 行为、管理上下文、切换模型、检查更改、导航项目和管理权限。关键命令包括 /model、/context、/compact、/clear、/resume、/diff、/cwd 和 /reset-allowed-tools。文章强调掌握这些命令可以提高 CLI 工作流的效率和可控性。

  • 斜杠命令是 Copilot CLI 中的控制面板,输入 '/' 即可访问。
  • 使用 /model 在具有不同能力和成本的 AI 模型间切换。
  • 通过 /context 检查令牌使用情况,/compact 总结对话以释放上下文空间。
  • /clear 重置会话,/resume 恢复之前的会话。
  • 用 /diff 查看文件更改,用 /cwd 切换工作目录。
  • 使用 /reset-allowed-tools 重置工具权限,确保在不同项目中的安全。
  • 熟悉斜杠命令可以提升工作流的效率和可控性。

GitHub Copilot / CLI / slash commands / command line / productivity / AI tools / developer tools / GitHub

完整文章

Kayla Cinnamon · @cinnamon-msft

June 15, 2026|

4 minutes

Share:Welcome back to GitHub Copilot CLI for Beginners! In this series (available in video and blog format), we’ll give you everything you need to get started using GitHub Copilot CLI . So far in this series, we’ve covered how to get started and when to use interactive and non-interactive modes . In this edition, we’ll learn what slash commands are, why they matter, and how to use slash commands to control GitHub Copilot efficiently. You can complete tasks like switching models, checking token usage, and resuming past sessions right from your terminal.Let’s dive in!Understanding slash commands in GitHub Copilot CLIWhen working in Copilot CLI, one of the most powerful concepts to learn early on is slash commands. Slash commands are built-in controls that you can access directly from the command line. Acting as your control surface within Copilot CLI, slash commands allow you to:Guide Copilot’s behaviorInspect changesManage contextMove efficiently across sessions and projectsKeep permissions tidySlash commands can be thought of as your command center for interacting with Copilot CLI. To look at all of the options available, just type / in the command line for a scrollable list of all currently supported slash commands.Let’s take a look at some of the most popular ones.Choosing the right modelDifferent models are optimized for different kinds of work. If you want to switch models, type /model into the command line. This will display a list of available models, along with key details like:Capabilities : Some are better for quick, lightweight tasks like refactoring, while others more efficiently handle deeper reasoning such as feature planning.Availability : The list may vary depending on your plan or organization’s settings.Cost : Numbers shown on the right of each model indicate cost multiplier, helping you choose the right balance between performance and usage in relation to your plan.Choosing the right model can significantly impact both speed and results.Managing context and token usageCopilot CLI operates within a context window, which determines how much information it can “remember” during a session. If you want to check your current usage, type /context to learn how many tokens you have left, along with system usage and available buffer.If you find that you’re running low on space, you can free up space by typing /compact in the command line. This summarizes your current conversation so you can continue without having to start a new session. Copilot CLI will do this automatically when you approach the limit, but you can also do this manually if you want to transition to a new task or clean up context mid-session.If you’d rather start fresh and completely reset your environment, you can use /clear to clear the session entirely.Working across sessionsIf you want to resume a previous session, you can type /resume . This will bring up a list of previous sessions you’ve had, including both local and remote sessions. Entering a previous session will show you your session history, and you can pick up right where you left off.Inspecting changesAs you work with Copilot to make changes to your project, it’s important to keep track of what’s changed. If you want to see what the changes are, run /diff to see recent updates. This gives you a clear view of what modifications were made during your session, so you can validate changes before moving forward.Navigating projects and directoriesIf you want to work across repositories or directories, you don’t have to exit Copilot. You can type /cwd to change your working directory to another repository. This allows you to scope Copilot’s work to a specific part of your project and helps you stay efficient while multitasking across codebases.Managing tool permissionsIn the past, you might have granted Copilot CLI permission to perform actions like editing files. Say you’re switching to a repository you want to be more careful in and want to reset those permissions: you can do so by running /reset-allowed-tools .Take this with youUsing these slash commands gives you even better control over Copilot CLI—and the more familiar you become with them, the more deliberate your workflow becomes.Whether you’re switching models, managing context, or navigating across projects, using slash commands in CLI gives you the tools you need to stay in control. And if you haven’t already: open up your terminal, type / , and explore! There are many more slash commands to discover.Happy coding!Looking to try GitHub Copilot CLI? Read the docs and get started today.More resources to explore:GitHub Copilot CLI for Beginners video seriesGitHub Copilot CLI for Beginners: Getting started with GitHub Copilot CLIGitHub Copilot CLI for Beginners: Interactive v. non-interactive modeGitHub Copilot CLI 101: How to use GitHub Copilot from the command lineBest practices for GitHub Copilot CLITags:

GitHub Copilot

GitHub Copilot CLI

GitHub Copilot CLI for BeginnersWritten bySenior AI Developer Tools AdvocateRelated postsAI & ML

What are git worktrees, and why should I use them?Git worktrees have been around since 2015, but it wasn’t until recently they became popular. Learn what they are, how to use them, and why you might.AI & ML

Accelerating researchers and developers building multilingual AI with a new open datasetA new repository-level dataset, published on GitHub under CC0-1.0, helps researchers and developers discover multilingual developer content across READMEs, issues, and pull requests.AI & ML

How we made GitHub Copilot CLI more selective about delegationBetter orchestration, fewer handoffs, faster progress, without a single new knob.We do newsletters, tooDiscover tips, technical guides, and best practices in our biweekly newsletter just for devs.Your email address

抓取快照

用于解析和审计的抓取证据。

200 · text/html; charset=UTF-8

2026/06/17 10:57

446200a0ff97b08544c701b4e1d67f674a68812c242bad1f63ce040f5d636f7e

AI 输出

带验证状态的结构化模型输出。

article.summarize

deepseek-v4-flash · 有效

{"tags":["GitHub Copilot","CLI","slash commands","command line","productivity","AI tools","developer tools","GitHub"],"titleEn":"GitHub Copilot CLI for Beginners: Overview of common slash commands","titleZh":"GitHub Copilot CLI 初学者指南:常用斜杠命令概览","summaryEn":"This article provides a...
article.classify

deepseek-v4-flash · 有效

{"relevant":true,"confidence":0.95,"primaryTopic":"product-updates","secondaryTopics":["software-engineering"]}

质量问题与日报引用

开放或已解决的问题,以及文章出现在每日日报中的记录。