Skip to content
Fluf
Beta

We are actively shipping every day for Fluf.

New things land daily and the product keeps getting better. Tell us what to fix or build next: we read every message.

Gemini CLI agent guide: setup, subagents and headless runs (2026)

How to set up a Gemini CLI agent after Google's June 2026 change: who can still use it, sign-in, GEMINI.md, subagents, MCP, headless runs, persistence.

A blue Fluf beside a clock between a sky Fluf and a coral Fluf, under a rose sky.
On this page

Part of How Fluf runs Claude Code with your own login (2026 rules)

A Gemini CLI agent is Google's open-source coding agent running in your terminal, and in 2026 the first question is no longer how to install it but whether your account can use it. Since 18 June 2026, Gemini CLI no longer serves free Google accounts or Google AI Pro and Ultra subscribers; Google moved them to its new Antigravity CLI. It still serves Gemini Code Assist Standard and Enterprise licences, paid Gemini API keys and Vertex AI. This guide starts with that check, then walks through setup, GEMINI.md, subagents, MCP, headless runs and CI, and how to keep a Gemini agent working with a memory and a schedule.

What changed in June 2026

On 19 May 2026 Google announced that "Antigravity CLI is available to everyone" and that from 18 June, Gemini CLI would stop serving requests for "Google AI Pro and Ultra" subscribers and free individual users (Google Developers Blog, GitHub announcement). The repository stays "available to the community as an Apache 2.0 licensed repository," and Google will keep it updated "for our enterprise customers."

Today the README says Gemini CLI is "Designed for Gemini Code Assist Standard / Enterprise licenses and Code Assist for GitHub on Google Cloud," and that it is "Not optimized for Gemini 4+". For Gemini 4 Argon, Google points you to Antigravity.

