Home AI SkillsGemini CLI: Google’s Open-Source AI Agent for the Terminal

Gemini CLI: Google’s Open-Source AI Agent for the Terminal

by Knowledge Base Linux
Gemini CLI open-source terminal agent working with code files

Most terminal AI agents ask for a credit card before you type your first prompt. Gemini CLI is the exception: Google’s open-source terminal agent gives you a generous free tier with nothing more than a personal Google account. Gemini CLI reads and edits files, runs shell commands, fetches web pages, and grounds answers in Google Search, all from your terminal, with a context window large enough to swallow most codebases whole. This guide installs it on Linux and shows how to get real work out of it.

What Is Gemini CLI?

Gemini CLI is an open-source AI agent, released by Google under the Apache 2.0 license, that brings the Gemini family of models directly into your command line. It is a full agent, not a chat box: it has built-in tools for file operations, shell commands, web fetching, and Google Search grounding, so it can research, write, and verify code in a loop. It also supports the Model Context Protocol (MCP), so you can plug in external tool servers the same way as with other modern agents.

Two numbers explain its popularity. First, the free tier: signing in with a personal Google account currently gives you 60 model requests per minute and 1,000 requests per day at no cost. Second, the context window: Gemini models accessible through the CLI offer up to 1 million tokens of context, which means the agent can hold an entire medium-sized repository, its documentation, and your conversation in mind at once.

If you enjoy working with language models from the shell, you may also like our walkthrough of calling an LLM API from Bash with curl and jq. Gemini CLI builds on the same idea but adds agency: it decides which files to read and which commands to run, and asks for your confirmation along the way.

Gemini CLI reading a whole codebase with its large context window

Install Gemini CLI on Linux

You need Node.js 20 or higher. The fastest route is npx, which runs the tool without installing anything:

npx @google/gemini-cli

For daily use, install it globally with npm, or with Homebrew on macOS and Linux:

npm install -g @google/gemini-cli
# or
brew install gemini-cli

Then start it inside any project directory:

cd ~/projects/my-app
gemini

On first launch you pick a theme and an authentication method. Signing in with Google is the free path described above. Alternatively, set an API key from Google AI Studio for usage-based billing, or use a Gemini Code Assist license or Vertex AI if your organization provides one:

export GEMINI_API_KEY="your-api-key"
gemini

Working with Gemini CLI: Context, Tools and GEMINI.md

Inside a session you chat naturally, reference files with @, and run shell commands with a ! prefix. The agent proposes file edits as diffs and asks before executing commands that change your system. A few built-in capabilities stand out:

  • Google Search grounding. The agent can search the web mid-task, which is genuinely useful when an API changed last month and the model’s training data is stale.
  • Web fetch. Paste a documentation URL into your prompt and the agent reads the page instead of guessing.
  • Hierarchical context files. Gemini CLI loads GEMINI.md files: a global one in ~/.gemini/, plus project and subdirectory files, so instructions get more specific as you go deeper into a tree.
  • MCP servers. Configure extra tools — databases, ticketing systems, internal APIs — in ~/.gemini/settings.json.
  • Checkpoints and memory. Conversation and tool state are kept so you can resume and steer long tasks instead of starting over.

A practical project GEMINI.md is short and concrete:

# Project context
Python 3.12 service, FastAPI + PostgreSQL.
Run tests with: pytest -q
Never edit migrations by hand; generate them with Alembic.
Style: ruff for lint and format, type hints required.

Tips to Get the Most from Gemini CLI

Use the free tier deliberately: 1,000 requests a day sounds like a lot, but an agent burns several requests per task, so it suits interactive work better than unattended batch jobs. When the agent struggles, shrink the task rather than repeating it — small prompts with a testable outcome beat one giant instruction. Take advantage of the huge context window by pointing the agent at the whole relevant folder instead of pasting snippets; it is one of the few tools where “read everything first” is a realistic strategy. And as with every agent, keep the diff review habit: the confirmation prompts are your quality gate.

One privacy note: the free Google-account tier is governed by the Gemini Code Assist privacy terms, under which prompts may be logged for product improvement with an opt-out available. If you are working on sensitive code, the API-key route or a paid license changes those terms — check the current documentation before pointing any agent at proprietary repositories.

Conclusion

Gemini CLI is the easiest terminal agent to start with: open source, one npm command to install, a 1M-token context window, and a free tier that is generous enough for real daily work. Install it, sign in with Google, drop a GEMINI.md in your project, and let it explain an unfamiliar codebase as your first task. The official Gemini CLI documentation covers configuration, commands, and MCP setup in depth.

You may also like

KbLinux

Typically replies within a day

Hello, Welcome to the site. Please click below button for chatting me through Telegram.