Gemini Command Line Tool Tips and Tricks
Gemini CLI – Pro Tips & Complete Usage Guide
This guide is also available to star/follow on our GitHub repository.
---
Introduction
Gemini CLI is an open-source AI assistant that brings the power of Google’s Gemini model directly into your terminal. It works as a conversational, agentic command-line tool — meaning it can:
- Understand your requests
- Choose and execute the right tools (shell commands, file edits, etc.)
- Carry out multi-step plans to improve your development workflow
In practice, Gemini CLI acts like a highly capable pair programmer and command-line assistant. It excels at:
- Coding tasks
- Debugging
- Generating content
- Automating system operations
… all via natural language prompts.
---

Example:
gemini "Write a Python script to scrape headlines from a news site"
Gemini CLI will generate the solution and can execute it — making it far more than just a static code generator.
---
Getting Started
Installation
You can install Gemini CLI globally via npm:
npm install -g @google/gemini-cli
Or run it without installation using `npx`:
npx @google/gemini-cli
Gemini CLI is built with Node.js/TypeScript and runs on all major platforms.
---
Authentication
On first launch, you’ll need to authenticate. Two main options:
- Google Account Login (Free Tier)
- Use Gemini 2.5 Pro for free with generous limits (≈ 60 req/min, 1,000 req/day).
- Sign in with your Google account — no billing required.
- API Key (Paid / Higher-tier Access)
- Obtain from Google AI Studio
- Set it as an environment variable:
export GEMINI_API_KEY="your_api_key_here"
🔹 Note: API key users may get higher quotas and enterprise data protections.
---
Basic Usage
- Interactive Mode
- Run `gemini` with no arguments:
- Gemini can then create files, install dependencies, run tests, etc.
- One-shot Mode
gemini -p "Summarize the main points of the attached file. @./report.txt"
$ gemini
gemini> Create a React recipe management app using SQLite
- Piping Input
echo "Count to 10" | gemini
---
CLI Interface Highlights
- Slash Commands (/) → control session, tools, settings
- Bang Commands (!) → execute shell commands directly
- Safe Mode → requires confirmation before making changes
---
Power User Tips
Below are selected pro tips (this guide contains 28+). Each expands Gemini CLI’s functionality.
---
Tip 1: Persistent Context via `GEMINI.md`
Stop repeating yourself — store project-specific context in `.gemini/GEMINI.md` so Gemini always remembers styles, architecture, or rules.
Example:
# Project Phoenix
## Coding Style
- ESLint + Prettier
- async/await > Promises
## Architecture
- Next.js + Tailwind + Prisma
- JWT auth on all API calls
Use `/memory show` to view current context; `/memory refresh` to reload after edits.
---
Tip 2: Custom Slash Commands
Automate repetitive tasks via `.gemini/commands/*.toml` configs.
E.g., `/test:gen` to auto-generate Jest unit tests from descriptions.
description = "Generate a Jest unit test from requirement"
prompt = """
You are a test engineer. Write a Jest test based on:
Requirement: {{args}}
"""
---
Tip 3: Extend with MCP Servers
Add Model Context Protocol servers for custom tools.
E.g., Figma MCP for design-to-code, Google Docs MCP for document reads.
gemini mcp add myserver --command "python3 my_mcp_server.py" --port 8080
List MCP tools: `/mcp`
---
Tip 4: Memory Add & Recall
Store facts or configs across sessions:
/memory add "Staging RabbitMQ port is 5673"
View: `/memory show`
Refresh: `/memory refresh`
---
Tip 5: Checkpointing & Restore
Snapshot files before tool changes:
gemini --checkpointing
Restore:
/restore list
/restore
---
Tip 6: Read Google Docs & Sheets
With Workspace MCP integration, reference live docs:
@https://docs.google.com/document/d/
Gemini will pull content into your prompt context.
---
Tip 7: Reference Files & Images (`@` syntax)
Attach exact content to prompts:
Explain this code: @./src/main.js
Works for files, directories, and images.
---
Tip 8: On-the-Fly Tool Creation
Prompt Gemini to write helper scripts during a session, e.g., batch log analyzer.
---
Tip 9: System Troubleshooting
Run in home dir to edit dotfiles (`@~/.bashrc`), check configs, or install tools.
---
Tip 10: YOLO Mode
Auto-approve tool actions:
gemini --yolo
⚠️ Use with caution; skips confirmation prompts.
---
Tip 11: Headless/Scripting Mode
Run single prompts in scripts:
gemini -p "Generate a blog outline"
Custom system prompt:
export GEMINI_SYSTEM_MD="/path/to/system.md"
---
Tip 12: Save & Resume Chats
/chat save
/chat resume
Continue multi-day conversations seamlessly.
---
Tip 13: Multi-Directory Workspace
Include multiple folders in context:
gemini --include-directories ./frontend ./backend
---
Tip 14: Organize Files
AI-assisted folder cleanup, categorization, and renaming using image content.
---
Tip 15: Compress Long Conversations
Maintain relevance and stay within context limits:
/compress
---
Tip 16: Shell Passthrough (`!`)
Run shell commands inline:
!ls -lh
Persistent shell mode: `!` (empty) then commands.
---
Tip 17: Every CLI Tool is a Gemini Tool
Any tool in `$PATH` can be used — install helpful CLIs, restrict risky ones.
---
Tip 18: Multimodal Input
Reference images/PDF/audio for analysis with model’s vision capabilities.
---
Tip 19: Customize `$PATH`
Run Gemini with restricted tool availability:
PATH=/usr/bin gemini
---
Tip 20: Token Caching & Stats
Reduce costs via API key caching; check usage:
/stats
---
Tip 21: `/copy` to Clipboard
Copies last output directly to system clipboard.
---
Tip 22: Ctrl+C Mastery
- Once: abort current action
- Twice: exit CLI
---
Tip 23: Settings via `settings.json`
Change theme, tool permissions, directories:
{
"theme": "dark",
"sandbox": "docker"
}
---
Tip 24: IDE Integration (VS Code)
Gemini can track open files/selection and show AI diffs in VS Code.
---
Tip 25: GitHub Action Integration
Run Gemini CLI as a repo bot for PR reviews, issue triage.
---
Tip 26: Telemetry
Enable OpenTelemetry for usage stats and performance monitoring.
---
Tip 27: Follow the Roadmap
Upcoming: background agents for async tasks; engage via GitHub issues.
---
Tip 28: Extensions
Install modular capabilities:
gemini extensions install
Examples: Cloud Run deployment, Figma design tools, payment APIs.
---
Easter Egg: Corgi Mode 🐕
`/corgi` toggles animated ASCII corgi across your terminal.
---
Conclusion
Gemini CLI is a Swiss army knife of AI capabilities in your terminal — from persistent memory, multimodal input, custom tooling, automation, and integration with IDEs, CI/CD, and external APIs.
Pairing Gemini CLI with content ecosystems like AiToEarn lets creators generate → publish → monetize across platforms including:
- Douyin, Kwai, WeChat, Bilibili, Xiaohongshu
- Facebook, Instagram, LinkedIn, Threads, YouTube, Pinterest, X (Twitter)
… consolidating AI-assisted development and cross-platform content strategies.
---
Learn more:
- Gemini CLI Repository
- AiToEarn GitHub
- Beyond the Command Line – book site with free resources
---
Would you like me to prepare a condensed quick-reference cheat sheet summarizing these 28 tips for faster lookup? It would be a one-page markdown table.