Gemini CLI Skill
This skill helps you run Google's Gemini CLI (@google/gemini-cli) effectively — constructing the right command for the user's intent and executing it.
How to use this skill
- Understand intent: Figure out what the user wants to do with Gemini
- Construct command: Pick the right flags and subcommands (see reference below)
- Execute: Run via
Bashtool — for non-interactive use always use-pflag - Handle output: Show results, pipe further if needed
Key decision: interactive vs non-interactive
- Non-interactive (use
-p): When you're running gemini programmatically, analyzing files, answering questions, scripting — the vast majority of Claude Code invocations. Output goes to stdout. This is what you should almost always use. - Interactive (no
-p): Only suggest this when the user explicitly wants a back-and-forth conversation session in their own terminal. You cannot run this via Bash tool — tell the user to run it themselves.
Core command patterns
# Non-interactive query (most common — use this for programmatic use)
gemini -p "your question or task here"
# Non-interactive with specific model
gemini -m flash -p "summarize this"
# Non-interactive with JSON output (for scripting)
gemini -o json -p "extract the key points"
# Pipe file content to gemini
cat file.txt | gemini -p "summarize this"
# Pipe and analyze
cat error.log | gemini -p "what caused these errors and how do I fix them?"
# Non-interactive with sandbox (safer for code execution tasks)
gemini -s -p "run the tests and tell me what failed"
# Resume a previous session non-interactively
gemini -r latest -p "now also check for type errors"
# List sessions
gemini --list-sessions
# Check version
gemini --version
# Update gemini
gemini update
When the user wants an interactive session
If the user says "open gemini", "start a gemini session", "chat with gemini" — they want interactive mode. You cannot run this via Bash since it needs a TTY. Instead, tell them to run one of these in their terminal:
gemini # Start fresh interactive session
gemini "explain this project" # Start with an initial prompt, then continue
gemini -i "fix the bug" # Run prompt then drop into interactive mode
gemini -r latest # Resume last session interactively
Model selection
The -m / --model flag accepts these aliases:
auto(default) — best available pro modelpro— Gemini 2.5 Pro, best reasoningflash— Gemini 2.5 Flash, fast and balancedflash-lite— Gemini 2.5 Flash Lite, fastest for simple tasks
Use flash for quick tasks, pro for complex reasoning, leave as default if unsure.
Subcommand management
For extensions, MCP, and skills management, see references/subcommands.md for the full command reference. These are always non-interactive and safe to run via Bash.
Output formats
text(default) — human-readablejson— structured JSON, good for piping tojqstream-json— newline-delimited JSON events for real-time streaming
Example with JSON output:
gemini -o json -p "list the top 5 issues in this code" | jq '.[]'
Piping patterns
# Analyze a file
cat README.md | gemini -p "what does this project do?"
# Analyze code
cat src/main.py | gemini -p "find potential bugs"
# Multiple files (use shell substitution)
gemini -p "review these files for security issues: $(cat auth.py database.py)"
# Git diff review
git diff | gemini -p "summarize these changes and flag any concerns"
# Log analysis
tail -n 100 app.log | gemini -p "what errors are happening and why?"
Important notes
- Gemini CLI is installed at
@google/gemini-cli(npm global). Thegeminicommand should be available in PATH. - If
geminiis not found, the user may need to run:npm install -g @google/gemini-cli - Auth: Gemini needs either a Google account (OAuth) or
GEMINI_API_KEYenv var set. If it fails with auth errors, ask the user to rungeminiinteractively once to authenticate. - The
-pflag forces non-interactive mode and is essential for scripted/automated use.
Reference
See references/subcommands.md for the full reference on:
- Extensions management commands
- MCP server management commands
- Skills management commands
- All CLI flags and options