# AI use cases for Gemini CLI (google-gemini/gemini-cli)

Repo: [google-gemini/gemini-cli](https://github.com/google-gemini/gemini-cli) | Use cases: 3 | Page: https://dedupedai.com/use-cases/google-gemini-gemini-cli/

Gemini CLI is Google's open-source AI agent for the terminal. It reads your codebase, runs commands and answers prompts with Gemini models, and can run headless with JSON or streaming JSON output for scripts and CI. The README notes that unpaid tier and Google One users were moved to Antigravity CLI on June 18, 2026 and that Gemini CLI is not optimized for the newest Gemini models, so it now fits API key and Vertex AI users best.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Ask Gemini to explain a codebase from the terminal: https://dedupedai.com/use-cases/google-gemini-gemini-cli/ask-gemini-about-your-codebase-from-the-terminal/
- Run Gemini headless in scripts and CI with JSON output: https://dedupedai.com/use-cases/google-gemini-gemini-cli/run-gemini-headless-in-scripts-and-ci/
- Use Gemini CLI through your company's Vertex AI project: https://dedupedai.com/use-cases/google-gemini-gemini-cli/use-gemini-cli-through-vertex-ai/

## How to ask Gemini to explain a codebase from the terminal with Gemini CLI

Repo: [google-gemini/gemini-cli](https://github.com/google-gemini/gemini-cli) | Difficulty: Beginner | Time: 10 minutes | Basis: From the README

Run Gemini CLI in a repo and ask it about architecture, with extra directories included.

**Who it is for:** A developer joining an unfamiliar project who needs the big picture fast.

**The problem:** Reading a new codebase file by file takes days.

**The outcome:** A plain-language summary of the architecture and where the key pieces live.

### Steps

1. Try it without installing: `npx @google/gemini-cli`, or install with `npm install -g @google/gemini-cli` or `brew install gemini-cli`
2. Set your key: `export GEMINI_API_KEY="YOUR_API_KEY"`
3. In the repo run `gemini`, and add sibling folders with `gemini --include-directories ../lib,../docs`
4. Ask it to explain the architecture or summarize recent changes

### Prompt to paste into your agent

```text
In this repo, run google-gemini/gemini-cli with my GEMINI_API_KEY from the environment and ask it to explain the architecture, the entry points and the riskiest module. Paste its answer in a file ARCHITECTURE_NOTES.md.
```

### Caveat

Unpaid tier and Google One users were moved to Antigravity CLI on June 18, 2026; this path needs an API key or Vertex AI.

Risk, credentials: Keep the API key in your shell environment, not in the repo.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/google-gemini-gemini-cli/ask-gemini-about-your-codebase-from-the-terminal/

## How to run Gemini headless in scripts and CI with JSON output with Gemini CLI

Repo: [google-gemini/gemini-cli](https://github.com/google-gemini/gemini-cli) | Difficulty: Intermediate | Time: 20 minutes | Basis: From the README

Use non-interactive mode with JSON or streaming JSON so other tools can read the result.

**Who it is for:** A developer who wants AI steps inside shell scripts, cron jobs or a CI pipeline.

**The problem:** Interactive chat tools do not fit automated pipelines.

**The outcome:** Machine-readable answers your script or CI job can parse.

### Steps

1. Run a one-shot prompt: `gemini -p "Explain the architecture of this codebase"`
2. Get structured output: `gemini -p "Explain the architecture of this codebase" --output-format json`
3. Stream events for long tasks with `--output-format stream-json`
4. Pick a model with `gemini -m gemini-2.5-flash`

### Prompt to paste into your agent

```text
Write a shell script that runs google-gemini/gemini-cli headless with -p and --output-format json to <task> on this repo, parses the JSON with jq, and fails the CI step if <condition>.
```

### Caveat



Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/google-gemini-gemini-cli/run-gemini-headless-in-scripts-and-ci/

## How to use Gemini CLI through your company's Vertex AI project with Gemini CLI

Repo: [google-gemini/gemini-cli](https://github.com/google-gemini/gemini-cli) | Difficulty: Intermediate | Time: 15 minutes | Basis: From the README

Point the CLI at Google Cloud so usage bills to your organization's project.

**Who it is for:** An engineer at a company that already runs on Google Cloud.

**The problem:** Personal API keys are not allowed at many companies.

**The outcome:** Gemini CLI running against Vertex AI under your organization's project and controls.

### Steps

1. Install the CLI
2. Set `export GOOGLE_API_KEY="YOUR_API_KEY"` and `export GOOGLE_GENAI_USE_VERTEXAI=true`
3. Or set `export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"` for a Cloud project login
4. Run `gemini` and confirm which project the requests use

### Prompt to paste into your agent

```text
Configure google-gemini/gemini-cli to use Vertex AI in project <id> with GOOGLE_GENAI_USE_VERTEXAI=true, run one prompt, and tell me where usage will show up in the console.
```

### Caveat



Risk, credentials: Cloud keys can bill your organization; scope them and keep them in the environment.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/google-gemini-gemini-cli/use-gemini-cli-through-vertex-ai/
