Gemini CLI
Consult Google Gemini CLI for second opinions on architecture, debugging, and security audits. Use Gemini's 1M+ context window for comprehensive code analysis. Compare Flash (fast) vs Pro (thorough) vs 3-Pro-Preview (cutting-edge). Use when: need second opinion on architectural decisions, stuck debugging after 2+ attempts, writing security- sensitive code, planning refactors (5+ files), approaching 70%+ context capacity, unfamiliar with tech stack, need peer review, or want Flash vs Pro vs 3-Pro-Preview comparison. Keywords: gemini-cli, google gemini, gemini command line, second opinion, model comparison, gemini-2.5-flash, gemini-2.5-pro, gemini-3-pro-preview, architectural decisions, debugging assistant, code review gemini, security audit gemini, 1M context window, AI pair programming, gemini consultation, flash vs pro, AI-to-AI prompting, peer review, codebase analysis, gemini CLI tool, shell gemini, command line AI assistant, gemini architecture advice, gemini debug help, gemini security scan, gemini code compare
What this skill does
# Gemini CLI **Leverage Gemini's 1M+ context window as your AI pair programmer within Claude Code workflows.** This skill teaches Claude Code how to use the official Google Gemini CLI (`gemini` command) to get second opinions, architectural advice, debugging help, and comprehensive code reviews. Based on production testing with the official CLI tool. --- ## Table of Contents 1. [Quick Start](#quick-start) 2. [When to Use Gemini Consultation](#when-to-use-gemini-consultation) 3. [Installation](#installation) 4. [Using Gemini CLI](#using-gemini-cli) 5. [Model Selection: Flash vs Pro](#model-selection-flash-vs-pro) 6. [Proactive Consultation Patterns](#proactive-consultation-patterns) 7. [AI-to-AI Prompting Best Practices](#ai-to-ai-prompting-best-practices) 8. [Common Use Cases](#common-use-cases) 9. [Integration Examples](#integration-examples) 10. [Troubleshooting & Known Issues](#troubleshooting--known-issues) --- ## Quick Start **Prerequisites**: - Gemini CLI installed (`npm install -g @google/gemini-cli`) - Authenticated with Google account (run `gemini` once to authenticate) **Basic Usage Patterns**: ```bash # Quick question (non-interactive with -p flag) gemini -p "Should I use D1 or KV for session storage?" # Code review with file context (using --all-files) gemini --all-files -p "Review this auth implementation for security issues" # Architecture advice using Pro model gemini -m gemini-2.5-pro -p "Best way to handle WebSockets in Cloudflare Workers?" # Pipe file content for review cat src/auth.ts | gemini -p "Review this authentication code for security vulnerabilities" # Interactive mode for follow-up questions gemini -i "Help me debug this authentication error" ``` --- ## When to Use Gemini Consultation ### ALWAYS Consult (Critical Scenarios) Claude Code should **automatically invoke Gemini** in these situations: 1. **Major Architectural Decisions** - Example: "Should I use D1 or KV for session storage?" - Example: "Durable Objects vs Workflows for long-running tasks?" - Why: Gemini provides complementary perspective, may prioritize different concerns - **Pattern**: `gemini -m gemini-2.5-pro -p "[architectural question]"` 2. **Security-Sensitive Code Changes** - Authentication systems - Payment processing - Data handling (PII, sensitive data) - API key/secret management - Why: Gemini 2.5 Pro excels at security audits - **Pattern**: `cat [security-file] | gemini -m gemini-2.5-pro -p "Security audit this code"` 3. **Large Refactors** - Affecting 5+ files - Core architecture changes - Database schema migrations - Why: Fresh perspective prevents tunnel vision - **Pattern**: `gemini --all-files -m gemini-2.5-pro -p "Review this refactoring plan"` 4. **Stuck Debugging (2+ Failed Attempts)** - Error persists after 2 debugging attempts - Stack trace unclear - Intermittent bugs - Why: Different reasoning approach may spot root cause - **Pattern**: `gemini -p "Help debug: [error message]" < error.log` 5. **Context Window Pressure (70%+ Full)** - Approaching token limit - Need to offload analysis to Gemini - Why: Gemini's 1M context can handle large code files - **Pattern**: `cat large-file.ts | gemini -p "Analyze this code structure"` ### OPTIONALLY Consult 6. **Unfamiliar Technology** - Using library/framework for first time - Experimenting with new patterns - Why: Gemini may have more recent training data - **Pattern**: `gemini -p "Best practices for [new technology]"` 7. **Code Reviews** - Before committing major changes - Pull request preparation - Why: Catches edge cases and improvements - **Pattern**: `git diff | gemini -p "Review these changes"` --- ## Installation ### 1. Install Gemini CLI ```bash npm install -g @google/gemini-cli ``` ### 2. Authenticate ```bash gemini ``` Follow the authentication prompts to link your Google account. ### 3. Verify Installation ```bash gemini --version ``` Should show version 0.13.0 or higher. ### 4. Test Connection ```bash gemini -p "What is 2+2?" ``` --- ## Using Gemini CLI ### Core Command Patterns #### Non-Interactive Mode (`-p` flag) Best for Claude Code integration: ```bash # Direct question gemini -p "Your question here" # With model selection gemini -m gemini-2.5-flash -p "Quick debugging question" gemini -m gemini-2.5-pro -p "Complex architectural decision" # With file context via pipe cat src/auth.ts | gemini -p "Review this code" # With all files in current directory gemini --all-files -p "Analyze project structure" # With stdin input echo "Error: Cannot connect to database" | gemini -p "Help debug this error" ``` #### Interactive Mode (`-i` flag) For follow-up conversations: ```bash # Start interactive session with initial prompt gemini -i "Let's discuss the architecture" # Interactive with model selection gemini -m gemini-2.5-pro -i "Help me design a database schema" ``` #### YOLO Mode (`-y` flag) Auto-accepts all actions (use with caution): ```bash # Dangerous: Auto-executes suggested commands gemini -y -p "Fix all linting errors" ``` ⚠️ **Warning**: YOLO mode can execute commands without confirmation. Only use in trusted environments. --- ## Model Selection: Flash vs Pro ### gemini-2.5-flash (Default) **Characteristics**: - Fast response time: ~5-25 seconds - Good quality for most tasks - Lower cost - Safe for general questions **Use For**: - Code reviews - Debugging - General questions - Quick consultations - When speed matters **Example**: ```bash gemini -m gemini-2.5-flash -p "Review this function for performance issues" ``` ### gemini-2.5-pro **Characteristics**: - Response time: ~15-30 seconds - Excellent quality, thorough analysis - Higher cost - Best for critical decisions **Use For**: - Architecture decisions (critical) - Security audits (thorough) - Complex reasoning tasks - Major refactoring plans - When accuracy > speed **Example**: ```bash gemini -m gemini-2.5-pro -p "Security audit this authentication system" ``` ### gemini-3-pro-preview (Preview - November 2025) **Characteristics**: - Google's newest and most intelligent AI model (announced Nov 18, 2025) - State-of-the-art reasoning and multimodal understanding - Outperforms Gemini 2.5 Pro on every major AI benchmark - Supports text, image, video, audio, and PDF inputs - Response time: TBD (in testing) - Higher cost (preview pricing) **Use For**: - Most complex reasoning tasks requiring deep analysis - Critical architectural decisions on cutting-edge projects - Advanced multimodal analysis (diagrams, videos, complex docs) - Benchmark-critical applications - When absolute best quality is required (and cost is secondary) **Example**: ```bash gemini -m gemini-3-pro-preview -p "Deep architectural analysis of this distributed system" cat architecture-diagram.png | gemini -m gemini-3-pro-preview -p "Analyze this system design" ``` **⚠️ Preview Status**: Model is in preview. For production-critical decisions, consider using `gemini-2.5-pro` (stable) until Gemini 3 reaches general availability. ### How to Choose ``` Quick question? → Flash Security/architecture? → 3-Pro-Preview (cutting-edge) or 2.5-Pro (stable) Debugging? → Flash (try Pro if stuck) Code review? → Flash Refactoring 5+ files? → 3-Pro-Preview or 2.5-Pro Multimodal analysis? → 3-Pro-Preview ``` --- ## Proactive Consultation Patterns ### Pattern 1: Architecture Decision **Trigger**: User asks about technology choice **Claude Action**: Automatically consult Gemini for second opinion ```bash # Claude runs: gemini -m gemini-2.5-pro -p "Compare D1 vs KV for session storage in Cloudflare Workers. Consider: read/write patterns, cost, performance, complexity." # Then synthesizes both perspectives ``` ### Pattern 2: Security Review **Trigger**: Working on auth/payment/sensitive code **Claude Action**: Request Gemini security audit ```bash # Claude runs: cat src/auth/verify-token.ts | gemini -m gemini-2.5-pr
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.