What is Gemini CLI?
Gemini CLI is an open-source AI agent that brings Google’s Gemini large language models (LLMs) directly into your terminal or shell (cloud.google.com). It functions like a powerful coding assistant—able to read and write files, run shell commands, query the web, and reason across projects up to 1 million tokens in length (medium.com).
Key capabilities include:
Code generation & refactoring
Multimodal prompts (text + images/PDFs)
Shell automation & file manipulation
Web-grounded responses via Google Search
Extensible via Model Context Protocol (MCP) servers
📦 Installation & Setup
Prerequisites: Install Node.js v18+:
node -v
Install:
One-off (no install):
Global install (recommended):
Authenticate:
Sign in with your Google account to access the free tier: Gemini 2.5 Pro (1 M token context), 60 requests/min, 1,000/day (cloud.google.com, apidog.com, medium.com, blog.google, dev.to).
Launch:
Run
gemini
in your terminal to begin. 🔧 Core Features in Action
1. Prompt & Chat Modes
Single prompt:
gemini-cli prompt "Why is the sky blue?"
Interactive chat:
gemini-cli chat > name 3 dog breeds > which is the heaviest?
2. Shell & File Tools
Gemini CLI includes built-in tools to manipulate files, run commands, and search code:
edit
, glob
, grep
, ls
, shell
, read-file
, write-file
, read-many-files
, web-fetch
, web-search
(simonwillison.net). Example: Convert all images to PNG and rename using EXIF dates:
Gemini CLI reasons, runs shell tools, and updates files accordingly.
3. Multimodal Projects
Gemini CLI can ingest sketches or PDFs as context—using models like Gemini Pro Vision to generate, say, a Discord bot from a PDF spec (medium.com).
4. Extensibility with MCP
MCP servers allow Gemini CLI to integrate external services, such as:
5. GEMINI.md Context Prompts
Project-specific guidance via
GEMINI.md
—e.g. enforce linting/formatting rules in Python. Gemini uses this context automatically during code generation (medium.com).6. Flags & Automation
Run in non-interactive scripts with
--prompt
, enable auto-execution via --yolo
, or override models with --model
(medium.com).🛠 Example Workflow: Code Refactoring + Testing
Clone a repo:
git clone https://github.com/myorg/my-app.git cd my-app
Launch:
gemini > Refactor service.ts to async/await and add unit tests.
Gemini CLI will:
Read and refactor the file
Write updated version
Create a corresponding test file
Optionally run
npm test
💡 Why It Matters
Seamless workflow: no IDE/browser needed—everything works from your terminal (simonwillison.net, apidog.com).
🎥 See It in Action
✅ Getting Started Checklist
Install Node.js 18+
Install
@google/gemini-cli
or use npx
Sign in via Google (or set
GEMINI_API_KEY
) Start the CLI and type
/tools
, /mcp
, --help
Drop in a
GEMINI.md
to customize behavior Ask it to refactor code, automate shell tasks, or prototype apps!
✍️ Closing Thoughts
Gemini CLI is a paradigm shift: a terminal-native AI agent that reads, reasons, writes, and acts—without leaving your shell. With its massive context, open‑source ethos, and generous usage limits, it's an indispensable tool for developers, DevOps engineers, and creators alike.
Let me know if you'd like me to polish certain sections, add more use-case code samples, or tailor it to a specific audience!