Welcome!
This guide will get you from zero to your first working Gemini CLI command in just a few minutes.Already installed? Jump to Start Your First Session.
Step 1: Install Gemini CLI
Choose your preferred installation method:- npm (Recommended)
- npx (No Install)
- Homebrew
- MacPorts
Need more installation options? See the Installation Guide for Anaconda, Docker, and other methods.
Step 2: Start Your First Session
Launch Gemini CLI:Step 3: Authenticate
Choose your authentication method based on your account type:Select Authentication Method
When prompted “How would you like to authenticate for this project?”, choose:
- Login with Google (recommended for most users)
- Use Gemini API key (if you have an API key from AI Studio)
- Vertex AI (for enterprise/cloud users)
Complete Authentication
For Login with Google:
- A browser window will open
- Sign in with your Google account
- Grant permissions when prompted
- Return to your terminal
- Set your API key first:
export GEMINI_API_KEY="your-key" - Then run
gemini
Step 4: Try Your First Commands
Now let’s try some basic commands to see Gemini CLI in action:Example 1: Ask a Question
Example 2: Code Explanation
If you have code files in your directory:Example 3: Generate Code
Gemini CLI always asks for permission before executing commands, writing files, or making changes to your system.
Step 5: Learn Essential Commands
Here are some key slash commands to enhance your workflow:/help
Display all available commands
/chat
Start a new conversation
/model
Switch between Gemini models
/stats
View token usage and quota
Real-World Examples
Let’s explore some practical use cases:Create a New Project from Scratch
Analyze an Existing Repository
Automate File Management
Advanced Usage
Non-Interactive Mode (for Scripts)
Run Gemini CLI non-interactively for automation:Include Additional Directories
Provide more context from related directories:Choose a Specific Model
Understanding Permissions
Gemini CLI asks for permission before:File Operations
- Reading files
- Writing new files
- Modifying existing files
- Deleting files
System Operations
- Running shell commands
- Installing packages
- Executing scripts
- Network requests
- Allow once - Grant permission for this action only
- Allow all - Grant permission for all actions in this session
- Deny - Reject the action
Check Your Usage
Monitor your token usage and quota:- Current session token usage
- Overall quota for your account
- Usage by model
- Remaining quota
Free tier includes 60 requests/min and 1,000 requests/day for individual Google accounts.
Tips for Success
Be Specific with Your Prompts
Be Specific with Your Prompts
The more context you provide, the better results you’ll get:❌ “Create a server”✅ “Create a Node.js Express server with endpoints for GET /users and POST /users, using JSON file storage”
Use Context Files
Use Context Files
Create a
GEMINI.md file in your project root to provide persistent context:Break Down Complex Tasks
Break Down Complex Tasks
For large projects, break work into smaller steps:
Review Before Allowing
Review Before Allowing
Always review what Gemini plans to do:
- Check file paths
- Review commands before execution
- Understand what will be modified
Keyboard Shortcuts
Speed up your workflow with these shortcuts:| Shortcut | Action |
|---|---|
Ctrl+C | Cancel current operation |
Ctrl+D | Exit Gemini CLI |
↑ / ↓ | Navigate command history |
Tab | Auto-complete (when available) |
See the Keyboard Shortcuts Reference for a complete list.
Troubleshooting
Authentication keeps failing
Authentication keeps failing
- Clear cached credentials:
rm -rf ~/.gemini/credentials - Try using an API key instead:
export GEMINI_API_KEY="your-key" - Check your internet connection
- Verify you’re in a supported location
Gemini can't see my files
Gemini can't see my files
- Ensure you’re in the correct directory
- Use
--include-directoriesto add more context - Check file permissions
- Try explicitly mentioning the file: “Read the contents of src/app.js”
Responses are slow
Responses are slow
- Try a faster model:
/model gemini-2.5-flash - Reduce context by limiting included directories
- Check your internet connection
- Consider if you’re hitting rate limits (check with
/stats model)
Commands not executing
Commands not executing
- Verify you granted permission when prompted
- Check that required tools are installed (git, npm, etc.)
- Review error messages carefully
- Try running the command manually to debug
Next Steps
Now that you’re up and running, explore more features:Commands Reference
Learn all available slash commands
Configuration Guide
Customize Gemini CLI to your workflow
MCP Server Integration
Extend Gemini CLI with custom tools
Examples & Tutorials
Explore real-world use cases
Get Help
Need assistance?- Use
/helpin the CLI for built-in help - Check the FAQ for common questions
- Report bugs with
/bugor on GitHub Issues - Read the Troubleshooting Guide