M
MeshWorld.
AI Cheatsheet Gemini CLI Google Cloud Developer Tools 4 min read

Gemini CLI & Code Assist Cheatsheet (2026 Edition)

Vishnu
By Vishnu

The Gemini CLI (and its Code Assist counterpart) is Google’s answer to terminal-native AI. While other tools focus purely on text, Gemini’s massive 1M+ token context window and native multi-modal capabilities make it uniquely suited for heavy enterprise lifting and visual debugging.

Here is the no-nonsense cheatsheet for driving Gemini from your terminal in 2026.

Core Setup & Auth

If you are using Google Cloud, the CLI is tightly integrated with gcloud.

# Install via npm (standalone)
npm install -g @google/gemini-cli

# Authenticate via OAuth (Default)
gemini login

# Authenticate via Service Account (for CI/CD pipelines)
export GEMINI_API_KEY="your_api_key_here"

# Start the interactive REPL
gemini

Essential CLI Flags

You don’t always need the REPL. For quick tasks, use the single-shot execution flags.

FlagDescriptionExample
-p, --promptThe text instruction.gemini -p "Explain this error"
-f, --fileAttach a file to the context.gemini -f src/main.go -p "Refactor"
-m, --modelSpecify the model.gemini -m gemini-3.1-pro -p "Analyze"
--imageAttach an image (Multi-modal).gemini --image bug.png -p "Fix UI"
--systemOverride the default system prompt.gemini --system "You are a DBA."

Multi-Modal Magic (Vision in the Terminal)

Gemini’s biggest advantage is its native vision model. You don’t have to describe what a broken UI looks like; just show it to the CLI.

# Debug a UI layout issue from a screenshot
gemini --image screenshot.jpg -p "Why is this flexbox overlapping? Give me the tailwind fix."

# Diagram to Code
gemini --image architecture-diagram.png -p "Generate the Terraform scripts for this architecture."

The Scenario: You’re working on a legacy frontend. A user reports that the “Submit” button is hidden behind a modal on mobile Safari. Instead of guessing CSS properties for an hour, you take a screenshot from the simulator, run gemini --image modal-bug.png -p "Fix the z-index and flex properties causing this overlap", and get the exact CSS class changes instantly.

Exploiting the 1M Token Context

Unlike other CLIs that struggle with large files, Gemini 3.1 Pro eats massive repositories for breakfast. You can feed it entire directories.

# Analyze a whole directory
gemini -f src/ -p "Find all unhandled promise rejections and output a Markdown checklist of files to fix."

# Feed it massive log files
gemini -f production-error.log -p "Find the exact timestamp where the database connection pool exhausted, and tell me which query caused it."

The Interactive REPL Commands

Inside the > gemini prompt, use these slash commands to steer the session.

CommandAction
/clearResets the 1M token context window to zero.
/attach [path]Loads a file or directory into the current session.
/detach [path]Removes a specific file from the context window.
/save [filename]Saves the current chat output to a markdown file.

The GEMINI.md Project File

Just like Anthropic’s CLAUDE.md, Gemini looks for a GEMINI.md file in your project root to establish persistent context.

Example GEMINI.md:

# Project Context
This is a Go backend using Google Cloud Spanner and Pub/Sub.

## Rules
- All errors MUST be wrapped using `fmt.Errorf`.
- Never use panic() in production code.
- Always write table-driven tests for utility functions.

<reference path="./docs/database-schema.md">

The Scenario: Your team relies heavily on Google Cloud Spanner. The syntax is notoriously tricky. By linking your ./docs/database-schema.md directly inside GEMINI.md, the CLI automatically knows all your table names, foreign keys, and specific Spanner-SQL quirks before you even ask it to write a query. You stop fighting hallucinated Postgres syntax.


Found this useful? Check out our guide on Cursor vs. Antigravity to see how Google’s IDE agent compares to the competition.