Skip to content

Commands Should work in Non-Interactive Mode #5435

@jerop

Description

@jerop

What happened?

Description

When running the Gemini CLI in a non-interactive environment, custom commands defined in .toml files are not being recognized or executed. The CLI either treats the command as a literal string or reports it as an invalid command.

Instead of expanding the command from the corresponding .toml file, the CLI either treats the custom command itself (e.g., /pr-review) as the literal prompt text or fails with an "invalid command" error. This prevents the use of reusable prompts in automated workflows, which is a primary use case for this feature.

Steps to Reproduce

  1. Create a custom command file
  2. Run the command interactively. This works as expected.
  3. Run the same command non-interactively. This fails.

cc @abhipatel12

What did you expect to happen?

When gemini --prompt "/hello" is executed, the CLI should find the .gemini/commands/hello.toml file, expand the prompt, and execute that prompt with Gemini CLI non-interactively.

Open to other syntax suggestions to make this work in headless mode, doesn't have to be slash commands.

Client information

N/A

Login information

N/A

Anything else we need to know?

The primary impact of this bug is on automation. The current workaround is to embed the entire multi-line prompt directly into the script. This defeats the purpose of having reusable custom commands, making workflows verbose and difficult to maintain. Enabling slash commands in non-interactive mode is critical for clean, modular, and maintainable automated workflows.

In addition, this makes it impossible to use extensions in non-interactive mode.

Metadata

Metadata

Labels

area/coreIssues related to User Interface, OS Support, Core Functionalityarea/non-interactiveIssues related to GitHub Actions, SDK, 3P Integrations, Shell Scripting, Command line automationpriority/p1Important and should be addressed in the near term.

Type

No fields configured for Bug.

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions