How do I clean up Gemini CLI Mac disk usage without losing my project context?

Audit Gemini CLI Mac disk usage across ~/.gemini and its caches, then run a Trash-first sweep of sessions, tmp, and logs without resetting oauth or memory.

8 min read · Published · Updated · Saad Belfqih

A du -sh ~/.gemini on a Mac running Google's Gemini CLI as a daily driver for a couple of months almost always crosses 3 GB, and 8 to 12 GB is routine after any file-edit or shell-tool work on a monorepo. None of it surfaces in macOS Storage as anything other than the gray System Data bar, because ~/.gemini is a dotfolder and Apple's UI does not break it out. The same growth pattern shows up in the brtkwr.com 200 GB cleanup writeup, where the author's summary of editor and CLI bloat was "When you stop using an editor, uninstall it properly or manually delete its Application Support directory." The rule applies one level down for agent CLIs like Gemini.

TL;DR
A safe Gemini CLI Mac disk cleanup means auditing `~/.gemini/` and `~/Library/Caches/google-gemini-cli/`, then routing `tmp/`, `logs/`, `cache/`, and stale `sessions/` entries to Trash while leaving `oauth_creds.json`, `settings.json`, and `memory/` untouched. Expect 2 to 9 GB back on a Mac that has been running Gemini CLI for a few months. CleanMyDev maps every Gemini CLI path with per-row size, last-used date, and a risk label, then moves anything you tick to Finder Trash on a single click.

Where does Gemini CLI store its files on a Mac?

Gemini CLI is Google's open-source command-line agent for the Gemini family of models, distributed as a Node package and installed globally. Like every other agent CLI in this category (Codex, Claude Code, Cline) it does not use the macOS Application Support layout. Instead it follows the Unix dotfolder convention plus a small macOS-side cache.

The first root is ~/.gemini/. This is where the CLI keeps everything stateful: oauth_creds.json for your Google sign-in, settings.json for per-machine preferences, memory/ for the rolling cross-session project memory, sessions/ for the full transcript of each agent run, tmp/ for checkpoint snapshots and scratch files, cache/ for hashed tool outputs and embeddings, and logs/ for the per-run debug log archives. Almost all of the weight lives in sessions/, tmp/, and logs/.

The second root is ~/Library/Caches/google-gemini-cli/. macOS routes app-marked transient caches here. It is smaller than ~/.gemini/ but it carries downloaded tool binaries and font caches from TUI rendering, and on a long-running install it crosses a few hundred megabytes. If you have set GEMINI_HOME to a different path, that becomes the first root instead. Check with env | grep -i gemini before any audit.

Why does Gemini CLI disk space grow so fast?

Four growth channels stack, in roughly this order on a real dev Mac.

First is sessions/. Every run writes a full transcript: prompts, tool calls, stdout of every shell command, and the diff of every file edit. A long debugging session hits 80 to 200 MB. Ten runs a day for a month puts you in multi-GB territory.

Second is tmp/. Checkpoints, partial tool outputs, and the staging buffers all land here. The CLI tries to clean tmp/ on a normal exit, but a crash, a kill signal, or a Terminal close leaves the directory full. This is the same growth pattern the Codex CLI rollout sessions cleanup writeup names for ~/.codex/.

Third is cache/. Hashed tool outputs, embedding caches for code search, and downloaded context files. Nothing here is unique, everything regenerates on the next run.

Fourth is logs/. The CLI rotates the visible log file per run, but rotated archives stick around forever. On a Mac where the CLI runs many times per day, this folder passes a gigabyte inside two months.

The pattern is the one named in the AI coding tools disk footprint 2026 explainer: every agent CLI emits transcripts, traces, checkpoints, caches, and embeddings, and none of them prune by default.

How do I audit Gemini CLI Mac disk usage honestly?

Three commands give you the truth. Run them in a normal Terminal, no sudo.

# Top-level: how much disk does Gemini CLI claim across both roots?
du -sh "$HOME/.gemini" \
       "$HOME/Library/Caches/google-gemini-cli" 2>/dev/null

# Per-subfolder: where inside ~/.gemini is the weight?
du -sh "$HOME/.gemini/"* 2>/dev/null | sort -h

# Per-session: which sessions carry the biggest transcripts?
du -sh "$HOME/.gemini/sessions/"* 2>/dev/null | sort -h | tail -20

The first command is the headline number. Under 1 GB, close the tab. Past 3 GB, the second tells you whether the weight is in sessions/, tmp/, cache/, or logs/. The third names the heaviest sessions. Gemini CLI does not use hardlink storage, so du and reality agree byte-for-byte. The first JSON record in each session file carries the working directory, model, and start timestamp, which is enough to decide whether a 180 MB transcript is a debugging marathon worth keeping or a forgotten experiment.

What is safe to delete in a Gemini CLI cleanup?

The bright-line answer is in the table below. The same shape applies to every dotfolder agent CLI in this category: keep the credentials and the memory, throw the transcripts and the diagnostics.

Path What it holds Safe to delete? What you lose
~/.gemini/oauth_creds.json Google OAuth tokens for the CLI No Re-login required, agent unusable until then
~/.gemini/settings.json Per-machine CLI settings No Editor preferences and tool flags reset
~/.gemini/memory/ Cross-session rolling project memory No Agent forgets prior project context
~/.gemini/sessions/<id>/ Full transcript of a single agent run Yes for stale runs Ability to replay or audit that session
~/.gemini/tmp/ Checkpoint snapshots and scratch files Yes when CLI is not running Crash-recovery state for active runs
~/.gemini/cache/ Tool output and embedding cache Yes Slight latency on first re-run
~/.gemini/logs/ Rotated per-run debug logs Yes Diagnostic history for past runs
~/Library/Caches/google-gemini-cli/ macOS-side cache directory Yes Re-populated lazily

