Documentation/Commands
Commands Reference

Gemini CLI Commands

Complete reference guide for all Gemini CLI commands. Learn syntax, options, and see practical examples.

Quick Reference

Core Commands
Essential commands for daily usage
  • chat
  • ask
  • generate
  • analyze
Authentication
Manage authentication and credentials
  • auth login
  • auth logout
  • auth status
  • auth refresh
Configuration
Manage CLI settings and preferences
  • config get
  • config set
  • config list
  • config reset
File Operations
Work with files and projects
  • review
  • explain
  • refactor
  • test

Core Commands

gemini chat

Start an interactive chat session with Gemini

# Start interactive chat
gemini chat

# Chat with specific model
gemini chat --model gemini-pro

# Chat with custom system prompt
gemini chat --system "You are a helpful coding assistant"

gemini ask

Ask a single question and get an immediate response

# Ask a simple question
gemini ask "What is the capital of France?"

# Ask about code
gemini ask "Explain how JavaScript closures work"

# Ask with context from file
gemini ask "Review this code" --file app.js

gemini generate

Generate code, documentation, or other content

# Generate from description
gemini generate "Create a React component for a button"

# Generate specific type
gemini generate --type component --name UserCard --framework react

# Generate with template
gemini generate --template api-route --name users

File Operations

gemini analyze
Analyze code files for insights and patterns
# Analyze a single file
gemini analyze src/app.js

# Analyze multiple files
gemini analyze src/**/*.js

# Deep analysis with metrics
gemini analyze --deep --metrics src/
Features:
  • Code complexity analysis
  • Security vulnerability detection
  • Performance optimization suggestions
  • Code quality metrics
gemini review
Get code review suggestions and improvements
# Review code changes
gemini review --file src/component.js

# Review git diff
gemini review --diff HEAD~1

# Review with specific focus
gemini review --focus security,performance
Review areas:
  • Code style and conventions
  • Security best practices
  • Performance optimizations
  • Bug detection
gemini explain
Get detailed explanations of code functionality
# Explain code function
gemini explain --file utils/parser.js

# Explain specific lines
gemini explain --file app.js --lines 15-30

# Explain algorithm
gemini explain --algorithm --file sort.py
Explanation types:
  • Function purpose and logic
  • Algorithm explanations
  • API usage patterns
  • Architecture decisions
gemini refactor
Get suggestions for code improvements and refactoring
# Suggest refactoring
gemini refactor --file legacy/old-code.js

# Focus on specific aspects
gemini refactor --focus readability,performance

# Apply suggestions
gemini refactor --apply --backup
Refactoring types:
  • Code simplification
  • Performance improvements
  • Modern syntax updates
  • Design pattern application

Configuration & Settings

Configuration Management
Manage Gemini CLI settings and preferences
# Get specific setting
gemini config get model

# Get all auth settings
gemini config get auth.*

# Get with default value
gemini config get temperature --default 0.7

Advanced Features

Batch Processing
# Process multiple files
gemini batch --command analyze --pattern "src/**/*.js"

# Batch generation
gemini batch --template component --data inputs.json

# Parallel processing
gemini batch --parallel 4 --timeout 30s
Scripting & Automation
# Run from script file
gemini script run automation.gm

# Watch for file changes
gemini watch --pattern "*.js" --command "review"

# Pipeline processing
gemini pipeline --config ci-pipeline.yaml
Plugin System
# List installed plugins
gemini plugin list

# Install plugin
gemini plugin install @gemini/eslint-plugin

# Create custom plugin
gemini plugin create my-plugin --template typescript
Model Management
# List available models
gemini models list

# Get model info
gemini models info gemini-pro

# Compare models
gemini models compare --query "Hello world"

Global Options

OptionDescriptionExample
--help, -hShow help informationgemini chat --help
--version, -vShow version numbergemini --version
--verboseEnable verbose outputgemini ask "Hello" --verbose
--quiet, -qSuppress non-essential outputgemini generate --quiet
--configUse custom config filegemini --config ./custom.json chat
--no-colorDisable colored outputgemini ask "Hello" --no-color
--output, -oSpecify output filegemini generate -o result.js
Getting Help
Need help with a specific command? Use the built-in help system.
# General help
gemini --help

# Command-specific help
gemini chat --help
gemini generate --help

# List all commands
gemini help

# Search for commands
gemini help search "file"