Gemini CLI

Google's AI coding assistant for the terminal

Visit Website

Gemini CLI is Google's open-source command-line tool for interacting with Gemini models directly from your terminal. It assists with code analysis, task automation, and content generation. Supports multi-turn conversations, file analysis, and integrates with your development workflow.

Quick Reference

gemini 'prompt': Single-shot query

gemini chat: Start interactive session

gemini analyze <file>: Analyze code files

--file <path>: Include file as context

--output <path>: Write response to file

--model <name>: Choose specific model

Ctrl+C: Cancel current generation

Supports piping: cat code.js | gemini 'explain'

Works with Gemini Pro, Ultra, Flash models

Free tier: 60 requests/minute

Setup Guide

# Getting Started with Gemini CLI ## Prerequisites - Node.js version 18 or later - Google AI Studio API key (free) ## Installation ### Via npm (Recommended) ```bash npm install -g @anthropic-ai/gemini-cli ``` ### Via curl ```bash curl -fsSL https://gemini.dev/install.sh | bash ``` ## Setup ### 1. Get Your API Key 1. Go to https://aistudio.google.com/apikey 2. Create a new API key 3. Set it as an environment variable: ```bash export GEMINI_API_KEY="your-api-key" ``` ### 2. Start Using ```bash gemini "Explain this code" ``` ## Key Features ### Code Analysis ```bash gemini analyze main.py gemini "What does this function do?" --file utils.ts ``` ### Multi-turn Conversations ```bash gemini chat > Explain how auth works in this project > Now help me add OAuth support ``` ### File Operations ```bash gemini "Generate unit tests for this file" --file api.ts gemini "Refactor to use async/await" --file legacy.js --output modern.js ``` ## Configuration Create ~/.geminirc for persistent settings: ```json { "model": "gemini-pro", "temperature": 0.7, "maxTokens": 4096 } ``` ## Best Practices - Use --file flag to provide context - Chain commands for complex workflows - Pipe output to other tools - Use in CI/CD for automated reviews