Lesson 9 - Slash commands in GitHub Copilot CLI
此内容尚不支持你的语言。
Like any good CLI tool, GitHub Copilot CLI includes many slash commands to interact with it. These commands expose advanced functionality, behind-the-scenes information, and additional configuration options. You’ve already used commands such as /diff, /mcp, /skills, /agent, and /pr. Let’s explore a few other useful ones.
In this lesson, you will:
- use
/contextand/compactto explore how Copilot manages conversation context. - use
/modelto explore the models available to you. - learn how
/sharecan export or share a session. - explore optional commands for parallel work, worktrees, and delegation to cloud agent.
Scenario
You’ve wrapped the core CLI workflow. Now let’s look at a few additional capabilities — managing context, switching models, sharing sessions, and optionally delegating work to Copilot cloud agent.
Explore Copilot CLI context
When working on larger or more complex tasks, you may bump into the maximum context window for the model. Copilot CLI automatically compacts the conversation when needed, and you can inspect or compact it yourself with slash commands.
-
Return to your Codespace and start Copilot CLI from the repository root if it is not already open.
-
Enter:
/context -
Note the model, current token usage, and how the context is divided among system instructions, tools, messages, and free space.
-
Compact the conversation:
/compact -
Enter
/contextagain and compare the result. There might not be a drastic change if the conversation is already small.
Copilot CLI automatically compacts context as the window fills. Use /compact when you want to choose the timing. Use /clear or /new when you are switching to an unrelated task and want a fresh conversation instead.
Choose your model
Different models have different strengths, and different developers have different preferences. Copilot CLI allows you to list and select the model you want to use.
-
Enter:
/model -
Explore the available models and usage information.
-
Keep the current model, select another one, or press Esc to close the list.
Share a session
Working together as a team and sharing learnings helps everyone improve their use of AI tools. The /share command can export a session to a Markdown or HTML file, create a shareable link, or publish a GitHub gist.
- Enter
/helpand review the/shareoptions in your installed version. - If you want to share this session, choose the destination that fits your needs, such as
/share filefor a local Markdown export. - Review the exported content before sending it to anyone or publishing it. Session exports can include prompts, responses, and project details.
Publishing a link or gist is optional. Don’t publish repository or conversation content that your team does not intend to share.
Optional: scale out or delegate
The core workshop is complete. Copilot CLI also provides commands for larger tasks:
/fleetcan divide independent subtasks among subagents and run them in parallel./worktreecan create an isolated Git worktree for a separate task./delegatecan send a task to Copilot cloud agent, which works asynchronously and may open a pull request.
These commands are optional because they can create additional worktrees or remote work. Start a fresh, well-scoped task before trying them, and review the result through your normal workflow. If you want to dig deeper into asynchronous agent work, continue with the cloud agent workshop.
Summary and next steps
Using slash commands in Copilot CLI allows you to configure it, share sessions, and see what’s going on behind the scenes. In this lesson, you:
- used
/contextand/compactto explore how Copilot manages conversation context. - used
/modelto explore the models available to you. - learned how
/sharecan export or share a session. - explored optional commands for parallel work, worktrees, and delegation to cloud agent.
There are more slash commands available and more to explore with Copilot CLI! Let’s close out our journey by reviewing what we’ve learned and some next steps to continue learning.