Gemini

CLI Reference

Master the Gemini Command Line Interface with installation guides, usage examples, and advanced options.

Get Started

Installation Guide

Supported Platforms

🐧

Linux

Debian, Ubuntu, Fedora

🍎

macOS

macOS 10.14+

💻

Windows

Win10/11

Install CLI

Choose your platform and run the appropriate command below. The CLI will automatically verify system requirements before installation.

macOS/Linux

{`curl -fsSL https://cli.gemini.com/install.sh | sh
source ~/.zshrc`}

Windows

{`iex (New-Object Net.WebClient).DownloadString('https://cli.gemini.com/install.ps1')`}

Docker

{`docker run -v $PWD:/app -w /app \
  -e GEMINI_API_KEY="your_key_here" \
  google/gemini-cli:latest \
  gemini generate --file request.txt --outfile output.md`}

Core CLI Commands

gemini generate

Create content from natural language prompts

{`gemini generate \\
  --prompt "Explain quantum computing for high school students" \\
  --file output.md`}
Creates output.md with educational content

gemini code

Generate production-ready code from text descriptions

{`gemini code \\
  --prompt "Create a Flask API endpoint for user authentication" \\
  --language python`}
Generates Python files in the current directory

gemini image

Create and edit images using text prompts

{`gemini image \\
  --prompt "Cyberpunk cityscape at night with glowing skyscrapers" \\
  --output cyberpunk_city.png`}
Generates cyberpunk_city.png at 1024x1024 resolution

gemini debug

Analyze code issues with contextual suggestions

{`gemini debug \\
  --file broken_code.py \\
  --output fixed_code.py`}
Creates fixed version of the input file

Configuration

Configuration File

{`# ~/.gemini/config.yaml
api_key: "YOUR_API_KEY"
default_model: "gemini-pro"
output_dir: ~/workspace/gemini/outputs
language: en`}

Run gemini config --init to create a new configuration file.

Environment Variables

GEMINI_API_KEY
Sets the default API token
GEMINI_MODEL
Overrides the default model version
GEMINI_OUTPUT
Default directory for generated files

Flags & Options

--model
Specify model version
--json
Return structured JSON output
--watch
Watch mode for iterative editing

Advanced CLI Features

🔁

Iterative Development

Use the --follow flag to maintain context between multiple CLI commands for complex workflows.

{`gemini generate --follow \\
  --session myproject \\
  --prompt "Create initial architecture documentation"`}
📦

Batch Processing

Process multiple files in one operation with pattern matching and output organization.

{`gemini code *.py \\
  --output docs/ \\
  --language python`}
⚙️

Pipeline Workflows

Chain commands into complex workflows for automated documentation and code generation.

{`gemini generate \\
  --prompt "Design API documentation" |
  gemini format \\
  --style swagger`}
🔍

Code Inspection

Analyze code for security issues, style violations, and performance optimizations.

{`gemini inspect \\
  --dir ./src \\
  --output issues.json`}

Get More from the CLI

Master prompt engineering, batch processing, and integration with your existing development workflows.

CLI Tutorials