Official References: Overview · Installation · Authentication · GEMINI.md
Why Gemini CLI feels different
Gemini CLI is Google's open-source terminal agent. Its current positioning is simple: bring Gemini models, local tools, web access, and project context into one CLI that works well for both interactive sessions and automation.
For this project, Gemini CLI matters most in three situations:
- Large-repo understanding — the 1M-token context window is good for broad architectural passes.
- Mixed local + web workflows — the tool system can read files, run shell commands, and fetch current information.
- Reusable project guidance —
GEMINI.mdgives you persistent instructions without rewriting the same prompt every time.
Install it the practical way
Gemini CLI currently recommends Node.js 20+.
# npm global install
npm install -g @google/gemini-cli
# macOS / Linux
brew install gemini-cli
# no permanent install
npx @google/gemini-cliPick the right authentication path
The official docs split auth into a few clear cases:
| Situation | Best option | Notes |
|---|---|---|
| Personal local usage | Sign in with Google | Simplest default flow |
| Headless scripts / CI | Gemini API key | Easy env-var based setup |
| GCP-heavy org setup | Vertex AI | Fits existing Google Cloud controls |
| Workspace / school account | Google sign-in + project config | Often needs a Cloud project |
1) Sign in with Google
geminiThen choose the Google sign-in flow in the CLI.
2) Use a Gemini API key
Best for scripts, headless jobs, or minimal local setup:
export GEMINI_API_KEY="YOUR_GEMINI_API_KEY"
gemini3) Use Vertex AI
Best when your team already manages models through Google Cloud:
export GOOGLE_CLOUD_PROJECT="your-project-id"
export GOOGLE_CLOUD_LOCATION="us-central1"
geminiFirst commands and Core Workflows
Gemini CLI is strongest when you use its tool syntax instead of writing giant prompts manually.
Basic Interaction
# Start interactive mode
gemini
# Include files or directories with @
gemini "@package.json @src explain the app architecture"
# Run shell commands with !
!npm testThe Core Workflow: Research -> Strategy -> Execution
Instead of just chatting, guide the agent through explicit phases:
- Research: Ask the agent to explore (
grep_search,glob) and map the codebase. - Strategy: Ask it to design an approach before making changes.
- Execution: Let it apply surgical changes (
replace,write_file) and validate via shell tools.
Utilizing Plan Mode (/plan)
For large refactoring or architectural decisions, it is risky to let the agent start editing immediately.
Use the /plan command to enter Plan Mode. In this read-only state, the agent cannot modify files or run destructive commands. It focuses entirely on navigating the code and drafting a rigorous design document. Once the plan is verified, switch back to the default mode to execute the changes safely.
GEMINI.md is the real unlock
Gemini CLI loads GEMINI.md hierarchically:
~/.gemini/GEMINI.md(global preferences)- workspace context files (project-wide rules)
- JIT context files inside subdirectories
Example project file
# Project: AI Native Notes
## Stack
- Next.js 16
- TypeScript
- next-intl
- MDX content under /content
## Content rules
- Keep frontmatter consistent across locales
- Prefer practical examples over marketing copy
- Preserve slug parity between ko/en/esGemini CLI vs Claude Code vs GPT Codex
| Feature | Claude Code | GPT Codex | Gemini CLI |
|---|---|---|---|
| Main instruction file | CLAUDE.md | AGENTS.md | GEMINI.md |
| Context style | strong conversational memory | task-scoped execution | hierarchical memory + large context |
| Local tooling | local + MCP | sandbox/container oriented | local + web + MCP + sub-agents |
| Best first use | guided editing | bounded implementation tasks | repository understanding + large refactors |
Recommended next reads
- Repo-scale analysis: The 1M Token Advantage
- Delegating tasks: Sub-agents and Skills
- CI workflows: Headless Automation