Gemini CLI Development
Source: https://github.com/google-gemini/gemini-cli
Gemini CLI is Google's AI-powered command-line assistant built on Gemini models. This skill provides quick reference for effective usage, customization, and integration.
Best Practices
Getting Started
- Install via npm:
npm install -g @google/gemini-cli
- Authenticate with Google account for personal use, or configure a GCP project for enterprise
- Create a GEMINI.md in project roots with project-specific context (similar to CLAUDE.md)
- Use trusted folders to grant file system access to specific directories
Effective Usage
- Be specific with requests - "Fix the login bug in auth.ts" beats "fix bugs"
- Use context files - Reference files with
@filename or drag-and-drop
- Leverage checkpoints - Save conversation state for complex multi-step tasks
- Use headless mode for scripting and CI/CD integration
Model Selection
# Use Gemini 2.5 Pro (default)
gemini
# Use Gemini 2.5 Flash for faster responses
gemini --model gemini-2.5-flash
# Use Gemini 3 Pro Preview for best quality
gemini --model gemini-3-pro-preview
Custom Commands
Create reusable commands in .gemini/commands/:
<!-- .gemini/commands/review.md -->
---
description: Review code for best practices
---
Review the provided code for:
- Security vulnerabilities
- Performance issues
- Code style and readability
Provide specific, actionable feedback.
Use with: /review @src/auth.ts
Hooks
Automate workflows with hooks in .gemini/hooks.json:
{
"hooks": [
{
"event": "after-tool",
"tool": "write_file",
"command": "prettier --write $FILE"
}
]
}
Hook events:
before-agent / after-agent
before-model / after-model
before-tool / after-tool
session-start / session-end
Tools
Gemini CLI has built-in tools:
| Tool |
Description |
read_file |
Read file contents |
write_file |
Create or overwrite files |
edit_file |
Make targeted edits |
list_directory |
List files in a directory |
run_shell_command |
Execute shell commands |
web_search |
Search the web |
web_fetch |
Fetch URL content |
save_memory |
Persist information |
get_memory |
Retrieve saved info |
MCP Integration
Add MCP servers in settings:
{
"mcpServers": {
"my-server": {
"command": "node",
"args": ["./mcp-server.js"]
}
}
}
Sandboxing
- Enable sandbox for untrusted code execution
- Sandbox restricts file system access to current directory
- Network access is blocked in sandbox mode
- Use
--sandbox flag or configure in settings
Cost Management
- Free tier: Google AI Studio authentication (rate limited)
- Paid tier: GCP project with Vertex AI
- Token caching reduces costs for repeated queries
- Monitor usage in Google Cloud Console
Quick Reference
Common Commands
# Start interactive session
gemini
# Start with initial prompt
gemini "explain this codebase"
# Headless mode
gemini -p "fix the typo in README.md"
# Continue previous session
gemini --continue
# Use specific model
gemini --model gemini-2.5-flash
# JSON output mode
gemini --json -p "list files in src/"
Slash Commands
| Command |
Purpose |
/help |
Show available commands |
/clear |
Clear conversation |
/save |
Save checkpoint |
/load |
Load checkpoint |
/stats |
Show token usage |
/settings |
Open settings |
/memory |
Manage saved memories |
Keyboard Shortcuts
| Shortcut |
Action |
Ctrl+C |
Cancel current operation |
Ctrl+D |
Exit CLI |
Ctrl+L |
Clear screen |
Up/Down |
Navigate history |
Tab |
Autocomplete |
Environment Variables
GOOGLE_CLOUD_PROJECT # GCP project ID
GOOGLE_APPLICATION_CREDENTIALS # Service account key path
GEMINI_MODEL # Default model
GEMINI_SANDBOX # Enable sandbox (true/false)
Documentation Index
Detailed official documentation is synced to resources/. Consult these for specifics.
Getting Started
CLI Reference
Tools
Core Architecture
Extensions
Hooks
IDE Integration
Reference
Syncing Documentation
Resources are synced from the official Gemini CLI GitHub repository. To update:
cd skills/gemini-cli
bun run scripts/sync-docs.ts