Gemini CLI tool for building, debugging & deploying with AI. Use when querying codebases, generating apps from images/PDFs, automating workflows, or performing AI-powered code tasks from the command line.
A comprehensive guide for using the Gemini CLI tool to build, debug & deploy with AI directly from the command line.
Gemini CLI enables command-line access to Google's Gemini models for:
Perfect for developers who want to leverage AI without leaving the terminal.
Metadata Declaration:
gemini (official Google package)Authentication Model:
This tool uses your Gemini API Key passed as an environment variable:
GEMINI_API_KEY=<your-key> gemini <command>
Key Points:
What This Skill Does:
Binaries (required):
gemini — Gemini CLI tool (installed via npm)node — Node.js 20.0.0+ (usually pre-installed)Credentials (environment variable):
GEMINI_API_KEY — Your Gemini API key from Google AI Studio or Google CloudSystem Requirements:
Optional:
bash, zsh, or PowerShell — Any modern shellGemini CLI is usually pre-installed:
gemini --version
If not installed:
npm install -g @google/gemini-cli
# OR
brew install gemini-cli
export GEMINI_API_KEY="<your-api-key>"
Or use it inline:
GEMINI_API_KEY="<your-api-key>" gemini <command>
To find your API key:
gemini --version
gemini --help
gemini chat
Then type your questions about code, architecture, debugging, etc.
gemini code --prompt "What does this function do?" <file-or-directory>
gemini create --from-image ./screenshot.png --prompt "Create a React component from this design"
gemini create --from-pdf ./document.pdf --prompt "Create an API spec based on this document"
gemini workflow --steps "1) analyze code, 2) identify issues, 3) suggest fixes"
gemini --help
gemini <command> --help
gemini chat # Start interactive chat
gemini chat --context ./src # Chat with codebase context
gemini code --prompt "analyze" ./file.js
gemini code --explain ./function.ts
gemini code --review ./pull_request.patch
gemini create --from-image ./design.png
gemini create --from-pdf ./spec.pdf
gemini create --template react --prompt "counter app"
gemini batch --input ./tasks.json --output ./results.json
GEMINI_API_KEY environment variableTo persist API key across sessions (optional):
Add to your ~/.bashrc, ~/.zshrc, or equivalent:
export GEMINI_API_KEY="<your-key>"
⚠️ Security warning: Only do this if your shell profile is secure and not synced to public repos.
--version # Show version
--help # Show help
--verbose # Verbose output
--api-key <key> # Pass API key directly (overrides env var)
--model <model> # Specify Gemini model (default: gemini-2.5-pro)
gemini --help # Global help
gemini <command> --help # Command-specific help
Official Docs: https://geminicli.com/docs
Use with your codebase:
cd /path/to/your/project
gemini chat --context ./src
Chain commands:
gemini code --review ./changes.patch | tee review.txt
Batch process files:
for file in src/*.js; do
gemini code --explain "$file" > "docs/${file}.md"
done
Store prompts in files:
cat prompt.txt | gemini chat
| Task | Gemini CLI | Cursor/IDE | Web UI |
|---|---|---|---|
| Quick code questions | ✅ Fast | ✅ Integrated | ❌ Context switch |
| Large codebase analysis | ✅ Better | ✅ Native | ❌ Limited |
| Generate from images | ✅ Works | ✅ Works | ✅ Works |
| Batch automation | ✅ Perfect | ❌ Manual | ❌ Manual |
| Interactive chat | ✅ Terminal | ✅ IDE | ✅ Browser |
| Scripting workflows | ✅ Yes | ❌ No | ❌ No |
✅ Installation: Pre-installed (v0.28.2)
✅ Configuration: Ready to use with GEMINI_API_KEY environment variable
✅ Authentication: Set env var before use (no interactive steps needed)
Testing: Run gemini --help to verify installation
Usage: Set API key and start using:
export GEMINI_API_KEY="your-key-here"
gemini chat
Setup Date: 2026-03-14
Status: Ready (no authentication required — env var based)