Skip to content

gemini

gemini - execute non-interactive Google Gemini prompts

state-name:
tool: gemini
arguments:
prompt: <prompt-text>
model: <model-name> # optional
timeout: <duration> # optional
output-format: <format> # optional

The gemini tool invokes Google’s Gemini CLI for AI-powered tasks. It sends a prompt using the -p flag and captures the response.

The tool runs in the project root directory for full codebase context.

ArgumentRequiredDefaultDescription
promptYes-The prompt to send to Gemini
modelNoDefault modelModel to use (e.g., gemini-flash)
timeoutNo5mMaximum execution time
output-formatNo-Output format
  • 30s - 30 seconds
  • 5m - 5 minutes
  • 1h - 1 hour
CodeMeaning
0Success
1Gemini error or authentication issue
2Gemini CLI not found
124Timeout exceeded

Both stdout and stderr are merged for capture:

analyze:
tool: gemini
arguments:
prompt: "Summarize this document"
output: var(summary)
quick-question:
tool: gemini
arguments:
prompt: "What's the best practice for error handling in Go?"
review-code:
tool: gemini
arguments:
prompt: |
Review this code for potential improvements:
{{ file(./src/main.go) }}
output: var(review)
fast-task:
tool: gemini
arguments:
prompt: "Generate a brief summary"
model: gemini-flash
gemini-task:
tool: gemini
arguments:
prompt: "Analyze codebase architecture"
timeout: 10m
on-error:
1: check-auth
2: gemini-not-installed
124: handle-timeout
_: general-error
next: use-result
check-auth:
tool: bash
arguments:
command: |
echo "Gemini authentication issue. Run 'gemini' interactively to log in."
exit 1
gemini-not-installed:
tool: bash
arguments:
command: |
echo "Gemini CLI not found. Install from https://github.com/google-gemini/gemini-cli"
exit 1
# Get perspectives from multiple AIs
start-at: get-claude-opinion
states:
get-claude-opinion:
tool: claude
arguments:
prompt: "How would you implement {{ feature }}?"
output: var(claude_response)
next: get-gemini-opinion
get-gemini-opinion:
tool: gemini
arguments:
prompt: "How would you implement {{ feature }}?"
output: var(gemini_response)
next: compare
compare:
tool: bash
arguments:
command: |
echo "=== Claude's Approach ==="
echo "{{ claude_response }}"
echo ""
echo "=== Gemini's Approach ==="
echo "{{ gemini_response }}"

Install the Gemini CLI:

Terminal window
# Follow instructions at https://github.com/google-gemini/gemini-cli

Authenticate by either:

  1. Running gemini interactively to complete OAuth login
  2. Setting the GEMINI_API_KEY environment variable

The free tier has limits:

  • 60 requests per minute
  • 1,000 requests per day

If rate limited (exit code 1 with rate limit message), consider:

  • Using gemini-flash model (lower limits)
  • Adding delays between requests
  • Upgrading to a paid plan

The tool runs in the project root directory, giving Gemini access to the full project context.

  • claude - Claude AI integration
  • codex - OpenAI Codex integration
  • parallel - For concurrent AI queries