← Back to articles

Gemini CLI

Path: Computer Tech/AI/ML/Gemini CLI.mdUpdated: 2/3/2026

Gemini CLI

Google's Gemini AI in the terminal with a generous free tier - the best entry point for terminal-based AI workflows.

Key advantage: Free access to Gemini 2.5 Pro with file access, web search, and bash/Python execution.

Installation

Linux/WSL:

bash
curl -fsSL https://get.gemini.google.dev/cli | bash

# Or with sudo if needed
curl -fsSL https://get.gemini.google.dev/cli | sudo bash

macOS (Homebrew):

bash
brew install gemini-cli

First Launch

bash
# Navigate to project directory
cd ~/projects/my-project

# Launch Gemini
gemini

Login:

  1. Browser opens for Google account authentication
  2. Works with free Gmail accounts
  3. No credit card required

Free Tier

What's included:

  • Model: Gemini 2.5 Pro (latest)
  • Context window: 200,000 tokens
  • Rate limits: Generous for personal use
  • Tools: File access, web search, bash/Python execution

No payment needed - standard Google account is sufficient.

Core Features

File Access

Gemini can read and write files:

markdown
Research the top 10 coffee brewing methods from reputable 
sources and compile results into best-coffee-method.md

Gemini will:

  1. Search the web
  2. Compile findings
  3. Ask permission to create file
  4. Write to your project directory

No copy/paste needed - files appear directly in your filesystem.

Available Tools

View enabled tools:

bash
# Inside Gemini session
/tools

Default tools:

  • execute_code - Run bash/Python scripts
  • google_search - Web search
  • code_execution - Multi-language code execution
  • file_access - Read/write project files

Add custom tools via configuration (advanced).

Web Search Integration

markdown
Find the latest benchmarks for AMD Ryzen 9000 series CPUs 
and summarize key performance improvements

Gemini automatically:

  • Searches Google
  • Filters reputable sources
  • Synthesizes findings
  • Cites sources

Context Window Visibility

Unlike browser interface, terminal shows context usage:

99% context left

Monitor context consumption:

  • Every question reduces available context
  • Visible percentage helps you manage conversation length
  • Browser version hides this information

When context fills up:

  1. Start new session
  2. Use context file (gemini.md) to maintain continuity
  3. AI loads context from file automatically

Context File Workflow

Initialize project context:

bash
# Inside Gemini session
/init

This creates gemini.md:

  • Analyzes project directory
  • Describes purpose based on files
  • Tracks decisions and progress
  • Auto-loaded on future sessions

Example gemini.md:

markdown
# Coffee Project

## Purpose
Research and blog series about coffee brewing methods.

## Current Status
- Completed: Initial research (10 methods documented)
- In Progress: Blog post #1 (intro to pour-over)
- Next: Record video demonstrations

## Key Decisions
- Focus on beginner-friendly methods first
- Include cost breakdowns for each method
- Video series to complement written posts

## Files
- best-coffee-method.md - Research compilation
- coffee-blog-plan.md - Series outline

New session in same directory:

bash
gemini
# Automatically loads gemini.md
# Full context restored

Update context:

markdown
Update gemini.md to reflect that we finished blog post #1

Headless Mode

Run Gemini without TUI:

bash
gemini -p "your prompt here"

Use cases:

  • Quick one-off queries
  • Scripting/automation
  • Called by other AI agents

Example:

bash
gemini -p "Find the top 5 NAS systems under $500"

Output printed directly to stdout.

Multi-AI Workflow

Gemini works alongside Claude and Codex:

Same directory approach:

bash
# Terminal 1
gemini

# Terminal 2
claude

# Terminal 3
codex

Shared context via .md files:

  • gemini.md - Gemini's context
  • claude.md - Claude's context
  • agents.md - Codex's context

Keep synced:

markdown
# In Claude
Update gemini.md and claude.md to reflect research completion

Division of labor:

  • Gemini: Web research (free tier advantage)
  • Claude: Complex writing and analysis
  • ChatGPT: High-level review

All working on same project files simultaneously.

Commands

CommandAction
/initCreate gemini.md context file
/toolsShow available tools
/helpShow all commands
Ctrl-CInterrupt response

Example Workflows

Research + Documentation

markdown
Research the top 10 JavaScript testing frameworks. 
For each, note:
- Popularity (npm downloads)
- Key features
- Best use cases

Save results to testing-frameworks.md

Gemini:

  1. Searches web
  2. Gathers data
  3. Asks permission to create file
  4. Writes structured markdown

Code Execution

markdown
Write a Python script that analyzes my /logs/ directory 
and creates a summary of error frequencies. 
Run the script and save output to error-summary.txt

Gemini:

  1. Reads files in /logs/
  2. Writes Python script
  3. Executes script
  4. Saves output

Iterative Development

bash
# Session 1
gemini
> Create a bash script to organize my downloads folder

# Session 2 (next day)
gemini
# Loads gemini.md automatically
> Update the script to also move images to Photos/

Context persists via gemini.md file.

Comparison: Gemini CLI vs Browser

FeatureTerminalBrowser
Context visibilityPercentage shownHidden
File accessDirect filesystemCopy/paste only
Persistencegemini.md filesStuck in chat
Multi-toolWorks with Claude/CodexSiloed
ScriptingHeadless modeNot available
ModelGemini 2.5 ProSame
Free tierYesYes

Tips

Leverage free tier:

  • Use Gemini for research tasks
  • Offload web searches from paid Claude sessions
  • Headless mode for automation

Context management:

  • Initialize gemini.md early
  • Update context at end of sessions
  • Start new session when context fills

Multi-AI optimization:

  • Gemini for research (free)
  • Claude for complex writing (paid)
  • ChatGPT for review (paid)
  • All work in same directory

File permissions:

  • Gemini asks before creating files (security)
  • Approve file operations you trust
  • Review files after AI writes them

Common Use Cases

Web research:

markdown
Find the latest research on lithium battery recycling 
and summarize environmental impact

Data analysis:

markdown
Read sales-data.csv and create a summary with:
- Total revenue
- Top 5 products
- Month-over-month growth

Documentation:

markdown
Read all .js files in /src/ and create API documentation 
in api-docs.md

Code debugging:

markdown
Review error-log.txt and suggest likely causes 
for the timeout errors

Links

Gemini CLI Documentation

NetworkChuck Video: You've Been Using AI the Hard Way