Anything in tmp/, cache/, logs/, and the macOS Caches folder is throwaway. sessions/ is safe per stale entry. The three credential and config files are off-limits unless you want a full reset.

How do I run the Gemini CLI cleanup safely?

The safe playbook is six steps. The first two are read-only. The rest are reversible because they go to Trash, not to rm -rf. Quit any active Gemini CLI run before step 3 so nothing holds an open file handle.

# 1. Audit (read-only)
du -sh "$HOME/.gemini" \
       "$HOME/Library/Caches/google-gemini-cli" 2>/dev/null

# 2. Find anything modified in the last 24 hours so you do not touch an active run
find "$HOME/.gemini/sessions" "$HOME/.gemini/tmp" \
  -mindepth 1 -maxdepth 1 -mtime -1 2>/dev/null

# 3. Move the cache and tmp folders to Trash (lossless)
STAMP=$(date +%Y%m%d)
mv "$HOME/.gemini/cache" \
   "$HOME/.Trash/gemini-cache-$STAMP" 2>/dev/null
mv "$HOME/.gemini/tmp" \
   "$HOME/.Trash/gemini-tmp-$STAMP" 2>/dev/null

# 4. Move rotated log archives to Trash
mv "$HOME/.gemini/logs" \
   "$HOME/.Trash/gemini-logs-$STAMP" 2>/dev/null

# 5. Move sessions older than 30 days to Trash, keep recent ones
find "$HOME/.gemini/sessions" \
  -mindepth 1 -maxdepth 1 -mtime +30 \
  -exec mv {} "$HOME/.Trash/" \; 2>/dev/null

# 6. Move the macOS-side cache to Trash
mv "$HOME/Library/Caches/google-gemini-cli" \
   "$HOME/.Trash/gemini-syscache-$STAMP" 2>/dev/null

Relaunch with gemini and confirm three things: no OAuth prompt, the agent still remembers your project context, and a fresh du -sh ~/.gemini returns a number under a gigabyte. Empty the Trash a week later. That seven-day window turns "did I just nuke the session I needed" into a Cmd+click in Finder, which is the Move to Trash vs rm -rf discipline applied at the CLI layer.

How does Gemini CLI disk space compare to Claude Code, Codex, and Cursor?

Same growth shape, different magnitude. CLI agents stack transcripts plus checkpoints plus logs. IDE agents stack workspace state plus Chromium caches. Gemini CLI sits in the same league as Codex CLI, smaller than Claude Code with the Claude Code 472 GB debug bug triggered. Rough month-three footprints on a daily-driver Mac look like this.

Tool Primary state root Cache root Typical 3-month size
Claude Code ~/.claude/ ~/Library/Caches/claude-cli-nodejs/ 15 to 80 GB, worse with debug bug
Codex CLI ~/.codex/ ~/.codex/log/ 8 to 30 GB
Gemini CLI ~/.gemini/ ~/Library/Caches/google-gemini-cli/ 2 to 9 GB
Cursor ~/Library/Application Support/Cursor/ same root 10 to 40 GB
Windsurf ~/Library/Application Support/Windsurf/ ~/Library/Caches/com.exafunction.windsurf/ 3 to 14 GB
Cline (VS Code ext) ~/Library/Application Support/Code/User/globalStorage/ same root 3 to 12 GB

If you have more than one of these installed, the which AI coding tool uses the most disk breakdown is the right starting point. A Mac with Gemini CLI, Claude Code, and Cursor in daily use can carry 25 to 60 GB of agent state before you look at simulators, Docker, or Ollama.

How do I keep Gemini CLI storage from creeping back?

Two habits cap it. First, schedule the audit, not the deletion. A monthly launchd job that logs the two du -sh numbers is enough. Seeing ~/.gemini at 4 GB in month three is information. Finding it at 22 GB in month nine on a 5 GB-free disk is a panic.

Second, prune sessions/ at the project boundary. When you finish a piece of work you will not revisit, move that session folder to Trash the same day. The sessions worth keeping are the ones you came back to in the first week.

If you want the same audit across Gemini CLI, Codex, Claude Code, Cursor, Windsurf, Cline, and the Ollama and Hugging Face model caches in one read-only pass, that is the job CleanMyDev was built for. Full per-tool footprint on the pricing page at $9.99 lifetime, no subscription, no telemetry, no sudo, no scareware.

Closing

Gemini CLI is not the worst offender on a 2026 dev Mac, but it carries the standard agent-CLI tax: a sessions/ folder that never shrinks, a tmp/ that survives crashes, and a logs/ that rotates forward without ever rotating out. A real Gemini CLI Mac disk cleanup is two audited roots, a Trash-first sweep of the cache and log directories, a stale-session prune, and the habit of checking the number monthly. Leave oauth_creds.json, settings.json, and memory/ alone. Everything else is recoverable for the price of a slightly slower first run. If you want the audit and Move-to-Trash safety floor in one app, CleanMyDev is $9.99 lifetime on the pricing page.

Related reading

Stop wondering what System Data is.

CleanMyDev opens the box. 110+ developer-specific cleanup targets. Move-to-Trash by default. $9.99 lifetime.

Get CleanMyDev — $9.99