// Wield Google's Gemini CLI as a powerful auxiliary tool for code generation, review, analysis, and web research. Use when tasks benefit from a second AI perspective, current web information via Google Search, codebase architecture analysis, or parallel code generation. Also use when user explicitly requests Gemini operations.
| name | cli-gemini |
| description | Wield Google's Gemini CLI as a powerful auxiliary tool for code generation, review, analysis, and web research. Use when tasks benefit from a second AI perspective, current web information via Google Search, codebase architecture analysis, or parallel code generation. Also use when user explicitly requests Gemini operations. |
| allowed-tools | ["Bash","Read","Write","Grep","Glob"] |
| version | 1.1.0 |
Enable Claude Code to effectively orchestrate Gemini CLI (v0.16.0+) with Gemini 3 Pro for code generation, review, analysis, and specialized tasks requiring a second AI perspective or real-time web information.
This file (SKILL.md): Core workflow and usage patterns
Reference Files (detailed documentation):
1. Second Opinion / Cross-Validation
2. Google Search Grounding
3. Codebase Architecture Analysis
codebase_investigator tool4. Parallel Processing
5. Specialized Generation
6. Explicit User Request
Skip this skill when:
| Document | Purpose | Key Insight |
|---|---|---|
| Gemini CLI - Main Workflow | Auxiliary tool integration | Specialized second AI perspective |
| Gemini CLI - Web Research | Google Search integration | Real-time web information access |
| Gemini CLI - Code Generation | Alternative code generation | Cross-validation with Claude |
| Document | Purpose | Key Insight |
|---|---|---|
| references/patterns.md | Advanced orchestration patterns | Load for Generate-Review-Fix |
| references/reference.md | CLI flags and command syntax | Load for command construction |
| references/templates.md | Prompt templates | Load for copy-paste prompts |
| references/tools.md | Built-in tools (google_web_search, codebase_investigator) | Load when using Gemini-specific tools |
START
โ
[Detect Use Case]
โ
Explicit User Request? โโโ YES โโโ [Load: reference.md + patterns.md]
โ โ
NO [Verify Gemini CLI Installed]
โ โ
Need Web Search? โโโ YES โโโ [Load: tools.md]
โ โ
NO [Execute Google Web Search]
โ โ
Code Review Needed? โโโ YES โโโ [Load: templates.md] โโโโโโโโโ Merge
โ โ โ
NO [Review Code with Gemini] [Process Output]
โ โ โ
Architecture Analysis? โโโ YES โโโ [Load: tools.md] โโโโโโโโโโโโโ
โ โ
NO [Analyze with codebase_investigator]
โ โ
Parallel Processing? โโโ YES โโโ [Background Execution] โโโโโโโโ
โ โ
NO [Run in Background & Monitor]
โ โ
Simple/Quick Task? โโโ YES โโโ [Skip Gemini - Use Claude] โโโโโโ
โ โ
NO [Handle Directly]
โ โ
[Load: templates.md] โ
โ โ
[Specialized Generation Mode] โโโโโ
โ
[Generate Tests/Docs/Types]
โ
[Validate Output]
โ
Security Issues? โโโ YES โโโ [Escalate to User]
โ โ
NO DONE
โ
[Apply Changes]
โ
COMPLETE
Before using, confirm Gemini CLI is available:
command -v gemini || which gemini
If not found, install following Gemini CLI documentation.
gemini "[prompt]" --yolo -o text 2>&1
Key flags:
--yolo or -y: Auto-approve all tool calls (required for automation)-o text: Human-readable output (default for Claude integration)-o json: Structured output with stats and metadata-m gemini-2.5-flash: Use faster model for simple tasksYOLO Mode Limitation: Auto-approves tool calls but does NOT prevent planning prompts. Gemini may still present plans and ask "Does this plan look good?"
Mitigation: Use forceful language in prompts:
Rate Limits: Free tier has 60 requests/min, 1000/day. CLI auto-retries with backoff. Expect messages like "quota will reset after Xs".
Text output (-o text):
JSON output (-o json):
{
"response": "actual content here",
"stats": {
"models": { "tokens": {...} },
"tools": { "byName": {...} }
}
}
Parse response field for content; stats for usage metrics.
Code Generation:
gemini "Create [description] with [features]. Output complete file content." --yolo -o text
Code Review:
gemini "Review [file] for: 1) features, 2) bugs/security issues, 3) improvements" -o text
Bug Fixing:
gemini "Fix these bugs in [file]: [list]. Apply fixes now." --yolo -o text
Test Generation:
gemini "Generate [Jest/pytest] tests for [file]. Focus on [areas]." --yolo -o text
Documentation:
gemini "Generate JSDoc for all functions in [file]. Output as markdown." --yolo -o text
Architecture Analysis:
gemini "Use codebase_investigator to analyze this project" -o text
Web Research:
gemini "What are the latest [topic]? Use Google Search." -o text
Faster Model (Simple Tasks):
gemini "[prompt]" -m gemini-2.5-flash -o text
Rate Limit Exceeded:
-m gemini-2.5-flash for lower priority tasksCommand Failures:
gemini --version~/.gemini/settings.json for config issuesValidation After Generation: Always verify Gemini's output:
Standard Generate-Review-Fix Cycle:
# 1. Generate
gemini "Create [code]" --yolo -o text
# 2. Review (Gemini reviews its own work)
gemini "Review [file] for bugs and security issues" -o text
# 3. Fix identified issues
gemini "Fix [issues] in [file]. Apply now." --yolo -o text
Background Execution:
For long tasks, run in background and monitor:
gemini "[long task]" --yolo -o text 2>&1 &
# Monitor with BashOutput tool
These tools are available only through Gemini:
Project Context (Optional):
Create .gemini/GEMINI.md in project root for persistent context that Gemini will automatically read.
Session Management:
gemini --list-sessionsecho "follow-up" | gemini -r [index] -o textALWAYS do these without asking:
ALWAYS verify Gemini CLI is installed before use
command -v gemini to check availabilityALWAYS use --yolo flag to auto-approve tool calls
ALWAYS specify output format explicitly
-o text for human-readable output (default)-o json when parsing structured data neededALWAYS use forceful language to prevent planning prompts
ALWAYS validate Gemini's generated code
ALWAYS redirect stderr to stdout (2>&1)
ALWAYS monitor rate limits
-m gemini-2.5-flash for lower priority tasksNEVER do these:
NEVER use for simple, trivial tasks
NEVER use for interactive refinement
NEVER skip output validation
NEVER assume rate limits won't apply
NEVER ignore authentication errors
gemini --version to verify authentication~/.gemini/settings.json for config issuesNEVER use when context preservation is critical
Ask user when:
ESCALATE IF rate limits are repeatedly exceeded
ESCALATE IF Gemini authentication fails
~/.gemini/settings.json configurationESCALATE IF generated code has critical security vulnerabilities
ESCALATE IF command failures persist after troubleshooting
ESCALATE IF task requires conversation history
Gemini CLI Usage Complete When:
command -v gemini)Before marking task complete:
When using Gemini for code review:
When using Gemini for code generation:
When using Gemini for research:
N/A - cli-gemini is invoked directly via Bash tool, not integrated into hook system.
workflows-code:
code-review (if exists):
bug-hunting (if exists):
test-generation (if exists):
Bash tool:
Read tool:
Write tool:
Grep/Glob tools:
Required: None
Optional:
.claude/knowledge/code_standards.md - Use to validate Gemini's generated code against project standards.claude/knowledge/security_guidelines.md - Use to check Gemini's code for security complianceGemini CLI (v0.16.0+):
~/.gemini/settings.jsonOptional: .gemini/GEMINI.md in project root for persistent context
Gemini API enforces rate limits:
Symptoms:
Solutions:
Example Throttling:
# Instead of rapid-fire requests:
for file in *.ts; do
gemini "code review $file"
done
# Add delays:
for file in *.ts; do
gemini "code review $file"
sleep 1 # 1-second delay
done
Rate Limit Recovery:
-o json to see request statsSymptom: "Not authenticated" or "Invalid API key" errors
Solutions:
gemini --versioncat ~/.gemini/settings.jsonSymptom: Gemini still asking for confirmation despite --yolo flag
Cause: Yolo auto-approves tool calls but NOT planning prompts
Solution: Use forceful language in prompts:
Symptom: Commands fail or hang
Debug steps:
gemini "[prompt]" -o jsongemini --version (need v0.16.0+)gemini "[prompt]" 2>&1Common causes:
-m gemini-2.5-flash for simpler tasks or default for complex.gemini/GEMINI.md for project contextSolution: Iterate prompt with more explicit instructions