⌂ Home
Gemini Code Assist: AI Pair Programming in Your IDE
Code Assist Track
⏰ 40-50 min Module 9 of 12 🔧 Hands-on lab
⌨️
Gemini Code Assist Track — G08: Gemini CLI The same models, rules, and MCP servers — without an IDE. Learn the terminal agent, then script it headlessly to generate Recipe Box's README and release notes.

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

Analogy First

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).

Technical Definition

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 same GEMINI.md convention — project files are honored identically.
  • Same agentic loop: plans, file edits, command execution with approvals — G06's gates, in text form.
June 2026 note (from G00)

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.

Want to go deep?

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)

terminal
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).

Checkpoint Inside the REPL, /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:

SyntaxWhat it doesExample
@file / @dirPulls a file or directory into context@storage.py explain the error handling
!commandRuns a shell command, output joins the conversation!pytest tests/ -v then "fix the failure"
/slashCLI meta-commands/help, /stats, /mcp, /tools, /memory show, /quit
Gemini CLI — interactive session in recipe-box/
PS>gemini
✦ Loaded GEMINI.md (Recipe Box rules) — same file your IDE uses
>!pytest tests/ -q
17 passed in 0.42s
>@app.py which endpoints lack rate limiting or auth?
All of them — this API has no auth layer. For a public deploy you'd want...
>/stats
Session: 6 turns • model: gemini-2.5-pro • tokens used: 18,204
✓ Same brain, same rules — new venue
Press ▶ for an interactive session tour

Headless Mode: The Assistant as a Unix Tool

Technical Definition

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."

headless patterns
# 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
Gotcha

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:

gemini REPL
@. 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.
Expected A structured tour that correctly identifies app.py → storage.py flow, the tags feature from G06, and plausible fragile spots (e.g., no auth, JSON-in-TEXT ingredients column). This is your first-day-on-any-codebase move from now on.

Generate the README (headless + file output)

terminal
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
Expected A complete README in one command. Review it like any AI output: check every documented endpoint against app.py (the model may document the 404 path you never built). Fix discrepancies, commit it.

Release notes from git history (pipe in, redirect out)

terminal
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
Expected A grouped changelog built from your actual G02–G07 commits. Notice the shape of all three workflows: context in (@ or pipe) → instruction → output captured. That's the whole headless pattern; CI usage (running this on every merge) is just workflow 3 in a YAML file.
What Just Happened?

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?

Nothing — they're entirely separate products
~/.gemini/settings.json (including MCP servers) and the GEMINI.md context-file convention
Only the color theme
Only keyboard shortcuts

2. In the REPL, !pytest tests/ -q does what?

Asks the model to imagine running the tests
Actually runs the shell command and feeds its real output into the conversation context
Deletes the tests directory
It's a syntax error

3. What makes headless mode (-p) qualitatively different from interactive use?

It uses a different model family
It's composable: pipes, redirects, scripts, cron, CI — the assistant becomes a Unix-style tool in automated workflows
It's the only mode that can read files
It doesn't count against quotas

4. Why should headless runs default to read-and-answer rather than editing files?

There's no human at the approval gates — pre-approved actions in unattended runs carry G07's auto-approve risks
Headless mode can't technically modify files
Editing is slower in headless mode
File edits cost extra

5. After June 18, 2026, an individual free-tier user of Gemini CLI should…

Keep using it — nothing changes for individuals
Migrate to Antigravity CLI (same concepts transfer), or move to a Standard/Enterprise license which continues to include Gemini CLI
Switch to dictating code over the phone
Downgrade Node.js

Quiz Complete!

Ready for G09: AI Code Reviews on GitHub →