Gemini CLI Setup
What is Gemini CLI?
Section titled “What is Gemini CLI?”Gemini CLI is a terminal-based AI coding assistant from Google. It works similarly to other AI coding tools: you type natural language prompts in your terminal and Gemini reads, writes, and modifies files on your machine.
Before You Start
Section titled “Before You Start”All the steps below happen inside a terminal. If you have never used a terminal before, follow the Using the Terminal guide first, then come back here.
Step 1: Install Node.js
Section titled “Step 1: Install Node.js”Gemini CLI requires Node.js 18 or later. You may already have it installed. Open your terminal and run:
node --versionIf you see a version number like v18.x.x or higher, skip ahead to Step 2. If you see “command not found” or a version below 18, follow the instructions below.
Install Node.js
Visit nodejs.org and download the LTS installer for macOS. Run the .pkg file and follow the prompts.
Alternatively, if you have Homebrew installed:
brew install nodeVisit nodejs.org and download the LTS installer for Windows. Run the .msi file and follow the prompts. Make sure “Add to PATH” is ticked during installation.
After installing, verify by running:
node --versionYou should see a version number like v20.x.x or higher.
Step 2: Install Gemini CLI
Section titled “Step 2: Install Gemini CLI”Open your terminal and run:
npm install -g @google/gemini-cliNote: Check the Gemini CLI documentation for the latest installation instructions, as the package name or method may change.
Alternatively, you can run it directly without installing:
npx https://github.com/google-gemini/gemini-cliStep 3: Authenticate
Section titled “Step 3: Authenticate”Run Gemini CLI for the first time:
geminiThis will prompt you to sign in with your Google account. Follow the on-screen instructions to complete authentication. You can use the free tier which provides access to Gemini models at no cost.
Step 4: Basic Usage
Section titled “Step 4: Basic Usage”Navigate to your project folder and start Gemini CLI:
cd ~/my-projectgeminiYou are now in an interactive session. Try your first prompt:
Here's what I found in this directory: 1. meeting-notes.docx: A Word document containing meeting notes 2. budget.xlsx: A spreadsheet with budget figures 3. photos/: A folder containing image files The directory has 2 files and 1 folder.
LLM outputs are non-deterministic and may vary from this example.
Gemini will read your files and respond directly in the terminal.
Useful Commands
Section titled “Useful Commands”| Command | Description |
|---|---|
gemini | Start an interactive session in the current directory |
gemini "your prompt" | Run a single prompt without entering interactive mode |
gemini --help | Show all available options |
Ctrl+C | Cancel the current response |
Ctrl+D | Exit the interactive session |
Next Steps
Section titled “Next Steps”Return to the Prerequisites page and continue with the guides. When you see an LLM Prompt Box, copy the prompt and paste it into your Gemini CLI session.