Gemini CLI is an open-source AI agent created for developers who want to streamline.
With feature-rich tools and commands, Gemini CLI brings AI capabilities directly to your terminal, enabling you to query, edit, generate code, and automate tasks with ease.
This guide will walk you through how to install, configure, and use Gemini CLI. We’ll also explore the commands, tools, and practical use cases that make it a game-changer for developers.
What You’ll Learn in This Guide
- How to quickly install and set up Gemini CLI on your system
- Using Gemini CLI to generate code and build applications from scratch
- Summarizing documents and understanding the main ideas in files or directories
- Automating everyday tasks like editing files, running shell commands, or managing workflows
- Saving and resuming conversations for better context management
- Fetching and summarizing information from the web to answer questions faster
- Editing, creating, and organizing files directly from your terminal
- Utilizing advanced tools for tasks like web searches, working with MCP servers, and reading multiple files at once
- Keeping your environment secure with built-in safeguards and user confirmations
- Customizing your CLI experience with themes and settings
- Troubleshooting and getting help using built-in commands
By the end of this guide, you'll know how to use Gemini CLI to speed up your work, automate processes, and make coding easier—whether you're new to development or have years of experience.
Installing Gemini CLI
Here’s how to get started with the Gemini CLI in just a few steps.
Before you begin, make sure you have Node.js version 18 or higher installed on your system.
Step 1: Run the CLI
You can directly execute the Gemini CLI without installation by running:
Alternatively you can use;
gemini
Step 2: Pick a Color Theme

During setup, you’ll be prompted to select a color theme for your CLI interface. Choose one that fits your style!
Step 3: Authenticate
When prompted, log in using your personal Google account. This will give you access to up to 60 model requests per minute and 1,000 model requests per day.
That’s it! You’re all set to start using the Gemini CLI..

Step 4: Use your own key (Optional)
You can use your own Gemini key for faster and extensive generations without any limit, Get your API key from your vertex portal or Google AI studio;
Create .env file in the folder where you've installed Gemini CLI and paste the following;
Updating Gemini CLI
Once you've installed, if you encounter any issues then maybe it's time to update your CLI, here's command to update Gemini CLI;
Uninstall Gemini CLI
If You want to remove gemini CLI, then type the following in the terminal and press ENTER;
Gemini CLI Commands
Before I get started with building anything let's understand available Gemini CLI commands as It supports a variety of built-in commands to help you manage your session, customize the interface, and control its behavior. These commands are categorized based on their prefixes: /
(slash commands), @
(at commands), and !
(shell commands).
Slash Commands (/
)

Slash commands provide meta-level control over the CLI itself.
/bug
File an issue about Gemini CLI.
The string entered after /bug
becomes the headline for the issue, which is filed in the GitHub repository. The behavior can be customized via the bugCommand
setting in .gemini/settings.json
.
/chat
Manage conversation history.
save
: Save the current conversation history with a<tag>
for identification.
Usage:/chat save <tag>
resume
: Resume a conversation from a saved state.
Usage:/chat resume <tag>
list
: List all available tags for resuming chat states.
/clear
Clear the terminal screen.
This command clears the visible session history and scrollback. Use Ctrl+L
as a shortcut.
/compress
Summarize the chat context.
Replaces the entire chat context with a summary to save tokens while retaining key information.
/editor
Open a dialog to select supported editors.
/help
(or /?
)
Display help information.
Shows available commands and their usage.
/mcp
List and manage Model Context Protocol (MCP) servers.
desc
ordescriptions
: Show detailed descriptions of MCP servers and tools.nodesc
ornodescriptions
: Hide tool descriptions, showing only tool names.schema
: Display the full JSON schema for tool parameters.
Shortcut: PressCtrl+T
to toggle tool descriptions.
/memory
Manage the AI's instructional context.
add
: Add text to the AI's memory.
Usage:/memory add <text>
show
: Display the current hierarchical memory loaded fromGEMINI.md
files.refresh
: Reload memory fromGEMINI.md
files in configured locations.
/restore
Restore project files to a previous state.
Reverts files to their state before a tool was executed.
Usage: /restore [tool_call_id]
/stats
Display session statistics.
Includes token usage, cached token savings, and session duration.
/theme
Change the visual theme of Gemini CLI.
/auth
Change the authentication method.
/about
Show version information.
Useful for sharing details when filing issues.
/tools
List available tools in Gemini CLI.
desc
ordescriptions
: Show detailed descriptions of tools.nodesc
ornodescriptions
: Hide tool descriptions, showing only tool names.
/quit
(or /exit
)
Exit Gemini CLI.
At Commands (@
)

