Gemini CLI Tutorial: How to Use Google's AI Coding Agent for Real Projects (2026)

By Ivern AI Team9 min read

Gemini CLI Tutorial: Use Google's AI Coding Agent for Real Projects

Google's Gemini CLI puts Gemini 2.5 Pro directly in your terminal. You describe what you want, it writes code, runs commands, and edits files — all from the command line. No browser, no GUI, no context switching.

If you've used Claude Code or OpenCode, the concept is similar: a terminal-based AI agent that reads your codebase and executes tasks. But Gemini CLI has a unique advantage — free access to Gemini 2.5 Pro with a generous context window.

This tutorial covers everything you need to start using Gemini CLI for real projects, including how to connect it to a multi-agent task board.

Related: OpenCode Tutorial · Claude Code Tutorial · Claude Code vs Cursor · AI Coding Assistant Complete Guide

What Is Gemini CLI?

Gemini CLI is Google's official command-line AI agent. Key features:

  • Free Gemini 2.5 Pro access — no API key needed for basic usage
  • 1M token context window — handles large codebases
  • Terminal-native — edits files, runs commands, searches code
  • Multi-modal — can analyze images and screenshots
  • Open source — available on GitHub

The main limitation: it's a single agent in a single terminal. You can't coordinate it with other agents or assign tasks from a dashboard — unless you connect it to Ivern Squads.

Setup (3 Minutes)

Step 1: Install Gemini CLI

# Install via npm
npm install -g @anthropic-ai/gemini-cli

# Or download directly
curl -fsSL https://cli.gemini.google/install.sh | bash

Verify:

gemini --version

Step 2: Authenticate

gemini auth login

This opens a browser window to sign in with your Google account. No API key needed — Google provides free Gemini 2.5 Pro access through the CLI.

If you want to use your own API key for higher rate limits:

export GEMINI_API_KEY=your_key_here
gemini auth login --api-key

Step 3: Test It

Navigate to any project directory:

cd your-project
gemini "What does this codebase do? Give me a brief summary."

Gemini reads your project files and responds with a summary. That's it — you're running an AI coding agent.

Real-World Usage Examples

Example 1: Add a Feature

gemini "Add a /health endpoint to the Express server in src/server.ts. It should return { status: 'ok', uptime: <seconds>, version: <from package.json> }"

Gemini reads your server file, understands the structure, and adds the endpoint. It shows you the changes before applying them.

Example 2: Write Tests

gemini "Write integration tests for the /api/users endpoints. Cover: GET /users (list), POST /users (create), GET /users/:id (get one), PUT /users/:id (update), DELETE /users/:id (delete). Use the testing framework already in this project."

It detects your test framework (Jest, Vitest, Pytest, etc.) and writes matching tests.

Example 3: Debug an Error

gemini "The test suite is failing with 'TypeError: Cannot read property map of undefined' in the UserProfile component. Find the cause and fix it."

Gemini traces the error through your codebase, identifies the root cause, and suggests a fix.

Example 4: Code Review

gemini "Review all uncommitted changes in this git repo. Check for: security issues, performance problems, missing error handling, and test coverage gaps."

Example 5: Documentation

gemini "Generate JSDoc comments for all exported functions in src/utils/. Include @param and @returns tags with types."

Usage Limits and Pricing

TierRate LimitContextCost
Free (Google auth)60 requests/min, 1000/day1M tokens$0
API Key (Pay-as-you-go)Higher limits1M tokens~$0.10-0.50/task

The free tier is generous enough for most individual developers. You only need an API key if you're running high-volume automated tasks.

Connecting Gemini CLI to a Multi-Agent Task Board

Gemini CLI works great on its own. But if you're also using Claude Code, Cursor, or OpenCode, you need a way to coordinate them. That's where Ivern Squads comes in.

Why Coordinate Multiple Agents?

Use CaseSingle AgentMulti-Agent Squad
Simple editFineOverkill
Full feature (frontend + backend + tests)Sequential, slowParallel, fast
Code review + implementationManual handoffAutomatic routing
Daily standup of tasksManualTask board with auto-assignment

