1. Introduction
In this codelab, you will learn about Gemini CLI, an open-source AI agent that brings the power of Gemini directly into your terminal.
The Gemini CLI project is open source and you can view the public roadmap over here.
What you'll learn
- Installing and configuring Gemini CLI
- Exploring tools, built-in commands and configuring MCP Servers in Gemini CLI
- Customizing Gemini CLI via the
GEMINI.md
file - Exploring a few use cases with Gemini CLI
What you'll need
This codelab can be run entirely within Google Cloud Shell, which comes pre-installed with Gemini CLI.
Alternatively, if you prefer to work on your own machine, there is a section to install Gemini CLI locally.
You would need the following:
- Chrome web browser
- A Gmail account
This codelab, designed for users and developers of all levels (including beginners). The use cases in the codelab have been categorized into developer and non-developer tasks. The developer use cases demonstrate how to vibe code with Gemini CLI and working with a Github repository to perform common development tasks like code explanation/understanding, generating documentation, fixing issues and more. It is recommended that you complete these use cases in the codelab. There is an optional section at the end that covers several every day tasks that are non-developer focused.
2. Before you begin
Create a project
- In the Google Cloud Console, on the project selector page, select or create a Google Cloud project.
- Make sure that billing is enabled for your Cloud project. Learn how to check if billing is enabled on a project.
- You'll use Cloud Shell, a command-line environment running in Google Cloud that comes preloaded with bq. Click Activate Cloud Shell at the top of the Google Cloud console.
- Once connected to Cloud Shell, you check that you're already authenticated and that the project is set to your project ID using the following command:
gcloud auth list
- Run the following command in Cloud Shell to confirm that the gcloud command knows about your project.
gcloud config list project
- If your project is not set, use the following command to set it:
gcloud config set project <YOUR_PROJECT_ID>
3. Installation
Before you do the setup and run Gemini CLI, let us create a folder that you will be using as our home folder for all the projects that you may create inside of it. This is a starting point for the Gemini CLI to work with, though it will also reference some other folders on your system and which you will come to later, as needed.
Go ahead and create a sample folder (gemini-cli-projects
) and navigate to that via the commands shown below. If you prefer to use some other folder name, please do so.
mkdir gemini-cli-projects
Let's navigate to that folder:
cd gemini-cli-projects
You can directly launch Gemini CLI via the gemini command.
Please navigate directly to the next section (Gemini CLI configuration via settings.json).
If you want to install Gemini CLI locally, follow the instructions given below.
The first step is to install Node 20+ on your machine. Once this is complete, you can install and run Gemini CLI via any one of the following methods:
- You can install Gemini CLI globally on your system first. You may need Administrator access to perform this step.
# option 1: install Gemini CLI
npm install -g @google/gemini-cli
# .. and then run
gemini
- Run it with the following command:
# option 2: run without installing Gemini CLI
npx https://github.com/google-gemini/gemini-cli
You can confirm the CLI is installed by running:
gemini --version
Assuming that you have launched Gemini CLI via any of the methods above, you should see the following screen that asks you about choosing a theme. Go ahead and select one that you like:
Once you select that, it will ask for the Authentication method. It is recommended that you use your personal Google Account and not non-Google or Google Workspace related accounts in this lab. That free license gets you access to Gemini 2.5 Pro and its 1 million token context window. The free tier allows for 60 model requests per minute and 1,000 requests per day at no charge.
If you hit limits with the current free quota given to Google Accounts, you can opt to use the Gemini API Key or even Google Cloud Vertex AI, where you will need to have a Project Id and the location name for that project. Do refer to the Authentication section of the documentation, if you plan to use other methods of authentication.
Go ahead and click on Enter. This will open up a Google Authentication page in the browser. Go ahead with the authentication with your Google Account, accept the terms and once you are successfully authenticated, you will notice that the Gemini CLI is ready and waiting for your command. A sample screenshot is given below:
4. Gemini CLI configuration via settings.json
If you choose Cloud Shell to run Gemini, a default theme for Gemini CLI and the authentication method is already selected and configured for you.
If you installed Gemini CLI on your machine and launched it for the first time, you selected a theme and then an authentication method.
Now, on subsequent runs of Gemini CLI, you will not be asked to select a theme and authentication method again. This means that it is getting persisted somewhere and the file that it uses is called settings.json
and it is the way to customize Gemini CLI.
Settings are applied with the following precedence (Cloud Shell only makes User settings available):
- System:
/etc/gemini-cli/settings.json
(applies to all users, overrides user and workspace settings). - Workspace:
.gemini/settings.json
(overrides user settings). - User:
~/.gemini/settings.json
.
Windows User: %USERPROFILE%.gemini\settings.json (which typically expands to C:\Users<YourUsername>.gemini\settings.json)
System: %ProgramData%\gemini-cli\settings.json (which typically expands to C:\ProgramData\gemini-cli\settings.json)
Mac User: ~/.gemini/settings.json (which expands to /Users/<YourUsername>/.gemini/settings.json)
System: /etc/gemini-cli/settings.json
If you recollect, at the time of selecting the theme, you selected for the settings to be saved in the User Settings. So visit the ~/.gemini folder
and you will notice the settings.json
file.
My settings.json
file is shown below. If you had selected another theme, you would see the name there.
{
"theme": "Default",
"selectedAuthType": "oauth-personal" or "cloud-shell"
}
5. Our first interaction with Gemini CLI
Let's get started with Gemini CLI and type your first query as shown below:
Give me a famous quote on Artificial Intelligence and who said that?
The expected response is shown below:
You will notice that our query resulted in a GoogleSearch
tool (an in-built tool in Gemini CLI) that got invoked. In other words, you have already exercised one of Gemini CLIs powerful in-built tools namely GoogleSearch
that grounds its responses based on information that it gets from the web. You will learn more about Tools in the next section.
A quick way to understand Gemini CLI and the various commands that it supports is to type /help
(forward slash) and you will see a variety of commands and keyboard shortcuts as shown below:
Let's quit Gemini CLI for now. You can do that either via the /quit
command or you can do Ctrl-C
twice in the interactive Gemini CLI terminal session.
6. Gemini CLI - Command Parameters
There are a few command line parameters that one can provide when you start Gemini CLI. To get a full list of options, you can use the --help
as shown below.
gemini --help
This should show the full range of options available. You are encouraged to go through the documentation here.
Let us take a look at a few of them. The first one is to configure Gemini CLI to use either the Pro or the Flash model. Currently, at the time of writing this lab, these are the only two models supported. By default the Gemini 2.5 Pro model is used, but if you would like to use the Flash Model, you can do that at the time of starting Gemini CLI via the -m
parameter as shown below:
gemini -m "gemini-2.5-flash"
You will notice that if you start in the above manner, you can check the model at the bottom right of the Gemini CLI terminal as shown below:
Non-interactive mode
An interesting option is to run Gemini CLI in a non-interactive mode. This means that you directly provide it the prompt and it will go ahead and respond to it, without the Gemini CLI interactive terminal opening up. This is very useful if you plan to use Gemini CLI in an automated fashion as part of the script or any other automation process. You use the -p parameter to provide the prompt to Gemini CLI as shown below:
gemini -p "What is the gcloud command to deploy to Cloud Run"
Do keep in mind that there is no scope to continue the conversation with follow up questions. This mode also does not allow you to authorise tools (including WriteFile) or to run shell commands.
7. Gemini CLI - In-built Tools
Gemini CLI comes with a set of built-in tools and the tools documentation states "Gemini model uses these tools to interact with your local environment, access information, and perform actions. These tools enhance the CLI's capabilities, enabling it to go beyond text generation and assist with a wide range of tasks."
To get a list of current Built-in Tools, invoke the /tools
command as shown below:
One of the things that should strike you immediately is to ask yourself if Gemini CLI can simply call these tools, when it wants to? The default answer is no, when it comes to sensitive operations that might involve writing to the local system, reading from an external system, going to the external network and so on.
While there is a --yolomode
available when you start the CLI (not typically recommended), you will find that Gemini CLI will prompt you for permission to run the tool that it has chosen. You can refuse permission, or let it run once or give it blanket permission to always run. You are and should be in full control of things.
Let's use a prompt that will make Gemini CLI choose one of the inbuilt tools to execute and that will give you a good understanding of how it all works.
Imagine a scenario where you would like to get information on latest financial news across the world and save that into a file in the local working directory from where you launched Gemini CLI. Use the following prompt:
Search for the latest headlines today in the world of finance and save them in a file named finance-news-today.txt
Imagine for a moment what it should do. Ideally it needs to go out to do a GoogleSearch to get news from some relevant sources of information that can provide it financial news. It then needs to create a file named finance-news-today.txt
(a write operation on your local system that will require your permission) with its content.
Let's see what happens (you should proceed doing the same on your machine).
The first thing it does is that it invokes the GoogleSearch
tool to search the web.
Once the search is complete, it retrieves the data as shown below:
Once that is done, it is ready to write this to the file and it will use the WriteFile
tool, but since that is a sensitive operation (write), it will ask for your permission. You can decide the permission type i.e. allow once , allow always, etc. Go ahead and select allow once for now.
This will then write the information to the file and a success message is shown below:
How do you check if the file is written or not? You can use the @file
to ask it to read the content. As you type @
, it displays a list of files in the current folder and it has shown the file that it has just created. Select that and submit the prompt. My prompt is shown below:
read the contents of @finance-news-today.txt
This results in the required tools (ReadManyFiles, ReadFile) being invoked and the contents are displayed as shown below:
8. Gemini CLI - Shell mode
This is a good time to learn how to directly work with the Shell from within Gemini CLI. You can go into shell mode by pressing !
in the message box. This will toggle to a Shell mode. You can get back by pressing !
again or by hitting the ESC
key.
When in shell mode, you will see the !
at the start of the prompt as shown below:
You can directly check using standard commands like pwd
and ls
as shown below. Please note that the commands assume a Linux type OS. If you are on another operating system (Windows), please use equivalent commands like (cd
, dir
and type
). Do note that the output of these calls is included in the model's context window.
You can print the contents of the file via the cat
command today.
Exercise: Here is a short exercise to try out. Choose an RSS feed of your choice. Give a prompt to Gemini CLI to fetch the contents of the RSS feed and format the results for you in a specific way. This is a good way to automate something at the start of the day. You might even ask Gemini CLI to figure out if there is RSS Feed for a specific area for e.g. Google Cloud Platform Release Notes.
A sample prompt is shown below:
Get the latest release notes for Google Cloud from its RSS Feed and display the key points in a well-formatted list.
This prompt should ideally first invoke the GoogleSearch tool to find the Google Cloud Platform RSS feed and then it will use the WebFetch tool to get the contents of the RSS Feed and display them.
9. Configuring Model Context Protocol (MCP) Servers
An MCP server is an application that exposes tools and resources to the Gemini CLI through the Model Context Protocol, allowing it to interact with external systems and data sources. MCP servers act as a bridge between the Gemini model and your local environment or other services like APIs.
An MCP server enables the Gemini CLI to discover and execute tools thereby extending Gemini CLI's capabilities to perform actions beyond its built-in features, such as interacting with databases, APIs, custom scripts, or specialized workflows.
Gemini CLI supports configuring MCP Servers for discovering and using custom tools. If you have Gemini CLI launched, you can check up on the MCP servers configured via the /mcp
command as shown below:
If you have not configured any MCP servers, it will launch Gemini CLI's MCP Server documentation.
You can configure MCP servers at the global level in the ~/.gemini/settings.json
file or in your project's root directory. Create or open the .gemini/settings.json
file. Within the file, you will need to add the mcpServers
configuration block, as shown below:
"mcpServers": {
"server_name_1": {},
"server_name_2": {},
"server_name_n": {}
}
Each server configuration supports the following properties ( Reference documentation):
Required (one of the following)
- command (string): Path to the executable for Stdio transport
- url (string): SSE endpoint URL (e.g., "http://localhost:8080/sse")
- httpUrl (string): HTTP streaming endpoint URL
Optional
- args (string[]): Command-line arguments for Stdio transport
- headers (object): Custom HTTP headers when using url or httpUrl
- env (object): Environment variables for the server process. Values can reference environment variables using $VAR_NAME or ${VAR_NAME} syntax
- cwd (string): Working directory for Stdio transport
- timeout (number): Request timeout in milliseconds (default: 600,000ms = 10 minutes)
- trust (boolean): When true, bypasses all tool call confirmations for this server (default: false)
- includeTools (string[]): List of tool names to include from this MCP server. When specified, only the tools listed here will be available from this server (whitelist behavior). If not specified, all tools from the server are enabled by default.
- excludeTools (string[]): List of tool names to exclude from this MCP server. Tools listed here will not be available to the model, even if they are exposed by the server. Note: excludeTools takes precedence over includeTools - if a tool is in both lists, it will be excluded.
Let us go ahead and configure one of the key MCP servers that you might need if you are working with Github. You would probably have a question: if you already have Git and other related tools set up on your system, would you still need the Github MCP Server?
Gemini CLI will invoke the git tools that you have on your system and you may also instruct the Gemini CLI to use that. So do keep in mind that Gemini CLI will help in translating your natural language queries to equivalent tools that you may have on your system and it may require that you explicitly state that in your prompt.
You may not need the next section to setup a Github MCP Server if you have the following already setup on your system:
- Git tools (this means that you can execute commands like
git init
,git add
, etc on your system) gh
: This is GitHub on the command line. It brings pull requests, issues, and other GitHub concepts to the terminal next to where you are already working with git and your code. Install it from here and validate its setup via a few commands, especially around authentication to Github from your machine.
If you'd still like to try out the Github MCP Server, please see the next section or you can skip that.
Github MCP Server
The Github official MCP Server provides sufficient documentation on the tools that it exposes along with how to configure the same. You can pick your choice in terms of running it locally or remotely, since Gemini CLI supports remote MCP Servers too.
This tutorial demonstrates the Remote MCP Server option in Github. For this, you will need to have a Personal Access Token (PAT) from Github first.
Once you have that, you will need to add the MCP Server object in the settings.json
file. The complete settings.json file on my system is shown below. You might have additional settings, but the mcpServers
object should be as given below:
{
"theme": "Default",
"selectedAuthType": "oauth-personal",
"mcpServers": {
"github": {
"httpUrl": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": "GITHUB_PAT"
},
"timeout": 5000
}
}
}
You can either start Gemini CLI again or do a /mcp refresh
command, once you have updated the settings.json
with the Github MCP Server configuration. The screenshot below highlights the Github MCP Server that is configured on my machine and the various tools that are now available to the Gemini CLI to work with MCP.
Let's start with a prompt that will invoke one of the tools from the Github MCP Server. Give the following prompt:
Notice that it will pick the correct tool from the Github MCP Server but as with other in-built Tools, this will also require that you provide explicit permission to invoke the tool. Go ahead and see what output you get.
You should now work with one of your Github projects. Give your queries in natural language like:
- Describe the <repo-name> to me?
- Clone the <repo-name> on my local machine.
- Describe @<file-name> or @<directory-name>/
- What are the different components of this repository?
- I have made necessary changes. Can you push the changes to Github and use the Github MCP Server tools to do that.
You will find an exercise for working with the Github MCP Server in detail later in the lab.
Context7 MCP Server
Context7 provides up-to-date documentation for LLMs and AI code editors. If you are looking to provide the context to the LLM with the latest documentation for the framework of your choice, the Context7 MCP server is a good one to configure.
Make sure that you do have your library listed at the Context7 home page.
Here is the MCP Server that you need to add in the settings.json
file.
"context7": {
"httpUrl": "https://mcp.context7.com/mcp"
}
Once the MCP Server is configured and Gemini CLI loaded successfully with it, you should be able to view the Context7 tools as shown below:
You can now be specific in your prompt and ask Gemini CLI to use Context7
for the latest documentation, while generating your application or code snippet, using a specific XYZ framework.
Here is an example prompt, where I want to write an Agent using the Agent Development Kit (ADK) from Google. I am specifying in my prompt to look up the documentation for the same via the Context7 MCP Server.
I am working on coding an Agent using the Agent Development Kit (ADK) from Google. I would like to know how to create the LLMAgent in Python. Use Context7 for the latest documentation on ADK and specifically use /google/adk-python, /google/adk-docs and adk.wiki
Here is the output received:
Google Slides MCP Server
The Github project at https://github.com/matteoantoci/google-slides-mcp provides a MCP server for interacting with the Google Slides API. It allows you to create, read, and modify Google Slides presentations programmatically.
The steps to configure the MCP server are given in the project. You will need to have a Node.js environment where you build out the server, configure a Google Cloud Project and OAuth 2.0 tokens and then configure the MCP Server in the settings.json file.
Once setup, you can run prompts like:
- Extract the latest information from "web_url", summarize it into key points and create a presentation named "my_presentation".
Give it a try!
More MCP Servers
Here is an additional list of MCP servers that you might be interested in:
- Firebase MCP Server
- Google Gen AI Media Services (Imagen, Veo, Lyria)
- MCP Toolbox for Databases (work with Firestore, BigQuery, Google Cloud databases)
- Google Workspace MCP Server (work with Docs, Sheets, Calendar, Gmail)
The instructions for setting up the above MCP servers are published in this blog post.
10. Customizing Gemini CLI with GEMINI.md
If you noticed your usage of Gemini CLI so far, you would have noticed that either we were just giving the prompt and expecting Gemini CLI to execute it, sometimes with results that are not as per our expectations. In some prompts, you were a bit specific in terms of what to do and have included those instructions in the prompt.
This may work fine as per what you are instructing Gemini CLI to do and the results that you get. But in many cases, you want to ensure that it follows rules. These rules could be specific programming languages or frameworks to use. It could also be specific tools. It could be coding styles. It's not just about generation but you might also want Gemini CLI to strictly be in what is called a "planning" mode and would like it to just present a plan and not generate any code or modify files on the system.
Enter GEMINI.md
. This is the context file (defaulting to GEMINI.md
but configurable via the contextFileName
property in settings.json
file) that is crucial for configuring the instructional context (also referred to as "memory") provided to the Gemini model. This file allows you to give project-specific instructions, coding style guides, or any relevant background information to the AI, making its responses more tailored and accurate to your needs.
The GEMINI.md
file is in markdown format and loads in a Hierarchical fashion, which is combined from multiple locations.
The loading order is:
- Global Context: **
~/.gemini/GEMINI.md
** (for instructions that apply to all your projects). - Project/Ancestor Context: The CLI searches from your current directory up to the project root for
GEMINI.md
files. - Sub-directory Context: The CLI also scans subdirectories for
GEMINI.md
files, allowing for component-specific instructions.
You can use the /memory show
to see the final combined context being sent to the model.
What does a GEMINI.md
look like? We produced one from the official documentation:
# Project: My Awesome TypeScript Library
## General Instructions:
- When generating new TypeScript code, please follow the existing coding style.
- Ensure all new functions and classes have JSDoc comments.
- Prefer functional programming paradigms where appropriate.
- All code should be compatible with TypeScript 5.0 and Node.js 20+.
## Coding Style:
- Use 2 spaces for indentation.
- Interface names should be prefixed with `I` (e.g., `IUserService`).
- Private class members should be prefixed with an underscore (`_`).
- Always use strict equality (`===` and `!==`).
## Specific Component: `src/api/client.ts`
- This file handles all outbound API requests.
- When adding new API call functions, ensure they include robust error handling and logging.
- Use the existing `fetchWithRetry` utility for all GET requests.
## Regarding Dependencies:
- Avoid introducing new external dependencies unless absolutely necessary.
- If a new dependency is required, please state the reason.
You will notice that it provides some general instructions plus very specific instructions for coding style, dependency management and more. While this is a sample GEMINI.md
file for TypeScript projects, you can write your own based on your programming language, framework, coding style and other preferences.
You can give a custom GEMINI.md
file a try. This is from a gist published that shows how to use Gemini CLI in Plan mode only. The file is reproduced here:
# Gemini CLI Plan Mode
You are Gemini CLI, an expert AI assistant operating in a special 'Plan Mode'. Your sole purpose is to research, analyze, and create detailed implementation plans. You must operate in a strict read-only capacity.
Gemini CLI's primary goal is to act like a senior engineer: understand the request, investigate the codebase and relevant resources, formulate a robust strategy, and then present a clear, step-by-step plan for approval. You are forbidden from making any modifications. You are also forbidden from implementing the plan.
## Core Principles of Plan Mode
* **Strictly Read-Only:** You can inspect files, navigate code repositories, evaluate project structure, search the web, and examine documentation.
* **Absolutely No Modifications:** You are prohibited from performing any action that alters the state of the system. This includes:
* Editing, creating, or deleting files.
* Running shell commands that make changes (e.g., `git commit`, `npm install`, `mkdir`).
* Altering system configurations or installing packages.
## Steps
1. **Acknowledge and Analyze:** Confirm you are in Plan Mode. Begin by thoroughly analyzing the user's request and the existing codebase to build context.
2. **Reasoning First:** Before presenting the plan, you must first output your analysis and reasoning. Explain what you've learned from your investigation (e.g., "I've inspected the following files...", "The current architecture uses...", "Based on the documentation for [library], the best approach is..."). This reasoning section must come **before** the final plan.
3. **Create the Plan:** Formulate a detailed, step-by-step implementation plan. Each step should be a clear, actionable instruction.
4. **Present for Approval:** The final step of every plan must be to present it to the user for review and approval. Do not proceed with the plan until you have received approval.
## Output Format
Your output must be a well-formatted markdown response containing two distinct sections in the following order:
1. **Analysis:** A paragraph or bulleted list detailing your findings and the reasoning behind your proposed strategy.
2. **Plan:** A numbered list of the precise steps to be taken for implementation. The final step must always be presenting the plan for approval.
NOTE: If in plan mode, do not implement the plan. You are only allowed to plan. Confirmation comes from a user message.
Save the contents above into a file named GEMINI.md and save that in ~/.gemini/GEMINI.md
. This is the same folder in which you had created the settings.json file. You can also keep the GEMINI.md
file in your <current project folder>/.gemini
folder or even have multiple GEMINI.md
files in your sub-directories if you have different instructions.
Give a prompt to generate an application and see how it responds.
Here is another GEMINI.md
file ( Gemini Explain mode) that you can study and then repurpose it for your requirements and use it. This focuses on GEMINI CLI being an interactive guide, helping users understand complex codebases through a conversational process of discovery.
GEMINI.md
file are the key to making Gemini CLI follow your preferences and it is suggested to check out this practical series " Practical Gemini CLI" that dives into this area, how you can auto-generate one for your project, customizing even the System Prompt and more.
Do note that you can also build out the GEMINI.md
file as you interact with Gemini CLI. At any point, you can use the /memory add <some instruction/rule> command and Gemini CLI will append that to the GEMINI.md
file. You can even use natural language to ask Gemini CLI to add to its memory i.e. GEMINI.md
via prompts like "Remember <some instruction/rule>" or "Add to memory <some instruction/rule>".
11. Gemini CLI - Custom slash commands
You've just seen how to customize GEMINI.md
to create a plan mode. The previous section also provided you links to an Explain mode.
What if you wanted to configure both these modes and instruct Gemini CLI to go into any of these modes via /plan
or /explain
slash commands. This is exactly what Gemini CLI Custom slash commands are about.
As the documentation states, "Custom commands allow you to save and reuse your favorite or most frequently used prompts as personal shortcuts within Gemini CLI. You can create commands that are specific to a single project or commands that are available globally across all your projects, streamlining your workflow and ensuring consistency."
Let us create a couple of Custom slash commands: /plan
and /explain
.
The next step is to understand where Gemini CLI picks up the Custom commands from. As per the documentation, it discovers commands from two locations, loaded in a specific order:
- User Commands (Global): Located in
~/.gemini/commands/
. These commands are available in any project you are working on. - Project Commands (Local): Located in
<your-project-root>/.gemini/commands/
. These commands are specific to the current project and can be checked into version control to be shared with your team.
Let's pick the current project folder from where you have launched Gemini CLI. So this will be <your-project-root>/.gemini/commands/
folder. Go ahead and create the folder structure.
What do we need to create inside this folder? We need two TOML files (plan.toml
and explain.toml
). You can read more on the namespaces and naming conventions if you'd like here.
Each TOML file needs to have two fields : description
and prompt
. Ensure that the description is short and crisp since it will be shown next to the command in the Gemini CLI. TOML file sample below is taken from the official Custom slash commands blog post.
A sample plan.toml file is shown below. Notice that the prompt contains a special placeholder {{args}}
, the CLI will replace that exact placeholder with all the text the user typed after the command name.
description="Investigates and creates a strategic plan to accomplish a task."
prompt = """
Your primary role is that of a strategist, not an implementer.
Your task is to stop, think deeply, and devise a comprehensive strategic plan to accomplish the following goal: {{args}}
You MUST NOT write, modify, or execute any code. Your sole function is to investigate the current state and formulate a plan.
Use your available "read" and "search" tools to research and analyze the codebase. Gather all necessary context before presenting your strategy.
Present your strategic plan in markdown. It should be the direct result of your investigation and thinking process. Structure your response with the following sections:
1. **Understanding the Goal:** Re-state the objective to confirm your understanding.
2. **Investigation & Analysis:** Describe the investigative steps you would take. What files would you need to read? What would you search for? What critical questions need to be answered before any work begins?
3. **Proposed Strategic Approach:** Outline the high-level strategy. Break the approach down into logical phases and describe the work that should happen in each.
4. **Verification Strategy:** Explain how the success of this plan would be measured. What should be tested to ensure the goal is met without introducing regressions?
5. **Anticipated Challenges & Considerations:** Based on your analysis, what potential risks, dependencies, or trade-offs do you foresee?
Your final output should be ONLY this strategic plan.
"""
Try to create an explain.toml file too. You can refer to Gemini Explain mode to pick some content from.
Restart Gemini CLI. Now you will find that it has a slash command (/plan
) as shown below:
12. Use cases to try out
Gemini CLI can be applied to a wide range of use cases that apply to both developers and non-developers alike. Presented here are a few scenarios and depending on your area of interest, you can try any or all of them out.
In each of these cases, the prompt is provided. You are free to try this out in the Gemini CLI interactive mode or non-interactive mode via the -p
parameter at the time of launching the Gemini CLI.
Vibe coding with Gemini CLI
Let's use Gemini CLI to vibe code an application. In this task, you will ask Gemini CLI to generate an application and then push the initial version to a Github repository.
Prerequisite
To perform the tasks in this section, there are a few prerequisites:
- Git
- Gemini CLI with Github MCP Server (we did that earlier) or if you have set up
gh
( Github CLI tool) that would work too. - Familiarity with Git basics and a bit of programming knowledge
We will assume that you have launched Gemini CLI in a specific folder of your choice. Make sure that the MCP Servers have started successfully, especially the Github MCP Server.
Start with an initial prompt. Feel free to modify it as you see fit. Keep in mind that throughout the session with Gemini CLI, it will ask you for permissions to create the files, etc. Do give the required permissions.
In this task, we are not looking for Gemini CLI to run the application or test it out for us since we would like a little more control. But it is completely up to you, how you would like to do that.
Generate a website for a 1-day event filled with technical talks. There are going to be 6 talks in a single track of 1 hour each. Each talk has the following information: title, 1 or maximum of 2 speakers, category (1 or maximum of 3 keywords), duration and a description. The website has a single page where users can see the schedule for the entire day with the timings. There will be one lunch break of an hour and the event starts at 10:00 AM. Keep a 10 minute transition between talks. I would like to use Node.js on the server side and standard HTML, JavaScript and CSS on the front-end. The users should be able to search the talks based on category.
I would like you to proceed in the following way:
1. Plan out how you would design and code this application.
2. Ask me for any clarifications along the way.
3. Once I am fine with it, do generate the code and provide me instructions to run and test locally.
The next few prompts and responses are a sample flow that was observed. You might get a completely different response, so go through the plan and interact back-and-forth with Gemini CLI as needed.
We have observed that at times, Gemini CLI tries to do more and might even give you the commands that it would like to execute. For this exercise, it is advisable not to, so that you have more control on how it goes about the task and what you would like to validate yourself first.
For example, if it offers to run the commands, you can simply escape out and give a message as shown below:
On following the instructions to start the server and navigate to the home page, we got a sample site as shown below (you should see a variant of a similar site if you used the same prompt):
You are free to keep making more changes with the help of Gemini CLI. Once you are satisfied with the changes, you can push this to a Github repository.
First up, let's create a .gitignore file and you can take the help of Gemini CLI.
Create a .gitignore file for this project.
The next step for you is to give instructions to Gemini CLI to push this repository under our Github account and this should exercise the Github MCP Server tools in the background.
Give a prompt similar to the one below:
Great! I would now like to push all of this to a new repository in my Github account. I would like to name this repository <Your-Name>-event-talks-app
It will go through a number of commands here:
- Create the repository.
- It will use multiple Git commands : init, add, commit to manage the local Git repository.
- It will then setup the Git remote and do a push
Note: There are instances where Gemini CLI might timeout or use an incorrect username, etc. Do interact with it and suggest the fixes.
If all goes well, you should have a Github repository in place. A sample screenshot is shown below:
Note that you have not generated a README.md
for this project and that is a good exercise for the next section, where we shall now work with this repository that you just created.
Using Gemini CLI to work on a Github Repository
In this use case, you shall use Gemini CLI to work with a Github repository. You will perform multiple tasks that include:
- Understanding the code base
- Generating documentation
- Implementing a new feature
- Commit and push the changes back to the repository
- Work on a Github Issue and implement the proposed changes
This should give you a good foundation to then work with your repositories and use Gemini CLI as an assistant vis-a-vis these developer specific tasks.
Prerequisite
To perform the tasks in this section, you will need to the following:
- Git
- Gemini CLI with Github MCP Server (we did that earlier) or if you have set up
gh
( Github CLI tool) that would work too. - Familiarity with Git basics and a bit of programming knowledge (we will use Node.js in this example since you might already have the environment ready on your machine due to the fact that you have installed Gemini CLI). But feel free later on to pick a repository of your choice with a different programming language and framework.
- You should have completed the previous section and have the repository handy, where we created an Event Talks website.
Let's continue to use Gemini CLI from the folder/directory that you used to generate the Event Talks application or if needed, you can clone the repository to your local machine and then start Gemini CLI from that directory. Try out the following scenarios as listed below:
Understanding the code base
- I would like to understand this project in detail. Help me understand the main features and then break it down into Server and Client side. Take a sample flow and show me how the request and response works.
- Explain @server.js
Generating a README file
- Generate a
README
file for this project.
Gemini CLI in this case not only generated the README
file but it also wanted to execute the commands to add to the Git repository and push the changes to the remote, which if you find it doing, you may allow it to do so.
In some cases, it may even offer to generate the LICENSE
file for you. You can decide if you would like to do so. Depending on the outcome, you will find the README
and/or LICENSE
files generated and the changes have been pushed to Github.
Implementing a new feature
- I would like to implement a new feature where the user is allowed to search by a specific Speaker too. First show me a plan of how you would implement this change and then we can generate the code.
It should provide you with a plan, which you can approve. On approval, Gemini CLI will go ahead and make those changes. Do test out your changes and if there are bugs (likely), do ask Gemini CLI to fix it.
Once the changes look good, you can follow the same steps to commit and push them to the remote repository.
Generate Issues based on suggested features
Let's try something interesting here. You are going to ask Gemini CLI about how it can improve the user experience of this application and based on its assessment, it can create those suggestions as issues in the same Github repository. It will use the "create_issue" tool from the Github MCP Server.
Try the following prompt:
- I would like you to assess the application from a user experience point of view. Ease of use, responsiveness, helpful messages and more. Please come up with a list of improvements and I would like you to then create them as Issues in the Github repository.
Ideally it will share the improvements first with you and then proceed with your permission to create the issues in the Github repository. Here is a sample screenshot from our run:
Work on a Github Issue and implement the proposed changes
You can now take one of the issues that was generated earlier and ask Gemini CLI to work and implement it.
A sample issue that it generated is shown below:
Take the entire Issue URL and provide a prompt like this:
- Please go through the Issue:
<YOUR_ISSUE_URL>
and understand what changes need to be made. First discuss the plan and then show the proposed changes in code.
Feel free to approve the changes and push them to the repository. You can even ask it to close the issue.
(Optional) Everyday Tasks
The use cases given below are tasks that you might end up doing regularly. These include arranging files into folders, fetching and summarizing content from the web, processing image files and extracting content from them, working with databases and more.
Feel free to explore any of the use cases that you like.
Organizing Files/Folders
You can use Gemini CLI to organize the files depending on types in various folders as needed. Go to a folder on your machine that has several files .txt, .png, .jpg, .pdf, .mp4 and others. This is likely to be your Desktop or your Downloads folder.
Here is a sample folder and the contents of the folder are shown below (you may have other files):
Navigate to that folder and start Gemini CLI. You are going to ask Gemini CLI to create some folders first: Images, Documents, Videos and then you will ask Gemini CLI to organize the files in the folders.
The Gemini CLI will often prompt you for permission before executing commands, especially those that modify your file system (like writing, moving, or deleting files). Always review these prompts carefully before granting permission. This is your safety net.
Create the following folders "Images","Documents","Videos"
Then give the following prompt:
Go through all the files in this folder and then organize them by moving all the files ending with .jpg, .jpeg, .gif into the "Images" folder. Move all ".txt" files into the "Documents" folder. Move all the ".mp4" files in the "Videos" folder.
An example of what the final state of the folder should be, is shown below. You should see new sub-folders created and the files moved into the respective sub-folders depending on their type.
A few other organizing scenarios (the prompts are given next to each scenario):
- Summarization: For each document in the ‘Documents' folder, create a txt file in the same folder named ‘summary_ORIGINAL_FILENAME.txt' that contains a 3-sentence summary of the document's main points.
- Categorizing by Type: Scan all PDF and DOCX files in this directory. Move all files with "invoice" in their name or content into the ‘Financial/Invoices' folder. Move files with "receipt" into ‘Financial/Receipts'. Any other .docx files go into ‘Reports'.
- Extracting Key Information (and "tagging"): For each PDF file in the ‘Financial/Invoices' folder, read its content. If you find a date, rename the file to include that date in YYYY-MM-DD format, e.g., ‘invoice_2025-07-26_original_name.pdf'.
Organizing Images
Let's see how you can organize image content in your machine.
To try this out:
- You will need to have a directory/folder with various image files (.jpg, .png, etc.). Include some with EXIF data (most photos from cameras/phones have this).
- Navigate into this directory.
- Launch Gemini CLI.
Try out any of the following scenarios (the prompts are given next to each scenario):
- Rename by Date (EXIF Data): Rename all .jpg and .png files in this directory to include their creation date from EXIF data in ‘YYYYMMDD_HHMMSS_original_name.jpg' format. If no EXIF date is found, use the file's last modified date.
- Create Image Descriptions: For each image in this folder, describe what is in the image and save that description in a text file named ‘description_ORIGINAL_FILENAME.txt' in the same directory.
- Identify Duplicates (Conceptual, requires more advanced logic): Find any duplicate images in this folder based on their visual content, and list their filenames. Do not delete them yet.
Summarizing Articles (Local Files or Web)
For each of the scenarios below, feel free to change the url, topic of interest and the local file names as applicable. The filenames provided are sample file names, you can replace them with filenames of files that you have on your system.
Try out any of the following scenarios (the prompts are given next to each scenario):
- Summarize a web article (single URL): Go to https://medium.com/google-cloud/getting-started-with-gemini-cli-8cc4674a1371 and summarize the top 3 key takeaways from this news article.
- Summarize multiple web articles (e.g., from a search): Find the latest news articles about "Gemini CLI" using Google Search. For the top 5 relevant articles, summarize each in 2-3 sentences and list their URLs.
- Summarize a local text file: Summarize the main points of the article in ‘my_research_paper.txt'. Focus on the methodology and conclusions.
- Summarize a local PDF: Read ‘financial_report_Q2_2025.pdf'. Provide a summary of the financial performance and key challenges mentioned.
Extracting Specific Information (Local Files or Web)
For each of the scenarios below, feel free to change the url, topic of interest and the local file names as applicable. The filenames provided are sample file names, you can replace them with filenames of files that you have on your system.
Try out any of the following scenarios (the prompts are given next to each scenario):
- Extract entities from a local article: From ‘biography.txt', list all named individuals and the significant dates associated with them.
- Extract data from a table in a PDF: In ‘quarterly_sales.pdf', extract the data from the table on page 3 that shows "Product Sales by Region" and present it in a Markdown table format.
- Extract news headlines and sources from a news website: Go to ‘https://news.google.com/' (or a similar news site). Extract the main headlines from the front page and their corresponding news sources. Present them as a bulleted list.
- Find product specifications from an e-commerce page: Browse to ‘https://www.amazon.in/Google-Cloud-Certified-Associate-Engineer/dp/1119871441' (example for a book). Extract the book title, author and other details. Present this in a structured JSON format.
- Extract duration from a video, in a certain format (eg "2h37m42s").
Answering Questions based on Content (RAG-like behavior)
For each of the scenarios below, feel free to change the url, topic of interest and the local file names as applicable. The filenames provided are sample file names, you can replace them with filenames of files that you have on your system.
Try out any of the following scenarios (the prompts are given next to each scenario):
- Q&A on a local document: I'm attaching ‘user_manual.pdf'. What are the steps to troubleshoot network connectivity issues?
- Q&A on a web page: Using the content from ‘https://www.who.int/news-room/fact-sheets/detail/climate-change-and-health', what are the primary health risks associated with climate change according to WHO?
- Compare information across multiple sources: I have two news articles: ‘article1.txt' and ‘article2.txt', both discussing the recent economic policy changes. Compare and contrast their views on the potential impact on small businesses.
Content Generation based on Extracted Information
For each of the scenarios below, feel free to change the url, topic of interest and the local file names as applicable.
Try out any of the following scenarios (the prompts are given next to each scenario):
- Generate a news brief from an article: Read @tech_innovation_article.txt. Write a short, engaging news brief (around 150 words) suitable for a company newsletter, highlighting the new technology and its potential.
- Draft an email summarizing a meeting transcript: Here is a meeting transcript file: @meeting_transcript.txt. Draft an email to the team summarizing the key decisions made and action items assigned, including who is responsible for each.
Gemini CLI multi-modal support
Gemini CLI has multi-model support via Gemini and you can ask it to process files of different content formats as per your requirements.
You are going to process a bunch of invoice images with Gemini CLI and extract key information from them. Follow the steps given below:
- Create a folder on your machine and download some invoices from the following Github repository.
- Launch Gemini CLI from that folder
Give the following prompt to extract out information from the invoices in the form of a table.
The current folder contains a list of invoice files in Image format. Go through all the files in this folder and extract the following invoice information in the form of a table: Invoice No, Invoice Date, Invoice Sent By, Due Date, Due Amount.
You should ideally get an output that looks like this:
Here is another scenario, where you can ask for additional derived columns. Let's say that you want to show a red cross emoji for all the invoice due dates that are in the past. You can give a prompt as follows:
list all files with .png extension in this folder. Extract the invoice information from it by reading them locally and display it in a table format containing the following column headers: : Invoice No, Invoice Date, Invoice Sent By, Due Date, Due Amount. Add a column at the end of the table that shows a red cross emoji in case the due date is in the past.
This produces the following output:
Apply this to any of your own files that are in formats other than text.
Using Gemini CLI to work with databases
You can use Gemini CLI to more efficiently work with various databases. You can use it for multiple scenarios: querying with natural language, exporting data, designing database schemas, generating realistic test data and more.
You shall be using SQLite3
to do this task. You will need to install SQLite3 and have the sample Chinook database.
Here are brief instructions for setting up SQLite3:
- macOS: SQLite3 comes pre-installed. Verify with
sqlite3 --version
. If needed, install with Homebrew:brew install sqlite3
. - Windows: Download the precompiled binaries from the SQLite website. Extract the files to a directory (e.g.,
C:\sqlite
). Add that directory to your system's PATH environment variable. - Linux: Debian/Ubuntu:
sudo apt update && sudo apt install sqlite3
Download the sample Chinook database (here is a direct link to download it).
To run these prompts, it is suggested that you create a folder (database-tasks
) in the gemini-cli-projects
directory. Copy the Chinook database file to that folder. Ensure that the sqlite3 tool is set up on your system and available in the path, so that Gemini CLI can use that. Launch Gemini CLI.
The database schema diagram is shown below:
Let's assume that you are in a folder named database-tasks
and the Chinook database file is named chinook.db
.
Several prompts are given below that can help you work with databases. Let's cover the first one in brief to demonstrate the permission that will be requested.
Start off with the prompt to list down the tables that are present in the database, give the following prompt:
What tables are present in the file: chinook.db
This uses the tool to read the file and then wants to use sqlite3
utility present on your system to do the needful:
Provide the permission to run it once to get the expected output:
Try out the following prompts or any other prompt of your choice:
- How many employees are there?
- What is the schema of the invoices table?
- Which are the top 3 invoices by total and which customers have placed those invoices?
You will notice that Gemini CLI takes care of two things: Generating the correct SQL statement to meet your requirement and giving the correct sqlite3
command.
Using Gemini CLI to generate data
You can prompt Gemini CLI to produce data in various data formats. This could range from content pieces to JSON data, that you might need to mock. Let's focus here on scenarios applicable to developers/testers.
Here are some prompts to try out:
Generate JSON data of sample customer reviews
Generate a JSON array of 3 synthetic customer reviews for a new smartphone. Each review should have 'reviewId' (string, UUID-like), 'productId' (string, e.g., 'SMARTPHONE_X'), 'rating' (integer, 1-5), 'reviewText' (string, 20-50 words), and 'reviewDate' (string, YYYY-MM-DD format).
Generating Mock API Responses (JSON)
Generate a JSON array representing 7 daily sales records for a mock API endpoint. Each record should include 'date' (YYYY-MM-DD, chronologically increasing), 'revenue' (float, between 5000.00 and 20000.00), 'unitsSold' (integer, between 100 and 500), and 'region' (string, either 'North', 'South', 'East', 'West').
Generating Sample Database Insert Statements (SQL)
Generate 5 SQL INSERT statements for a table named 'users' with columns: 'id' (INTEGER, primary key), 'username' (VARCHAR(50), unique), 'email' (VARCHAR(100)), 'password_hash' (VARCHAR(255)), 'created_at' (DATETIME, current timestamp). Ensure the password_hash is a placeholder string like 'hashed_password_X'.
Generating CSV Data for Data Loading/Analysis
Generate 10 lines of CSV data, including a header row, for customer transactions. Columns should be: 'TransactionID' (unique string), 'CustomerID' (integer), 'ItemPurchased' (string, e.g., 'Laptop', 'Monitor', 'Keyboard'), 'Quantity' (integer, 1-3), 'UnitPrice' (float, between 100.00 and 1500.00), 'TransactionDate' (YYYY-MM-DD).
Generate a Configuration file (YAML)
Generate a sample YAML configuration for a 'user_service'. Include sections for 'database' with 'host', 'port', 'username', 'password', 'database_name'. Also include a 'api_keys' section with 'payment_gateway' and 'email_service' placeholders. Use realistic default values.
Generating Test Data for Edge Cases/Validation
Generate a JSON array of 8 email addresses for testing purposes. Include a mix of: 2 valid standard emails, 2 with missing '@', 2 with invalid domains (e.g., '.com1'), and 2 with special characters in the local part that are usually invalid (e.g., spaces or multiple dots).
13. Congratulations
Congratulations, you've successfully explored Gemini CLI, its capabilities and applied it to a few use cases.