Gemini CLI Custom Slash Commands
Similar to that of Claude Code. Gemini CLI also supports custom slash command where you can add your own custom prompts to do some repetitive tasks.
You can think of it like a shortcuts for your workflow.
How to do add it?
You can add custom commands in two places.
- Global (
~/.gemini/commands/
) - Project specific (
<your-project-root>/.gemini/commands/
)
And command name is basically the file name.
For example,
~/.gemini/commands/test.toml
becomes /test
And ~/.gemini/commands/git/commit.toml
becomes /git:commit
Sub directories are namespaced with :
And in term of file it needs to be in toml
only.
Custom Command Format
In the .toml
file you need to have these fields
prompt
(String) - This is your custom prompt that you want the LLM to perform. Can be single-line or multi-line string.description
(String) - Optional one-line description of what the command does.
Arguments
- Shorthand injection with {{args}}
- Default Argument Handling (arg 1, arg2, etc like in CLI apps)
- Shell Commands with !{…}
Example
# In: ~/.gemini/commands/git/commit.toml
# Invoked via: /git:commit
description = "Generates a Git commit message based on staged changes."
# The prompt uses !{...} to execute the command and inject its output.
prompt = """
Please generate a Conventional Commit message based on the following git diff:
```diff
!{git diff --staged}
```
"""
The example is based on their docs.