Gemini CLI: The Same Brain in Your Terminal
Some work doesn't happen in an editor: servers you SSH into, CI pipelines, quick questions about a repo you haven't opened. Gemini CLI brings the assistant there — and because it shares configuration with Code Assist, everything you built in G05–G07 comes along.
What Gemini CLI Is
Your IDE assistant is like a workshop assistant who lives in your garage — brilliant, but only helpful when you're standing in the garage. The pain comes the moment work happens elsewhere: you're on a remote server over SSH at 2am, or you want a nightly script to summarize what changed — and your garage assistant can't follow you there. Gemini CLI is the same assistant in a van: it goes wherever a terminal goes, carries the same handbook (your GEMINI.md), the same toolbox (your MCP servers from ~/.gemini/settings.json), and will even work unattended when you leave written instructions (headless mode).
Gemini CLI is Google's open-source terminal AI agent. It runs interactively (a conversational REPLRead-Eval-Print Loop — an interactive prompt where you type input, the program responds, and the session keeps state between turns. in your shell) or headlessly (one-shot, scriptable). Key relationships with Gemini Code Assist:
- License & quota: a Code Assist Standard/Enterprise license includes Gemini CLI access; usage draws from the same per-edition quotas.
- Shared config: the same
~/.gemini/settings.json(MCP servers!) and the sameGEMINI.mdconvention — project files are honored identically. - Same agentic loop: plans, file edits, command execution with approvals — G06's gates, in text form.
For individual/free-tier and AI Pro/Ultra users, Gemini CLI stops being served on June 18, 2026 — Google directs those users to Antigravity CLI, which carries the same concepts (context files, agent loop, MCP). Standard/Enterprise licenses continue. Everything in this module transfers either way.
This module covers Gemini CLI as a Code Assist companion. There's an entire 18-module sibling course dedicated to Gemini CLI workflows — spec-driven development, extensions, GitHub Actions, Google Cloud MCP — at Building with Gemini CLI. Finish this course first, then go there for mastery.
Install & Authenticate
Install (Node.js 20+ required)
npm install -g @google/gemini-cli
gemini --version
Authenticate with the right identity
Run gemini once; it walks you through login. Choose Login with Google and use the same account as your IDE extension so your license and quotas apply. Team seats: if prompted, select your licensed Google Cloud project (or set GOOGLE_CLOUD_PROJECT).
/about shows your auth mode and model; /stats shows session usage. Type /quit to exit.Interactive Essentials
Three pieces of syntax do most of the work:
| Syntax | What it does | Example |
|---|---|---|
| @file / @dir | Pulls a file or directory into context | @storage.py explain the error handling |
| !command | Runs a shell command, output joins the conversation | !pytest tests/ -v then "fix the failure" |
| /slash | CLI meta-commands | /help, /stats, /mcp, /tools, /memory show, /quit |
Headless Mode: The Assistant as a Unix Tool
Headless mode (gemini -p "prompt") runs one prompt non-interactively and prints the answer to stdoutStandard output — the text stream a terminal program writes results to, which can be redirected to files or piped into other programs.. That makes Gemini a composable shell tool: pipe data in, redirect answers out, call it from scripts, scheduled jobs, and CI pipelines. This is the mode that turns "AI assistant" into "AI infrastructure."
# One-shot question about the current repo
gemini -p "Summarize what this project does in 3 sentences"
# Pipe data in (works in PowerShell and bash)
git diff HEAD~5 | gemini -p "Write release notes from this diff, grouped by feature/fix"
# Redirect the answer into a file
gemini -p "Audit @app.py for security issues; output a markdown checklist" > security-audit.md
Headless runs are non-interactive — there's nobody at the keyboard to approve actions, so by default treat headless as read-and-answer, not edit-my-files. Flags exist to pre-approve tool use (e.g., --approval-mode / --yolo in current builds), which is exactly G07's auto-approve trade-off: only in isolated, recoverable environments like CI containers.
Lab: Three Terminal Workflows for Recipe Box
Run all three from your recipe-box folder. Each one is a pattern you'll reuse on real projects.
The onboarding tour (interactive)
Pretend you've never seen this repo. Start gemini and ask:
@. Give me a newcomer's tour: what this project does, the role of each file,
how data flows from HTTP request to database, and the three most fragile
spots a new contributor should know about.
Generate the README (headless + file output)
gemini -p "Write a README.md for this project: description, setup (pip install flask, python app.py), API reference for every endpoint in @app.py with example curl calls and status codes, and a testing section for @tests/. Output ONLY the markdown." > README.md
Release notes from git history (pipe in, redirect out)
git log --oneline main | gemini -p "Turn this commit history into CHANGELOG.md content: version 0.1.0, grouped into Features / Fixes / Internal, human-readable bullet points" > CHANGELOG.md
git add README.md CHANGELOG.md; git commit -m "Add generated docs"; git push
You used the same assistant in a new medium: interactively for repo archaeology, headlessly as a documentation generator, and as a pipe stage in a shell one-liner. Your GEMINI.md rules and MCP servers came along for free because the CLI shares Code Assist's configuration. When you want to go further — extensions, CI recipes, spec-driven builds — the dedicated Gemini CLI course picks up exactly here.
Knowledge Check
1. What configuration do Gemini CLI and the IDE extension share?
2. In the REPL, !pytest tests/ -q does what?
3. What makes headless mode (-p) qualitatively different from interactive use?
4. Why should headless runs default to read-and-answer rather than editing files?
5. After June 18, 2026, an individual free-tier user of Gemini CLI should…
Quiz Complete!
Ready for G09: AI Code Reviews on GitHub →