Google Gemini CLI Cheatsheet: The Terminal Power User’s Guide
What is Google Gemini CLI?
Google Gemini CLI is Google’s open-source command-line AI agent that embeds Gemini’s large language models directly into your terminal. Its powerful natural language processing allows you to code, debug, generate content, automate repetitive tasks, and even interact with external APIs and code repositories—all from the simplicity and speed of the command line.
Gemini CLI is:
- Free to use with generous model request limits (60/min, 1,000/day).
- Cross-platform (Windows, Mac, Linux).
- Fully open-source and extensible, supporting plugins, context, and custom tools.
- Authentication-flexible: personal Google account or Gemini API key
Gemini CLI Commands Cheatsheet
Below is a distilled cheatsheet with the top Gemini CLI commands, flags, shortcuts, and developer workflows for 2025.
Installation & Launch
- Prerequisites: Node.js v18 or newer.
- Install globally:
npm install -g @google/gemini-cli
- Run without install (npx):
npx @google/gemini-cli
- Start interactive mode:
gemini
Authentication
Authenticate with a Google account or Gemini API key:
- Default (recommended):
Personal Google login (web popup on first run). - API key (for advanced/pro usage):
export GEMINI_API_KEY="YOUR_KEY"
Or add to~/.gemini/.env
or project.gemini/.env
.
Basic Usage Patterns
- Interactive REPL:
Launch terminal session.gemini
- One-off completion:
gemini -p "Summarize this code"
- Piping:
cat notes.txt | gemini
- Model selection:
gemini --model gemini-1.5-flash
- Debugging:
gemini --debug
Essential Slash Commands (/)
Slash Command | Description |
---|---|
/help | Show help with all commands |
/tools | List available AI tools |
/extensions | Show active extensions |
/clear | Clear chat/terminal context |
/compress | Summarize and compress conversation context |
/copy | Copy last response to clipboard |
/mcp | List configured Model Context Protocol (MCP) servers and tools |
/chat save <tag> | Save current chat, tagged for resumption |
/chat resume <tag> | Reopen previous saved chat |
/restore | View or restore checkpoints (undo recent changes) |
/memory show | Display loaded context from all GEMINI.md files |
/memory refresh | Reload GEMINI.md for updated project instructions |
/stats | View token usage and request stats |
/bug | File an issue or bug report directly |
/auth | Change auth method (switch account or key) |
/theme | Change CLI visual theme |
/quit | Exit Gemini CLI session |
Contextual Reference (@)
- Reference a file:
@./src/main.js
(adds contents to prompt context) - Reference a directory:
@./project/
(includes all files recursively, respects.gitignore
) - Multi-reference:
@./fileA.py @./fileB.py
Shell Integration (!)
- Run a shell command:
!git status
- Enter persistent shell mode:
Type!
alone to toggle shell mode. Exit with another!
.
Sandbox Mode and Extensions
- Run in sandbox (secure):
--sandbox
(requires Docker/Podman) - Add/Remove Extensions (custom tools):
/extensions add <ext>
or manual edit to settings.
Advanced Features & Model Context Protocol (MCP)
MCP Integration
- Connect external tools (GitHub, Notion, cloud):
Add to.gemini/settings.json
:
json"mcpServers": { "github": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"], "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_TOKEN" } } }
- List MCP tools:
/mcp
- Use GitHub/Notion/other tools via CLI after server config
Checkpoints and Restores
- Save project state before file changes:
CLI auto-checkpoints before major modifications (--checkpointing) - Restore:
/restore [checkpoint_name]
Custom Project Instructions
- Add GEMINI.md in project root to specify coding standards, tool configs, or project rules—Gemini honors these across sessions.
Context and Memory
- Gemini CLI leverages 1,000,000-token context. Use /memory show to inspect loaded context for large codebases.
Top Gemini CLI Developer Workflows
- Code Review:
gemini -p "Review all code changes in @./src/"
- Explain Errors:
gemini interactive; paste error message. - Project Documentation:
gemini -p "Generate README.md for @./project/"
- AI-Powered Refactoring:
gemini
then> Refactor the directory @./src/ to use async/await.
- Multi-modal Prototyping:
gemini
then> Generate an app prototype from @./ui-mockup.png
Google Gemini CLI Pro Tips
- Speed: Use keyboard up/down for prompt history.
- Security: Use API keys and .env for safer automation in scripts.
- Automation: Integrate with bash scripts for custom devops workflows.
- Customization: Edit settings in .gemini/settings.json for global or project preferences.
- Plugin Ecosystem: Explore extensions and MCP servers for integrating new models, tools, and APIs as new use cases emerge.
Frequently Asked Questions (FAQs) – Google Gemini CLI Cheatsheet
1. What is the best way to install the Google Gemini CLI?
Install globally with npm install -g @google/gemini-cli or run via npx @google/gemini-cli. Node.js v18+ is required.
2. How do I authenticate Gemini CLI—Google account or API key?
For most, use your personal Google account at first launch, which grants free, high-limits. For advanced use, set the GEMINI_API_KEY as an environment variable or .env file for API key authentication.
3. How can I access and use context from my codebase in prompts?
Reference files or folders in prompts with @./src/file.js or @./directory/ and use GEMINI.md for custom project rules.
4. What is the Model Context Protocol (MCP) in Gemini CLI?
MCP is the open protocol Google Gemini CLI uses to integrate external tools like GitHub, Notion, or cloud APIs—add servers in .gemini/settings.json and use /mcp to list available actions.
5. How do I monitor Gemini CLI usage and rate limits?
Use /stats to see token usage, queries per session, and request quotas. Personal Google login offers 1,000 free model requests/day and 60/minute; see quota in session.
Summary
Google Gemini CLI cheatsheet is your definitive resource for Google’s command-line AI agent. Combining open-source flexibility, deep integration with APIs and tools through MCP, multimodal support, robust free usage quotas, and intuitive commands, Gemini CLI ushers in a new era of developer productivity right from the terminal. With slash, context, and shell commands, checkpointing, and customization options, power users can automate, code, document, and create seamlessly. By leveraging this cheatsheet, you unlock the full potential of Gemini CLI—placing world-class AI, advanced code analysis, and automation at your fingertips.
Reference Links

Let's talk with us!
If you have any questions, feel free to write.
Tailored Digital Solutions
We design and build custom digital products that align with your business goals, ensuring every solution is a perfect fit for your needs.
Cutting-Edge Technology
Our team leverages the latest tools and frameworks to deliver innovative, high-performance solutions that keep you ahead of the curve.
Reliable Ongoing Support
We provide continuous support and proactive maintenance, so your digital products remain secure, up-to-date, and running smoothly.