18 Jun 2026Free and Google AI Pro/Ultra access moved to Antigravity CLI
1,500 / 2,000Daily requests per user, Code Assist Standard / Enterprise
250Daily requests on a free API key, Flash only (per Google's quota page)

Figures from Google's quota and pricing page, checked 27 November 2026. The transition notice names only paid API keys as keeping access, so treat the free-key row as unconfirmed.

1. Check which access you have

You haveGemini CLI today
Gemini Code Assist Standard or EnterpriseYes
A paid Gemini API key (AI Studio)Yes
Vertex AI on Google CloudYes
A free Gemini API keyPartly: listed at 250 requests a day, Flash only
Google AI Pro or Ultra (Google One)No: moved to Antigravity CLI
A free personal Google accountNo: moved to Antigravity CLI

If you are in the last two rows, Antigravity CLI is Google's route for you. It keeps "Agent Skills, Hooks, Subagents, and Extensions (now as Antigravity plugins)," still reads GEMINI.md and AGENTS.md, and imports your Gemini CLI setup with agy plugin import gemini. Google warns "there won't be 1:1 feature parity right out of the gate."

2. Install Gemini CLI

You need Node.js 20 or newer. Any of these works:

npx @google/gemini-cli            # try it without installing
npm install -g @google/gemini-cli
brew install gemini-cli

Stable releases ship weekly on Tuesdays; @preview and @nightly tags get changes earlier.

3. Sign in

Per the authentication docs, three options:

  • Sign in with Google. For Code Assist licences. Company, school and Workspace accounts, and some licences, need GOOGLE_CLOUD_PROJECT set.
  • Gemini API key. Create one in Google AI Studio and export GEMINI_API_KEY.
  • Vertex AI. Set GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION, then use gcloud auth application-default login, a service-account key (the docs suggest it for CI/CD) or a Google Cloud API key.

Headless runs use a cached credential if one exists; otherwise they need a key or Vertex settings in the environment.

4. Give the agent context with GEMINI.md

GEMINI.md is the agent's standing brief. Gemini CLI loads a global ~/.gemini/GEMINI.md, then files in your workspace and its parents. If your repo already has an AGENTS.md for Codex, point Gemini at it too:

{
  "context": {
    "fileName": ["AGENTS.md", "GEMINI.md"]
  }
}

Import other files with @docs/architecture.md. Check what loaded with /memory show, and reload after edits with /memory reload.

5. Add subagents

Subagents "are enabled by default." Define one as Markdown with YAML frontmatter in .gemini/agents/ (this project) or ~/.gemini/agents/ (everywhere). name and description are required.

---
name: test-fixer
description: Finds and fixes failing unit tests. Use when a test run reports failures.
---

Run the failing tests, read the error, fix the code (not the test) unless the test is wrong.
Report each fix in one line.

Call it directly with @test-fixer. Built-ins include codebase_investigator, cli_help and generalist. One quirk: /model "does not override the model used by sub-agents."

6. Connect tools over MCP

Add servers under mcpServers in settings.json, or from the terminal with gemini mcp add. Gemini CLI speaks stdio, SSE and streamable HTTP, with OAuth 2.0 for remote servers. /mcp lists what is connected. Extensions bundle prompts, MCP servers, commands, hooks, subagents and skills into one install: gemini extensions install <github-url>.

7. Run it headless

Pass -p and Gemini CLI runs once and exits (headless docs):

gemini -p "Summarise the TODOs added this week, grouped by owner" \
  --output-format json --approval-mode auto_edit
  • --output-format json returns response, stats and error; stream-json emits JSONL events (init, message, tool_use, tool_result, error, result).
  • --approval-mode takes default, auto_edit, yolo or plan. The old --yolo flag is deprecated.
  • -s turns on a sandbox: Seatbelt on macOS, Docker or Podman, gVisor on Linux for the strongest isolation.
  • Exit codes: 0 success, 1 error, 42 bad input, 53 turn limit exceeded.

Turn on checkpointing (general.checkpointing.enabled: true) and /restore can roll back both files and the conversation.

8. Automate it in GitHub

The run-gemini-cli Action runs Gemini CLI in workflows, with example setups for issue triage, PR review and an @gemini-cli assistant, on events or a schedule. Authenticate with a Gemini API key, Vertex AI or Workload Identity Federation.

9. Keep a Gemini agent working with memory and a schedule

A Gemini CLI session, like any CLI session, ends when you close it. GEMINI.md is instructions you write; there is no per-agent memory that learns from your corrections and lets you review each fact, and no inbox that reaches your phone when the agent needs a decision.

Fluf adds that layer. It is a desktop app for Mac, Windows and Linux where you hire AI agents with a name, a memory, routines and approvals. Two ways to run Gemini there:

  • Gemini CLI, for existing Gemini Code Assist Standard or Enterprise plans. Fluf runs the Gemini CLI you installed, signed in through Google's own flow; Google's terms and your licence's quotas apply.
  • A Google AI Studio API key. For everyone else, including former Google AI Pro and Ultra users. Paste it in App settings › AI accounts; it goes into your operating system's secure store, and Google bills usage to you (API keys).
Fluf's model picker listing models from several connected AI accounts
Pick Gemini per agent, next to Claude Code, Codex or a local model. Switching keeps the agent's memory.
  1. 1Connect GeminiYour Gemini CLI or an AI Studio key
  2. 2Hire an agentA name, a job and its own memory
  3. 3Add a routineRuns on schedule, asks before risky steps
Every morning at 08:00, check new GitHub issues, label them and try to reproduce the bugs.
Iris
Routine set for 08:00. I'll label with our existing set and reproduce in a scratch branch.
Friday 08:00
Iris
6 new issues. 4 labelled as questions with answers drafted. Reproduced #412 with a failing test. Could not reproduce #415; asked the reporter for their browser version.
Iris wants to post 4 repliesDraft answers on #409, #410, #411, #413ApproveDecline

What the agent gets on top: memory scoped to it, its team or the business; routines and heartbeats on your machine or an always-on server; approvals in its chat, on your phone or in Telegram; and the freedom to switch it to Claude Code, Codex or a local model without losing its memory. See Use your subscriptions and Models, effort and speed.

Gemini CLI, Claude Code or Codex?

If your company already pays for Code Assist, Gemini CLI is a strong, open agent with first-class sandboxing and headless output. If you are on a personal Google plan, the honest options are Antigravity CLI, a paid Gemini key, or another agent. For the other two, read Claude Code agents, Codex agents and our head-to-head Claude Code vs Codex. The rules for running agents on plans you pay for are in our pillar on running AI employees on your Claude subscription.

Download Fluf and give your Gemini agent a memory, a morning routine and a way to reach you.

Questions people ask

Does Gemini CLI still work with Google AI Pro or Ultra?
No. Since 18 June 2026, Gemini CLI stopped serving requests for Google AI Pro and Ultra subscribers and for free individual accounts; Google moved those users to Antigravity CLI. Gemini Code Assist Standard and Enterprise licences, paid Gemini API keys and Vertex AI still work.
Is Gemini CLI free?
The software is free and open source under Apache 2.0. Free personal access through a Google account ended on 18 June 2026. Google's quota page still lists a free API key tier at 250 requests a day on Flash models, but the transition notice names only paid API keys, so check your key before relying on it.
Does Gemini CLI have subagents?
Yes, and they are on by default. Define one as a Markdown file with YAML frontmatter in .gemini/agents/ or ~/.gemini/agents/; name and description are required. Built-ins include codebase_investigator and generalist, and you call one directly with @name.
Can third-party tools use my Gemini CLI Google sign-in?
Google's terms say accessing the services behind Gemini CLI through third-party software, giving 'using OpenClaw with Gemini CLI OAuth' as an example, is a violation that may get your account suspended. Use your own Gemini API key, Vertex AI or a Code Assist licence instead.
How do I run Gemini CLI non-interactively?
Pass -p with your prompt, or pipe input in a non-TTY environment. Add --output-format json for a response, stats and error object, or stream-json for JSONL events. Exit code 53 means the turn limit was exceeded.

Sources

  1. An important update: transitioning Gemini CLI to Antigravity CLI (Google Developers Blog), checked 27 November 2026
  2. Gemini CLI announcement discussion #27274, checked 27 November 2026
  3. google-gemini/gemini-cli README, checked 27 November 2026
  4. Gemini CLI: Authentication, checked 27 November 2026
  5. Gemini CLI: Quota and pricing, checked 27 November 2026
  6. Gemini CLI: Headless mode, checked 27 November 2026
  7. Gemini CLI: Subagents, checked 27 November 2026
  8. Gemini CLI: Terms of service and privacy, checked 27 November 2026
  9. run-gemini-cli GitHub Action, checked 27 November 2026

TopicsGeminiGoogleDevelopersSubscriptions

    Search every docs page: setup, agents, models, memory, routines, chat apps and reference.