How to Connect

  1. Sign up at ivern.ai/signup (free)

  2. Create a squad with multiple coding agents:

# Connect Gemini CLI
npx @ivern-ai/agent install --key YOUR_IVERN_KEY --provider gemini

# Connect Claude Code (in another terminal)
npx @ivern-ai/agent install --key YOUR_IVERN_KEY --provider claude
  1. Assign tasks from the Ivern dashboard. Tasks get routed to the right agent based on role:
  • Gemini CLI Agent → research and documentation tasks (free, large context)
  • Claude Code Agent → complex implementation tasks (strong reasoning)
  • Cursor Agent → inline editing tasks (editor-native)

Each agent picks up tasks, executes them, and submits results to the shared task board. You watch everything stream in real time.

For detailed setup, see the Claude Code tutorial or OpenCode tutorial.

Gemini CLI vs Claude Code vs Cursor: Quick Comparison

FeatureGemini CLIClaude CodeCursor
InterfaceTerminalTerminalVS Code editor
ModelGemini 2.5 ProClaude Sonnet/OpusClaude/GPT-4
Context Window1M tokens200K tokens128K tokens
Free TierYes (generous)API costs only2000 completions/mo
Best ForLarge codebases, free usageComplex reasoningInline editing
Multi-file EditsYesYesYes

The full breakdown is in our Claude Code vs Cursor comparison.

Tips for Getting the Most from Gemini CLI

1. Be Specific About File Paths

Instead of: "Fix the auth bug" Use: "Fix the JWT validation error in src/middleware/auth.ts line 47 where expired tokens are not being rejected"

2. Use the Context Window

Gemini's 1M token context means you can point it at your entire project:

gemini "Analyze the full codebase and identify: 1) Security vulnerabilities 2) Performance bottlenecks 3) Missing test coverage. Prioritize by severity."

3. Chain Commands

gemini "Find all TODO comments in the codebase. For each one, estimate the effort (S/M/L) and create a prioritized list."

4. Use for Non-Coding Tasks

gemini "Read all markdown files in the docs/ directory and generate a table of contents with summaries for each document."

Frequently Asked Questions

Is Gemini CLI free?

Yes. Google provides free access to Gemini 2.5 Pro through the CLI with generous rate limits (60 requests/min, 1000/day). No credit card needed. For higher limits, use your own API key.

How does Gemini CLI compare to GitHub Copilot?

Copilot suggests code inline in your editor. Gemini CLI is an agentic tool — it reads your entire project, plans changes across multiple files, and executes them. Copilot completes your next line. Gemini CLI builds your next feature.

Can I use Gemini CLI without internet?

No. Gemini CLI requires an internet connection to communicate with Google's Gemini API. The AI processing happens on Google's servers.

Does Gemini CLI work with all programming languages?

Yes. Gemini 2.5 Pro supports all major programming languages including Python, JavaScript, TypeScript, Go, Rust, Java, C++, Ruby, and more.

How do I connect Gemini CLI with other AI agents?

Use Ivern Squads to connect Gemini CLI with Claude Code, Cursor, and OpenCode in a shared workspace. Each agent gets a role and task queue. See the setup instructions above or the OpenCode tutorial for a similar walkthrough.

Is my code sent to Google?

Yes. When you use Gemini CLI, your code and prompts are sent to Google's servers for processing. If this is a concern for proprietary code, consider using a self-hosted model instead. Ivern Squads supports BYOK with any provider.

Get Started

  1. Install: npm install -g @anthropic-ai/gemini-cli
  2. Authenticate: gemini auth login
  3. Try it: cd your-project && gemini "Explain this codebase"

For multi-agent coordination:

  1. Sign up at ivern.ai/signup
  2. Connect: npx @ivern-ai/agent install --key YOUR_KEY --provider gemini
  3. Assign tasks from the dashboard

Your first 15 tasks on Ivern are free. Gemini CLI usage is free with Google authentication.

Create Your Free Squad →

Set Up Your AI Team - Free

Join thousands building AI agent squads. Free tier with 3 squads.