Getting Started with Gemini Command Line Interface (CLI)
Understanding the Target Audience
The primary audience for the Gemini Command Line Interface (CLI) includes developers, software engineers, and technical project managers. They are typically experienced in coding and familiar with command-line tools. Their pain points often revolve around the inefficiencies of managing large codebases, automating repetitive tasks, and integrating various tools into their workflows. Their goals include enhancing productivity, streamlining development processes, and leveraging AI capabilities to simplify complex tasks. Interests may include staying updated with the latest technology trends, AI advancements, and best practices in software development. Communication preferences lean towards concise, technical documentation that provides clear instructions and practical examples.
Overview of Gemini CLI
Google recently released the Gemini CLI, a powerful command-line tool designed to supercharge developer workflows with AI. Whether you’re working across massive codebases, automating tedious tasks, or generating new apps from sketches and PDFs, Gemini CLI brings multimodal intelligence right to your terminal.
Key Features of Gemini CLI
- Query and edit large codebases—even beyond the standard 1M token context window.
- Generate apps from visual inputs like PDFs or design sketches.
- Automate operational workflows—from handling pull requests to managing rebases.
- Connect external tools and MCP servers, including Imagen, Veo, and Lyria for media generation.
- Use Google Search as a grounding tool, directly within your terminal.
Installation Guide
Installing Node.js
To get started, you’ll need to have Node.js installed on your system:
- Go to nodejs.org and download the latest LTS version.
- Run the installer.
- Use the default settings and complete the installation.
Installing & Using the CLI
To install the Gemini CLI, run the following command:
npm install -g @google/gemini-cli
Once installed, initialize it by running:
gemini
On the first run, you’ll be prompted to:
- Choose a color theme for the CLI interface.
- Authenticate with your personal Google account – This allows access to Gemini with generous usage limits: 60 requests per minute and 1,000 requests per day.
You’re now ready to start using Gemini CLI to enhance your development workflow!
Using Your Own API Key
If you need access to a specific Gemini model or want higher usage limits, you can use your own API key. Generate a key from Google AI Studio and set it as an environment variable in your terminal:
export GEMINI_API_KEY="YOUR_API_KEY"
Replace YOUR_API_KEY
with the actual key you generated. This allows Gemini CLI to authenticate using your key instead of your personal Google account.
Querying a GitHub Repository
Once everything is configured, test it with a GitHub repo:
git clone https://github.com/Marktechpost/AI-Notebooks.git
cd AI-Notebooks
Once in the AI-Notebooks folder, run the CLI:
gemini
Summarizing Tutorials
To get started, let’s try a simple prompt:
Give an overview of the different tutorials in this repository
Gemini CLI will read the README.md file—assuming it contains details about the tutorials—and generate a concise summary based on that information.
Explaining Files in a Sub-Folder
To refer to a specific directory or file in your prompt, use the @ symbol followed by the folder or file name. Gemini CLI also supports auto-complete, so when you type @, it will suggest available files and folders automatically.
Let’s test this with the following prompt:
@A2A_Simple_Agent briefly explain the different files in this folder and how they work together to implement the A2A agent. Focus only on the .py files and the README.md file
Executing Git Commands
Gemini CLI can also execute shell commands directly from your prompts:
How many git commits have been made so far
When running a command like this, Gemini will:
- Ask for your permission before executing it.
- Run the shell command safely.
- Automatically fetch and display the result.
Updating the Memory
Manage the AI’s instructional context using the /memory command:
/memory add This Git repository contains multiple self-contained tutorial projects demonstrating how to use the Gemini CLI and build agent-based systems. Each folder (e.g., A2A_Simple_Agent) focuses on a specific concept like agent communication, tool use, or integration patterns. When asked, summarize or build on individual tutorials while keeping their scope isolated.
Checking Session Stats
The /stats command in Gemini CLI provides a detailed summary of your current session. It shows key metrics such as total token usage, any savings from cached tokens (when available), and the overall session duration. This is useful for tracking your usage efficiency and understanding how the model is being utilized during your workflow.
/stats
Quitting the Session
You can end your Gemini CLI session at any time by using the /quit command. Once you exit, the CLI will display a session summary—including total tokens used, session duration, and a breakdown of input and output tokens.
/quit
Further Reading
To explore the full range of commands, check out the Gemini CLI Commands Guide. There are many powerful commands that make Gemini CLI a versatile tool for developers. In this tutorial, we’ve only scratched the surface to give you a basic overview of its core features. For more details and updates, visit the official Gemini CLI GitHub repository.