Gemini CLI is an open-source command-line AI agent that brings the power of Google Gemini directly into your terminal. It allows you to interact with Gemini AI in a command-line environment for various programming and information processing tasks.
Gemini CLI is designed for terminal users:
- No need to switch to browsers or other applications
- Maintains your terminal workflow
- Suitable for server environments and headless operations
Direct access to Google's latest Gemini models:
- Powerful code understanding and generation (Gemini 3.1 Pro)
- Multimodal support (text, images, design assets)
- Ultra-long context processing (1M+ tokens)
- Real-time web grounding via Google Search integration
- Fully open source with transparent code
- Customizable and extensible
- Community-driven improvements
- Ask questions directly in terminal
- Get code suggestions and explanations
- Document queries and summaries
- Code completion and generation
- Bug analysis and fix suggestions
- Code review and optimization
- Read and analyze file contents
- Generate and modify code files
- Batch text processing
- Works with shell scripts
- Pipe operation support
- Output formatting
# Install via npm
npm install -g @google/gemini-cli
# Or install from source
git clone https://github.com/google-gemini/gemini-cli.git
cd gemini-cli
npm install
npm linkSet your Google AI API key:
export GOOGLE_AI_API_KEY="your-api-key"# Start interactive mode
gemini
# Ask a direct question
gemini "Explain what this regex means"
# Analyze a file
gemini "Analyze the code structure of main.py" < main.py
# Use with pipes
cat error.log | gemini "Help me analyze this error"gemini "What's wrong with this code?" < broken_code.pygemini "Explain how Docker works"gemini "Generate documentation comments for this function" < my_function.js- Be Specific - More specific questions yield more useful answers
- Provide Context - Pipe in relevant file content
- Verify Output - Always test AI-generated code
- Use Interactively - Multiple rounds of dialogue to refine solutions
Gemini CLI is an open-source project. Usage requires a Google AI API key. Please follow Google's terms of service and the open-source license.