Neszed-Mobile-header-logo
Thursday, August 7, 2025
Newszed-Header-Logo
HomeAIBeginner’s Guide to Gemini CLI: Install, Setup, and Use It Like a...

Beginner’s Guide to Gemini CLI: Install, Setup, and Use It Like a Pro

Beginner’s Guide to Gemini CLI: Install, Setup, and Use It Like a Pro
Image by Author | Canva

 

Introduction

 
Gemini CLI is Google’s new open-source AI assistant that runs in your terminal. It brings the Gemini language model (Gemini 2.5 Pro) directly to your shell so you can ask questions, generate code, fix bugs, or create documentation without leaving the command line. “Gemini” itself is an LLM and “Gemini CLI” is basically a user tool that makes model interactive in your workflows. In short, it’s like ChatGPT for developers. Google released Gemini CLI in June 2025, and it’s FREE for individuals. You just need to login using your personal google account and it gives you access to Gemini 2.5 Pro with a huge 1 million-token context window at no cost (up to 60 requests/minute and 1,000/day). It’s a great free and open source alternative to AI coding assistants like Anthropic’s Claude Code.

Let me help you with the setup and walk you through some examples to highlight its importance.

 

Setting Up Gemini CLI on Your System

 
To install Gemini CLI, you need a command-line environment (Terminal on macOS/Linux, PowerShell or similar on Windows) and either Homebrew or Node.js. On macOS, the easiest method is via Homebrew:

  1. Install Gemini CLI via Homebrew: Execute the following command in your terminal
  2.  

  3. Alternatively, install via Node (any OS): If you prefer or don’t use Homebrew, install Node.js (version 20 or higher. Then run:
  4. npm install -g @google/gemini-cli

     

    or

    npx https://github.com/google-gemini/gemini-cli

     

    This installs the CLI globally on macOS, Linux, or Windows. Node.js v20+ is required; you can download it from nodejs.org or use nvm to manage versions.

Once installed, you can simply run the following command to launch the gemini-cli:

 

This should start the CLI (if you see the “Gemini CLI” ASCII banner, you’re set). If gemini is not found, you may need to open a new terminal or add npm’s global bin to your PATH. You will see something like this:

 

Screenshot of Gemini CLI Launch
Screenshot of Gemini CLI Launch

 

On first run, Gemini CLI will prompt you to pick a color theme (light or dark) and then log in with your Google account. Follow the instructions in the browser (or CLI) to authorize. If you prefer using an API key instead of login, you can set GEMINI_API_KEY=”YOUR_KEY” in your environment (see Google AI Studio to generate a key). Once authenticated, the CLI confirms it’s ready to use.

 

Running Your First Gemini CLI Commands

 
With Gemini CLI set up, you can start using natural language commands right away. It opens a prompt (marked >) where you type questions or tasks. For example, let’s try with a simple prompt and ask: “Write a short paragraph about why Gemini CLI is awesome.” Here’s output:

 

Screenshot of Gemini CLI: Simple Paragraph Writing
Screenshot of Gemini CLI: Simple Paragraph Writing

 

// Task 1: Fixing bugs with Gemini CLI

Gemini CLI can integrate with tools like GitHub or your local Git to find issues. For instance, let’s use the built-in @search tool to fetch a GitHub issue URL, then ask for a fix plan:

Prompt (Source):

Here’s a GitHub issue: [@search https://github.com/google-gemini/gemini-cli/issues/4715]. Analyze the code and suggest a 3-step fix plan.

 

The CLI identified the root cause and suggested how to modify the code. The screenshot below shows it reporting a 3-step plan. You can review its plan, then confirm to let Gemini CLI automatically apply the changes to your files.

 

Screenshot of Gemini CLI: Fixing bugs
Screenshot of Gemini CLI: Fixing bugs

 

// Task 2a: Working with a Project (Simple Example)

I’ve created a project folder by cloning the gitdiagram repo. If you want to know more about this repo, head over to my article: Make Sense of a 10K+ Line GitHub Repo Without Reading the Code. Let’s navigate to our project folder using:

 

Now run gemini. You can start asking questions about the code. Let’s try the following prompt:

Prompt:
Explain the main components of this codebase

 

Gemini CLI will scan the files and use the Gemini model to summarize or answer, as shown in the screenshot below:

 

Screenshot of Gemini CLI: Working with a Project (Simple Example)
Screenshot of Gemini CLI: Working with a Project (Simple Example)

 

It parsed the folders and returned a structured summary (listing directories like src/, public/, etc.). This is handy for onboarding onto new projects or generating documentation.

 

// Task 2b: Working with a Project (Advanced Example)

Exploring the codebase is easy. Now let’s give it a more technical task to see how the output turns out. We’ll provide the following prompt to Gemini:

Prompt:
Analyze this repo for common performance anti-patterns.

 

Screenshot of Gemini CLI: Working with a Project (Advanced Example)
Screenshot of Gemini CLI: Working with a Project (Advanced Example)

 

The response was so detailed that I’ve only included the starting portion in the screenshot. Gemini CLI created a detailed plan and then read every file independently. In the end, it shared a summary of potential performance anti-patterns along with recommended next steps:

Summary of potential performance anti-patterns based on initial analysis:
   1. Large Frontend Bundle Size:
       * Mermaid Library: The mermaid library is likely a significant contributor to the bundle size. If it's not
         lazy-loaded, it will impact initial page load performance.
       * `react-icons`: Depending on how it's imported, it can also contribute to bundle size if not tree-shaken
         effectively.
   2. Unoptimized Image Usage: While Next.js has next/image, without inspecting the actual image usage in components,
      it's hard to say if images are properly optimized (e.g., correct sizes, formats, lazy loading).
   3. Potential Backend Performance Issues (Python & Node.js):
       * N+1 Queries: This is a common database anti-pattern that can significantly slow down data retrieval.
       * Lack of Caching: If frequently accessed data is not cached at the application or database level, it can lead
         to redundant computations and database hits.
       * Synchronous Operations: Blocking I/O in either backend could lead to performance bottlenecks under heavy load.
   4. `reactStrictMode: false`: While not a direct anti-pattern, it can hide potential performance issues related to
      React's rendering behavior during development.
   5. Development-like Docker Volume Mount: Mounting the entire backend directory in the Docker container is less
      optimal for production builds compared to copying only necessary files.

  To confirm these, further investigation would be needed, including:

   * Bundle Analysis: Using tools like @next/bundle-analyzer to identify large modules in the frontend.
   * Performance Profiling: Running the application and using browser developer tools (for frontend) and backend
     profiling tools to identify bottlenecks.
   * Code Review: Deep diving into the src/ and backend/ code to identify specific instances of the anti-patterns
     mentioned.

 

These examples show how Gemini CLI turns simple prompts into real actions. You can query code, generate or refactor it, fix bugs, and improve performance , all from your terminal.

 

Wrapping Up

 
Gemini CLI is a powerful new tool for developers. Once you have it installed on macOS (or any OS), you can interact with Google’s Gemini LLM as easily as any local command. Some of the key features that makes it different are:

  1. ReAct Agent Loop: Internally, it runs a ReAct agent loop with your local environment. This means it can decide when to call a tool (search, run shell, edit file) versus when to answer directly. For example, it fetched a URL with @search when needed.
  2. Built-in Tools: It has built-in “tools” such as grep, echo, file read/write, and you can invoke web search or file system queries from prompts.
  3. Multimodal Capabilities: Gemini CLI can even work with images/PDFs (since Gemini is multimodal). It supports integration with external Model Context Protocol (MCP) servers e.g., you could hook up an image generator (Imagen) or a custom API. This lets you do things like “generate code from this sketch” or “summarize a PDF.”

Try it out: After following the setup above, open a terminal in a project folder, type gemini, and start experimenting. You’ll quickly see how an AI companion in your shell can dramatically boost your productivity!
 
 

Kanwal Mehreen is a machine learning engineer and a technical writer with a profound passion for data science and the intersection of AI with medicine. She co-authored the ebook “Maximizing Productivity with ChatGPT”. As a Google Generation Scholar 2022 for APAC, she champions diversity and academic excellence. She’s also recognized as a Teradata Diversity in Tech Scholar, Mitacs Globalink Research Scholar, and Harvard WeCode Scholar. Kanwal is an ardent advocate for change, having founded FEMCodes to empower women in STEM fields.

Source link

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments