DEV Community

James Miller
James Miller

Posted on

Gemini CLI Core Commands: Work Calmly, Ship Confidently

Who hasn’t tried Gemini CLI yet? If you live in the terminal, this free and open-source tool brings a powerful AI teammate right where you work — with generous limits and serious capability.

  • Free tier: 60 requests/minute, 1,000 requests/day for personal Google accounts
  • Backed by Gemini 2.5 Pro: Up to a 1M-token context window for large codebases and complex docs
  • Built-in tools: Google Search (basic), file operations, shell commands, and web fetching
  • Extensible: Supports MCP (Model Context Protocol) for custom tool integrations
  • Terminal-first: Designed for developers who prefer the command line
  • Open source: Licensed under Apache 2.0

Install Prerequisites (Node.js 20+)

Gemini CLI requires Node.js 20 or newer. The simplest way to prepare your machine is to use an integrated dev environment that lets you install and manage Node.js visually with project isolation. For example, you can install Node 20 and switch versions quickly here:

node.js 20

Then verify Node in your terminal:
node -v
npm -v


Install Gemini CLI

Install globally via npm:
npm install -g @google/gemini-cli

Or run without installing:
npx @google/gemini-cli

Launch the interactive CLI:
gemini

Set an API key when you need a specific model or higher quotas:
export GEMINI_API_KEY="YOUR_API_KEY"


First-Time Setup: Connect to Your Project

Initialize and configure Gemini CLI in your repo:

  • /init

    Analyze the project structure and create initial context so Gemini understands your workspace.

  • /auth

    Authenticate with your Google account to grant access to AI services.

  • /about

    Show current CLI version, underlying model, and auth method.

  • /help and /docs

    /help lists available commands; /docs opens official documentation in your browser.


Everyday Core Commands

These are the workhorse commands you’ll use throughout the day.

  • ! (shell prefix)

    Run shell commands directly in the CLI. Combine with natural language to generate or explain commands.

  • /tools

    List available tools so you know what Gemini can do in your current session.

  • /editor

    Configure an external editor (VS Code, Vim). Press Ctrl+X to pop open your editor, write longer prompts or paste larger code blocks, save, and send back to the CLI.


Session Management: Save Your Thinking

Preserve context for complex tasks and pick up where you left off.

  • /chat save

    Save the current conversation.

  • /chat resume

    Restore a saved conversation.

  • /chat list and /chat delete

    Manage stored sessions.

  • /clear

    Start fresh whenever you switch topics.


Practical Examples

1) Refactoring Suggestions

Suppose you have a validation function that works but isn’t concise:
// file: validation.js
function checkUserAccess(userObject) {
if (userObject && userObject.isActive && userObject.permissions.level > 1) {
return true;
}
return false;
}

Ask Gemini to refactor it:
@validation.js Please refactor the checkUserAccess function to be more concise.

Possible suggestion:
// Suggested refactoring
const checkUserAccess = (userObject) =>
!!userObject && userObject.isActive && userObject.permissions.level > 1;

2) Generate Conventional Commits

Writing clean commit messages takes time. Let Gemini draft one from your staged changes:
!git diff --staged
From the diff above, write a Conventional Commit message.

You’ll get a polished, accurate commit message that reflects the change set.

3) Explain Tricky Shell Commands

Don’t blindly run commands copied from the internet. Ask Gemini first:
Explain this command: awk -F',' '{print $1, $3}' data.csv

Gemini will break down the flags, fields, and the expected output so you can proceed safely.


Why Pair with an Integrated Dev Environment?

Using an integrated dev environment for Node makes setup fast and predictable. You can install Node 20, keep multiple versions side-by-side, and avoid global conflicts — without wrestling with version managers or package conflicts. Start here if you need Node quickly:

node.js 20


Wrap-Up

Gemini CLI fits seamlessly into a terminal-first workflow: initialize your project context, authenticate once, and then use slash commands, shell integrations, and saved sessions to keep momentum. Combine it with a reliable integrated dev environment for Node.js 20+ and you’ll spend less time on setup and more time on shipping features with confidence.

Top comments (0)