Blog
·6 min

Where Gemini CLI Stores Your Chat History — and When It Deletes It

Gemini CLI keeps sessions per project under ~/.gemini/tmp, and deletes anything older than 30 days by default. Here is the layout, the setting that controls the deletion, and how to turn it off.

Gemini CLI saves your conversations automatically and deletes them automatically. Both halves are defaults, both are on, and the second one is the half nobody is shown.

The exact location

Sessions are stored per project, in a directory named after a hash of the project's root path:

# sessions — the conversations themselves
~/.gemini/tmp/<project_hash>/chats/

# checkpoints — conversation state plus tool calls
~/.gemini/tmp/<project_hash>/checkpoints

# checkpoint snapshots — a shadow git repository
~/.gemini/history/<project_hash>

What gets written is the complete conversation: your prompts, the model's responses, the tool executions in between, token usage, and reasoning summaries where available. That is a good record. Note the directory it is written to, though — tmp is not an accident of naming, it is a statement of intent.

The project hash means history is scoped to the directory you started from. Run gemini from a different path — a renamed folder, a different checkout of the same repository, a symlink — and you get a different hash and an empty history, while the old sessions sit untouched under the old one.

# what is on this machine
ls ~/.gemini/tmp/ 2>/dev/null | wc -l          # projects with history
find ~/.gemini/tmp -path '*/chats/*' | wc -l   # sessions
du -sh ~/.gemini/tmp 2>/dev/null

# nothing there? either no sessions yet — or cleanup already ran

The 30-day default

Session retention is configured in settings.json under general.sessionRetention. The defaults are worth reading carefully, because three of the four are doing something:

  • enabled: true — automatic cleanup is on.
  • maxAge: "30d" — sessions older than thirty days are deleted.
  • minRetention: "1d" — a safety floor; nothing newer than a day is ever auto-deleted.
  • maxCount: undefined — no limit on how many sessions you keep, only on how old they get.
Claude Code deletes transcripts after 30 days by default. Gemini CLI deletes sessions after 30 days by default. Two different vendors reached the same number, and neither shows it to you.

The convergence is not a conspiracy; it is what happens when two teams independently classify the same thing as a cache. A month of conversation logs per developer is real disk, and cleaning it up is defensible. The mismatch is between what the policy treats the files as and what they have become — the only written record of why a large share of your codebase looks the way it does.

How to stop the deletion

One block in settings.json. Do this today whether or not you ever install anything else:

// ~/.gemini/settings.json
{
  "general": {
    "sessionRetention": {
      "enabled": false
    }
  }
}

If you would rather keep cleanup on but push the horizon out, set maxAge to something long — "3650d" — instead of disabling it. Either way, check what you already have before you assume it worked: if you have been using Gemini CLI for more than a month and ~/.gemini/tmp holds nothing older than thirty days, the cleanup has already run and what it took is not in a trash folder.

How to back it up

DEST="$HOME/Backups/gemini-$(date +%Y-%m-%d).tar.gz"
tar -czf "$DEST" -C "$HOME" .gemini/tmp .gemini/history 2>/dev/null
tar -tzf "$DEST" | wc -l

Add that destination to whatever already backs up your home directory. If you want the picture across every AI tool on the machine rather than Gemini alone, promptwake doctor scans for AI coding history and reports what each tool holds and what is inside a deletion window — through npx, with no account, writing nothing and sending nothing anywhere.

Where the personal fix stops working

Turning off retention on your own machine solves your problem completely. It solves nothing for a team, for reasons that repeat across every tool in this category.

It has to be set on every machine by every developer before the thirty-first day, and anyone who joins next month starts the clock over. The files stay on the laptop that wrote them, so a wiped machine takes the record with it. Nobody else can read them, so there is no shared view of what the team asked the model to build. It covers Gemini CLI and nothing else. And a retention setting on a personal laptop is not evidence of anything you could show to someone who asks how a piece of AI-written code came to exist.

What to do this week

Set general.sessionRetention.enabled to false today — it costs one block and removes a deadline you did not choose. Then find out how much of the last year is already gone, across the whole team. That number is usually the argument, and getting it costs nothing.

If the answer is that the record matters and should not depend on each developer having read a blog post in time, that is what PromptWake was built for: it captures the prompt, the response and the resulting diff from the AI tools your team already uses, keeps them locally by default, and on the paid tiers syncs them into one timeline the team can search and audit. Change the setting regardless — the cleanup runs whether or not anyone is watching.