Post

How to Supercharge Your Terminal with Gemini CLI

How to Supercharge Your Terminal with Gemini CLI

TL;DR

Gemini CLI is Google’s free, open-source AI agent for your terminal. Powered by Gemini 2.5 Pro (with a huge 1 million-token context), it lets you scaffold apps, debug and refactor code, fetch and summarize web content, automate file ops, generate docs or slides, and even build custom chat agents—all via natural-language prompts. Install via homebrew, npx, npm; log in with your Google account for 60 req/min & 1 000 req/day free, or supply an API key for higher quotas and full privacy. Customize per-project behavior with gemini.md and .geminiignore, and extend capabilities through external MCP servers like Imagen, DuckDuckGo or HuggingFace.


Installation

Install the gemini-cli command system-wide.

Homebrew (macOS/Linux):

1
   brew install gemini-cli

Install via npx or npm

Prerequisite: Node.js ≥ 18 (check your current node version with node -v).

1
   npx https://github.com/google-gemini/gemini-cli?utm_source=genmind.ch
1
   npm install -g @google/gemini-cli

Authentication & Privacy

You can use your Google account (for free) or with an API key, here is how and key differences:

  • Google-account login (free tier): On first run, pick a color theme then sign in with your personal Google account—no billing setup required. You get 60 model requests/min and 1 000 requests/day at no cost. But here is the caveat: Under the Gemini Code Assist Privacy Notice, prompts & responses may be logged for product improvement (opt-out available).
  • API-key login (usage-based, full privacy): Generate a key in Google AI Studio, then run:

    1
    
    export GEMINI_API_KEY="YOUR_API_KEY"
    

    to switch to API-key mode—enabling higher rate limits, specific‐model access, and no data ingestion for improvements.


Project Configuration

  • .geminiignore: Exclude files/folders (like logs or large assets) from being read into context—just like .gitignore.
  • gemini.md: Drop this in your repo root to provide persistent “memory” (project rules, styles, or context) that loads automatically each session.
  • settings.json: In .gemini/, configure external MCP servers, default models, or bug filing behavior; see the repo’s docs/cli/configuration.md for details.

Getting Started

In any directory—new or existing—run:

1
gemini

to enter the interactive REPL (gemini>). From here, type natural-language prompts like:

1
> Scaffold a FastAPI todo app with SQLite

If you are planning to use the tool as a code assistant better if you set your default working folder with the @ command eg ‘@/Users/gp/Developer/samples/gemini-cli-test’

and watch it create files, install deps, run tests, and show you the results.

gemini-cli in action gemini-cli in action

After a while the tool was able to create a fully, almost, working solution. It just forget to create the __init__.py so uviconr was failing to start. A quick look and after 10 seconds the APis were working! Then I asked to create a simple python file to test the APIs. It worked first shot. I asked some more changes to the tested and everything went well. In less than ten minutes I had the solution working and even well organized and architected.
This is the proof that Andrej Karpathy is a visionary and he is totally right about where software development is going see his post from 2017 Software 2.0, and his speech at the AI Startup School in San Francisco Software Is Changing (Again). I’m no one, but I can’t agree more with him, I saw this happening back in 2019 when I gave my first speech about AI AI for every developer
I diverged a bit, but I’m really exited about the coming revolution in software development. Now back to track…


Core Slash Commands & Built-In Tools

Type /tools in the REPL to see everything at your fingertips. Below is the slash-command list:

CommandDescription
/bugFile a GitHub issue with your current prompt as the title (configurable via settings.json).
/chat saveSave the current conversation under a named tag.
/chat resumeResume a previously saved conversation.
/clearClear the terminal display (same as Ctrl+L).
/compressReplace the entire context with a concise summary to save tokens.
/helpShow general help and usage tips.
/mcpList or describe configured Model Context Protocol servers and their tools.
/memory addAdd a fact to your project memory (persisted via GEMINI.md).
/memory showDisplay all saved memory entries.
/memory refreshRe-load memory from GEMINI.md.
/restoreRoll back all file changes to the state before your last tool invocation.
/statsDisplay token usage, cache savings, and session duration (cached tokens only in API-key mode).
/themeSwitch the CLI’s color theme.
/authToggle authentication method (OAuth vs API key).
/aboutShow version info, authentication status, and environment details.
/quitExit the Gemini CLI.

What You Can Do: Sample Use Cases

Coding Assistant

  • Prompt:

    1
    
    > Generate a Next.js + Tailwind CDN landing page for a pizza by the slice bakery like the ones in Rome.
    

    Outcome: Creates pages/index.js, links Tailwind from CDN, and scaffolds responsive components.

  • Prompt:

    1
    
    > Find and fix failing pytest tests in tests/test_user.py.
    

    Outcome: Applies patch edits, runs !pytest, and reports success.

Research & Summaries

  • Prompt:

    1
    
    > Web-fetch "https://techcrunch.com" and save summaries of the top 5 AI articles to ai_summaries.txt.
    

    Outcome: Downloads pages, extracts headlines, writes summaries via write-file. (datacamp.com)

Content Generation

  • Prompt:

    1
    
    > Draft a 500-word GenMind.ch blog post on the latest trends in LLM fine-tuning.
    

    Outcome: Outputs a structured draft ready to copy into your CMS.

Automation & DevOps

  • Prompt:

    1
    
    > !for f in *.png; do convert "$f" "${f%.png}.webp"; done
    

    Outcome: Batch-converts all PNGs to WebP via shell integration.

Slide Decks

  • Prompt:

    1
    
    > Create a 5-slide PowerPoint deck summarizing last week’s Git commits by author.
    

    Outcome: Uses a Python script under the hood to parse git log and outputs deck.pptx. (datacamp.com)

6. Custom Agents (ADK)

  • Prompt:

    1
    
    > Using DuckDuckGo MCP, scaffold an ADK agent that answers questions about this codebase.
    

    Outcome: Generates agent.py, Docker setup, and config for adk web. (cloud.google.com)


Advanced: Extending with MCP Servers

  1. Configure .gemini/settings.json with your MCP endpoints (e.g., Imagen, DuckDuckGo, Hugging Face).
  2. Install local clients (pip install duckduckgo-mcp-server).
  3. List with /mcp list and describe with /mcp desc.
  4. Invoke in prompts, e.g.:

    1
    
    > /mcp huggingface-image generate an illustration of a data scientist
    

Tips & Best Practices

  • Use gemini.md to seed long-term context and project rules. (cloud.google.com)
  • Lean on web-fetch and /search for real-time facts.
  • Persist insights with /memory add.
  • Avoid token bloat via /compress on stale context.
  • Monitor limits daily with /stats to stay under free quotas.

Wrap-Up

Gemini CLI brings an incredibly versatile AI assistant to your terminal—whether you’re coding, researching, automating, or building agents. It’s free to try, simple to install, and endlessly extensible. Give it a spin:

1
   brew install gemini-cli

For full docs and the source code, check out the GitHub repo and the official docs.

Happy prompting!

This post is licensed under CC BY 4.0 by the author.