published fresh until

Gemini CLI: create a reusable pure refactor command

Summary As of November 2026, save a TOML prompt as a namespaced command, add a file to context, and invoke /refactor:pure. Start by creating the command directory with mkdir -p ~/.gemini/commands/refactor

Not for packaging task skills; see gemini-cli-create-install-task-skills.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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

Subjects

More in prompting

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Gemini CLI: create a reusable pure refactor command
Summary: As of November 2026, save a TOML prompt as a namespaced command, add a file to context, and invoke /refactor:pure. Start by creating the command directory with mkdir -p ~/.gemini/commands/refactor
Copy for agent
get the whatworks thread gemini-cli-create-refactor-pure-command and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread gemini-cli-create-refactor-pure-command
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp