With Gemini CLI’s new custom slash commands, you can now create, reuse, and share automated prompts that make your workflow faster and more reliable.
What Makes Custom Slash Commands Special?
Custom slash commands are user-defined shortcuts that trigger specific prompts directly in Gemini CLI. By setting them up in local .toml
files or using Model Context Protocol (MCP) prompts, you can automate common tasks, reduce typing, and ensure consistency across your projects.
Building Blocks: The .toml
File
At the heart of this feature is the .toml
file. It’s a simple yet powerful way to define each command. The only requirement is a prompt
key, but you can add dynamic arguments with {{args}}
or even run shell commands inside prompts using !{...}
. Command names are taken from the file name and are case-sensitive for accuracy.
- Reusable Prompts: Set up once and use them anytime you need.
- Arguments and Shell Integration: Make prompts interactive and context-aware using inputs and live shell data.
- Minimal Setup: Start simple and scale up as your needs grow.
For instance, a review.toml
command could automate steps for reviewing GitHub pull requests, guiding Gemini to fetch PR details, check commit messages, and post feedback all launched with a single /review <issue_number>
.
Organize Commands with Namespaces
Gemini CLI automatically organizes commands based on their file paths. Subfolders inside the commands
directory become namespaces, so a file at .gemini/commands/git/commit.toml
appears as /git:commit
. This keeps large workflows tidy and easy to manage.
How to Create Your First Slash Command
1. Make the Command File
Start by creating a
plan.toml
file in~/.gemini/commands/
. This will define a/plan
command that helps Gemini build a strategic plan for any task, without executing code.2. Define the Logic
Inside
plan.toml
, describe exactly what the command should do. For example, direct Gemini to investigate the goal, outline phases, spot verification steps, and predict potential pitfalls, all formatted in markdown for readability. Checkout this example3. Put the Command to Use
Run
/plan [your task]
in Gemini CLI to receive a detailed, actionable plan. You can make commands available everywhere (user-scoped) or just for a specific project by storing them in version control for team collaboration.
Advanced: Integrating with Model Context Protocol (MCP)
Gemini CLI now supports using MCP Prompts as slash commands. This lets you connect to standardized prompt templates from MCP-compatible servers. Command names and descriptions are filled in automatically, and you can pass arguments for flexible, powerful actions. It’s a simple way to connect Gemini with external services and prompt servers.
Start Automating Today
To boost your productivity, update Gemini CLI and try building your own custom slash commands. Whether you need to speed up code reviews, automate planning, or integrate with remote prompt servers, this feature is crafted to reduce manual work and help you focus on problem-solving.
Conclusion
Custom slash commands in Gemini CLI offer a practical pathway to automate repetitive tasks, enhance team collaboration, and keep workflows consistent. With easy setup, clear organization, and robust integrations, developers can spend more time innovating and less time on routine processes.
Source: Google Cloud Blog – Gemini CLI: Custom slash commands
Streamline Development with Gemini CLI's Custom Slash Commands