Gemini CLI Configuration
Customize Gemini CLI to match your workflow. Learn about settings files, model selection, custom instructions, extensions, environment variables, and MCP server support.
Settings Files
Gemini CLI uses a layered configuration system with settings files at different levels:
| Level | Location | Scope |
|---|---|---|
| Global | ~/.gemini/settings.json |
All projects on your machine |
| Project | .gemini/settings.json |
Current project only |
{
"model": "gemini-2.5-pro",
"temperature": 0.7,
"maxOutputTokens": 8192,
"sandbox": false,
"theme": "dark",
"autoApprove": false,
"excludePatterns": [
"node_modules/**",
"dist/**",
".git/**",
"*.lock"
]
}
Model Selection
Choose the right Gemini model for your task:
# Use Pro for complex tasks (default) $ gemini --model gemini-2.5-pro # Use Flash for fast, simple tasks $ gemini --model gemini-2.5-flash # Set default model in settings $ gemini config set model gemini-2.5-flash # Check current model $ gemini config get model
| Model | Best For | Speed | Cost |
|---|---|---|---|
| gemini-2.5-pro | Complex tasks, multi-file edits, architecture | Moderate | Higher |
| gemini-2.5-flash | Quick questions, simple edits, exploration | Fast | Lower |
Custom Instructions
Provide project-specific context and rules that Gemini CLI follows in every interaction:
# Project: E-Commerce API ## Tech Stack - Node.js 20 with TypeScript - Express.js for REST API - PostgreSQL with Prisma ORM - Jest for testing - Docker for deployment ## Coding Standards - Use functional programming patterns - All functions must have TypeScript types - Use Prisma for all database operations - Follow REST naming conventions - Write tests for all new functions ## Architecture - Routes in src/routes/ - Business logic in src/services/ - Database queries in src/repositories/ - Shared types in src/types/ - Utilities in src/utils/ ## Important Notes - Never modify migration files directly - Always use environment variables for secrets - Rate limiting is required on all public endpoints
Extensions
Extend Gemini CLI's capabilities with custom extensions and integrations:
{
"extensions": {
"web-search": {
"enabled": true
},
"image-generation": {
"enabled": true,
"model": "imagen-3"
}
}
}
Environment Variables
Configure Gemini CLI behavior through environment variables:
# Authentication export GEMINI_API_KEY="your-api-key" # Model selection export GEMINI_MODEL="gemini-2.5-pro" # Proxy settings (for corporate networks) export HTTP_PROXY="http://proxy:8080" export HTTPS_PROXY="http://proxy:8080" # Logging export GEMINI_LOG_LEVEL="debug" # Custom config directory export GEMINI_CONFIG_DIR="~/.config/gemini"
MCP Server Support
Gemini CLI supports the Model Context Protocol (MCP), allowing you to connect it to external tools and data sources:
{
"mcpServers": {
"database": {
"command": "npx",
"args": ["@modelcontextprotocol/server-postgres"],
"env": {
"DATABASE_URL": "postgresql://localhost:5432/mydb"
}
},
"github": {
"command": "npx",
"args": ["@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "ghp_your_token"
}
},
"filesystem": {
"command": "npx",
"args": [
"@modelcontextprotocol/server-filesystem",
"/path/to/allowed/dir"
]
}
}
}
Popular MCP Servers
- PostgreSQL/MySQL: Query and manage databases directly from Gemini CLI
- GitHub: Read issues, PRs, and repository data
- Filesystem: Access files outside the project directory
- Slack: Read and send messages in channels
- Google Drive: Access and search documents
- Custom servers: Build your own MCP server for any data source
💡 Try It: Create a GEMINI.md
Create a GEMINI.md file in one of your projects with details about the tech stack, coding standards, and architecture. Then start Gemini CLI and ask it to explain the project. Notice how it uses the custom instructions to provide more contextual answers.
Ready to Go Deeper?
Live instructor-led courses from our partners. Affiliate disclosure.
AI & ML Courses - 30% Off
Live instructor-led AI, machine learning, data science, and cloud courses for working professionals. Use code Limited30 at checkout.
EdurekaDataCamp - AI & Data Science
Hands-on Python, machine learning, and AI courses with interactive exercises and real projects.
DataCampedX - Top AI Courses
University-level AI courses from MIT, Harvard, Stanford. Earn certificates that employers recognize.
edX