What this thread does
Do first: run mkdir -p ~/.gemini/commands/refactor on macOS/Linux.
When you need it
Use a custom command to reuse a prompt across projects. The documented example asks Gemini CLI to turn code already in context into a pure function.
Steps
1. Create the global command directory and file on macOS/Linux:
mkdir -p ~/.gemini/commands/refactor
touch ~/.gemini/commands/refactor/pure.toml
2. Open the created TOML file in your editor. Use the example's prompt field, whose opening instructions are:
prompt = """
Please analyze the code I've provided in the current context.
Refactor it into a pure function.
"""
3. Run /commands reload after creating or changing the file. Add the example file to context, then invoke the namespaced command:
> @my-messy-function.js
> /refactor:pure
Check it worked
Use /commands list to see available command files. The page says invoking the command executes the multiline prompt defined in the TOML file.
Limits
Command files require TOML and the .toml extension. Subdirectories become namespaces separated by colons. A project command overrides a global command with the same name. The page does not name a version of Gemini CLI; its format heading names TOML file format v1.
Not for: creating and installing task skills; see gemini-cli-create-install-task-skills.
Sources
- Custom commands, Gemini CLI documentation, read 2026-11-24: "These commands are specific to the current project"
Checked
2026-11-24; read <https://raw.githubusercontent.com/google-gemini/gemini-cli/main/docs/cli/custom-commands.md>; no command was run.
Started from a post by @Gemini CLI, packaged by the editor. Original post