At commands allow you to include the content of files or directories in your prompt.
@<path_to_file_or_directory>
Inject file or directory content into your prompt.
- If a file path is provided, its content is read and included in the prompt.
- If a directory path is provided, the content of files within the directory is read.
- Git-ignored files are excluded by default but can be included via settings.
Examples: @file.txt
→ Explain this text.@src/project/
→ Summarize the code in this directory.
@
(Lone at symbol)
Pass the query as-is to Gemini.
Useful for discussing the @
symbol itself.
Shell Commands (!
)
Shell commands let you interact with your system's shell directly from Gemini CLI.
!<shell_command>
Execute shell commands.
Runs the specified command in your system's default shell.
Examples:
!ls -la
→ Lists files in the current directory.!git status
→ Shows the Git status.
!
(Toggle shell mode)
Enter or exit shell mode.
- In shell mode, all input is interpreted as shell commands.
- Exiting shell mode reverts to standard Gemini CLI behavior.
Caution: Commands executed in shell mode have the same permissions as running them directly in your terminal.
Gemini CLI Tools
The Gemini CLI includes a suite of built-in tools that extend its capabilities beyond text generation. These tools enable the Gemini model to interact with your local environment, access information, and perform various actions, making it a powerful assistant for a wide range of tasks.
Overview of Gemini CLI Tools
In the Gemini CLI, tools are specialized functions or modules that the Gemini model can request to execute. For example, if you ask Gemini to "Summarize the contents of my_document.txt," the model will identify the need to read the file and request the execution of the read_file
tool.
The core component of Gemini CLI manages these tools, defines their schemas, executes them when requested, and returns the results to the model for further processing.
Key Capabilities of Gemini CLI Tools
- Access Local Information: Tools can read file contents, list directories, and interact with your local file system.
- Execute Commands: Tools like
run_shell_command
allow Gemini to execute shell commands with safety measures and user confirmation. - Interact with the Web: Tools can fetch content from URLs or perform web searches.
- Take Actions: Tools can modify files, write new files, or perform other actions on your system, typically with safeguards.
- Ground Responses: By fetching real-time or specific local data, tools ensure Gemini's responses are accurate and relevant to your context.
How Gemini CLI Tools Work
- Prompt Submission: You provide a prompt to the Gemini CLI.
- Tool Analysis: The CLI sends your prompt, conversation history, and a list of available tools to the Gemini API.
- Tool Request: The Gemini model determines if a tool is needed and requests its execution with specific parameters.
- Execution: The core validates the tool request and executes it, often after user confirmation for sensitive operations.
- Response Generation: The tool's output is sent back to the Gemini model, which uses it to formulate a final response displayed in the CLI.
Security and Confirmation
Gemini CLI tools are designed with safety in mind, especially those that can modify your file system or execute commands. Key security measures include:
- User Confirmation: The CLI prompts you before executing sensitive operations, clearly showing the action to be taken.
- Sandboxing: Tools operate within a sandboxed environment to isolate changes and reduce risks. For example, MCP servers and executables must be available within the sandbox environment.
Categories of Gemini CLI Tools
File System Tools
Interact with files and directories.
These tools allow Gemini to read, write, list, and search files or directories.
Shell Tool (run_shell_command
)
Execute shell commands.
This tool enables Gemini to run shell commands directly, with appropriate safety measures.
Web Fetch Tool (web_fetch
)
Retrieve content from URLs.
Fetches data from web pages for use in your queries.
Web Search Tool (web_search
)
Perform web searches.
Searches the web to gather information relevant to your prompt.
Multi-File Read Tool (read_many_files
)
Read content from multiple files or directories.
Often used with the @
command to process and summarize large sets of files.
Memory Tool (save_memory
)
Save and recall information.
Allows Gemini to store and retrieve information across sessions for continuity.
Additional Features
- MCP Servers: Act as a bridge between the Gemini model and your local environment or external services like APIs.
- Sandboxing: Ensures tools operate in an isolated environment, reducing potential risks to your system.
What Can the Gemini CLI AI Agent Do?
Gemini CLI is like having a super-smart assistant right in your terminal. It can help you with coding, managing files, automating tasks, and even answering questions. Here’s a breakdown of what it can do, explained in simple terms:
1. Generate Code
Gemini can write code for you based on your instructions. Whether you need a function, a script, or even a full program, it’s got you covered.
- Example Prompt:
"Write a Python function to calculate the Fibonacci sequence."
"Generate a React component for a login form with email and password fields."
2. Summarize Documents
Got a long document or file? Gemini can read it and give you a quick summary so you don’t have to go through it all.
- Example Prompt:
"Summarize the contents of my_document.txt."
"What is this README.md file about?"
3. Automate Tasks
You can use Gemini to automate repetitive tasks, like running commands, editing files, or even managing workflows.
- Example Prompt:
"Automate the process of compressing all files in this directory."
"Create a script to back up my project folder every day."
4. Manage Conversations
Gemini can save your conversation history so you can pick up where you left off or branch into a new topic without losing context.
- Example Commands:
/chat save <tag>
→ Save the current conversation./chat resume <tag>
→ Resume a saved conversation./chat list
→ List all saved conversations.
5. Edit and Modify Files
Need to tweak a file? Gemini can edit, rewrite, or even create new files for you.
- Example Prompt:
"Edit the config.json file to change the API key to 'new_key_123'."
"Create a new file called 'index.html' with a basic HTML template."
6. Fetch Information from the Web
Gemini can search the web or fetch content from specific URLs to help you find the information you need.
- Example Prompt:
"Search the web for the latest trends in AI development."
"Fetch the content of https://example.com and summarize it."
7. Run Shell Commands
You can execute terminal commands directly through Gemini, saving you the hassle of switching between tools.
- Example Commands:
!ls -la
→ List all files in the current directory.!git status
→ Check the status of your Git repository.
8. Inject File Content into Prompts
Gemini can read files or directories and use their content to answer your questions or perform tasks.
- Example Prompt:
"Summarize the code in the src/ directory."
"Explain the text in file.txt."
9. Generate Apps or Components
Need a quick app or UI component? Gemini can generate it for you, complete with code.
- Example Prompt:
"Create a simple to-do list app in JavaScript."
"Generate a Flask app with a single route that says 'Hello, World!'."
10. Summarize Chat Context
If your conversation gets too long, Gemini can summarize it to save memory and keep things efficient.
- Example Command:
/compress
→ Summarize the entire chat context.
11. Customize Your Environment
You can change how Gemini looks and works to suit your style and needs.
- Example Commands:
/theme
→ Change the color theme of the CLI./auth
→ Switch authentication methods.
12. Debug and Troubleshoot
Gemini can help you debug issues or file bug reports directly to its GitHub repository.
- Example Commands:
/bug
→ File an issue about Gemini CLI./stats
→ View session statistics like token usage.
13. Restore Previous States
If you make a mistake, Gemini can roll back changes to a previous state.
- Example Command:
/restore [tool_call_id]
→ Restore files to their state before a specific tool was executed.
14. Save and Recall Information
Gemini can remember important details across sessions, so you don’t have to repeat yourself.
- Example Commands:
/memory add <text>
→ Add something to Gemini’s memory./memory show
→ Display everything Gemini remembers.
15. Build Efficient Workflows
Gemini integrates tools like web search, file management, and MCP servers to streamline your workflows.
- Example Prompt:
"Search for all TODO comments in my project and list them."
"Fetch the latest news articles about AI and summarize them."
16. Ensure Security
Gemini operates in a sandboxed environment, meaning it won’t mess with your system unless you allow it. It also asks for confirmation before performing sensitive actions.
- Example Prompt:
"Run a shell command to delete all .tmp files in this directory."
(Gemini will confirm before executing.)
17. Provide Help and Documentation
If you’re ever stuck, Gemini can guide you with built-in help commands.
- Example Commands:
/help
→ Show all available commands./about
→ Display version information.
18. Authenticate and Use API Keys
You can log in with your Google account or use your own API key for extended usage.
- Example Setup:
- Add your API key to a
.env
file:GEMINI_API_KEY=paste-your-key-here
- Add your API key to a
19. Support Developers of All Levels
Whether you’re a beginner or an expert, Gemini adapts to your needs. It’s simple enough for basic tasks and powerful enough for advanced workflows.
- Example Prompt:
"Explain how to use the fetch API in JavaScript."
"Generate a Dockerfile for a Node.js app."
Final Thoughts!
In conclusion, Gemini CLI is a powerful and versatile tool designed to simplify and enhance the way developers work. From generating code and summarizing documents to automating tasks and managing workflows, it brings the power of AI directly to your terminal.
With its intuitive commands, built-in tools, and customizable features, Gemini CLI caters to both beginners and experienced developers, making it an indispensable assistant for coding, debugging, and beyond.
Whether you're looking to streamline your daily tasks, explore new possibilities, or simply save time, Gemini CLI is your go-to solution. Get started today and unlock a smarter, more efficient way to work!