cobrain
Create your brainGo to your brain
Blog · 27 November 2026 · 6 min

How to give Gemini CLI long-term memory

What Gemini CLI remembers between sessions, how GEMINI.md, saved memories and Auto Memory work, where they stop, and how to add long-term memory over MCP.

Gemini CLI starts every session knowing your code and nothing about your week. The payments module is frozen until the audit? The client wants British spelling? The quick fix for the flaky test was tried on Tuesday and reverted? Unless someone wrote it down where the CLI looks, it's gone. Gemini CLI does have a few places to write things down, and they're worth knowing, along with where they stop.

Below: how Gemini CLI's memory works, where it runs out, and how to connect a long-term memory over MCP that other AIs can read too. Everything about Gemini CLI was checked against its official documentation on 27 November 2026.

One thing first. In May 2026 Google announced that from 18 June 2026 Gemini CLI would stop serving requests for Google AI Pro and Ultra subscribers and for the free Gemini Code Assist for individuals; those users move to Antigravity CLI. Organizations with a Gemini Code Assist Standard or Enterprise license keep their access, and Gemini CLI still works with paid Gemini API keys. If you've moved, see How to give Google Antigravity long-term memory; Antigravity reads GEMINI.md too.

GEMINI.md: the memory Gemini CLI loads every time

The core of Gemini CLI's memory is a plain Markdown file called GEMINI.md. The CLI looks for it in three places:

  • globally, in ~/.gemini/GEMINI.md, which applies to every project on your machine;
  • in your workspace folders and their parent folders;
  • just in time: when a tool touches a file or folder, the CLI scans that folder and its parents, up to a trusted root, for more GEMINI.md files.

It concatenates everything it finds and, in the docs' words, sends it "to the model with every prompt". /memory show prints the combined text, /memory list shows which files are in use, and /memory reload rereads them after you edit one by hand (the commands reference calls it /memory refresh).

Where Gemini CLI looks for memory

  • ~/.gemini/
  • GEMINI.mdglobal, every project
  • settings.jsonMCP servers, every project
  • repo/
  • GEMINI.mdshared with the team through git
  • .gemini/settings.jsonMCP servers for this project
  • src/
  • GEMINI.mdloaded when a tool touches this folder
Everything found is joined together and sent with every prompt.

The file name isn't fixed. With context.fileName in settings.json you can give a list, for example AGENTS.md and GEMINI.md, handy if Codex already reads AGENTS.md in the repository. We covered that overlap in CLAUDE.md vs AGENTS.md. A GEMINI.md can also pull in other files with @./path/file.md, up to five levels deep by default.

Asking it to remember

Tell the agent "remember that I prefer const over let" and it writes the fact down. The docs describe where it goes: shared project instructions in the repository's GEMINI.md, private notes about the project in a per-project private memory folder, and personal preferences that cross projects in ~/.gemini/GEMINI.md. Whatever is saved gets loaded into future sessions automatically. Google suggests it for preferences, architecture decisions, aliases and system settings: short facts that stay true for a long time.

Auto Memory: lessons mined from old sessions

Auto Memory is newer and marked experimental. It's off by default; you switch it on with "experimental": { "autoMemory": true } in ~/.gemini/settings.json (or in a project's .gemini/settings.json) and restart the CLI.

When it's on, it reads your past sessions in the background and proposes two kinds of things: changes to memory files and drafts of reusable skills. It only looks at sessions that have been idle for at least three hours and have at least ten messages from you. The current session doesn't count.

How Auto Memory proposes a change

  1. 1A session goes quiet3 hours idle, 10+ messages
  2. 2It reads the transcriptin the background
  3. 3It drafts a patch or skillinto a project inbox
  4. 4You review /memory inboxapply, promote or dismiss
Nothing changes in your memory files until you approve it.

Nothing gets applied on its own. Proposals wait in an inbox for each project, and you go through them with /memory inbox: apply or dismiss a memory change, promote or discard a skill. The docs say Auto Memory can't edit active memory files, settings, credentials or a project's GEMINI.md directly. Two caveats from the docs: extraction runs on a preview Gemini Flash model, and excerpts of your transcripts may be sent to it.

Saved sessions

Gemini CLI also keeps every conversation. Sessions are saved automatically in ~/.gemini/tmp/<project_hash>/chats/, one history per project folder. /resume opens a browser where you can search them, and gemini --resume picks up the latest one from the command line. By default sessions older than 30 days are cleaned up, and you can change that with general.sessionRetention.

You still have to remember which session to open, though, and a month later it's gone.

Where Gemini CLI's memory stops

It's local. ~/.gemini/GEMINI.md, the private project notes, the Auto Memory inbox and the session history all live on one machine. The GEMINI.md in the repository travels with git; the rest doesn't. Open a second laptop and the personal memory isn't there.

It costs context. Every loaded GEMINI.md goes with every prompt. A running log of decisions and client notes grows every week, and the agent carries it on every turn whether the task needs it or not. Our article on why your AI forgets mid-conversation explains why a fuller context isn't free.

It stays inside Gemini CLI. A team that plans in Claude, writes in ChatGPT and codes in Gemini CLI ends up with three memories that don't know about each other. AGENTS.md helps between coding agents, but a file in a repository doesn't reach a chat in the browser or on your phone.

GEMINI.md or a memory over MCP

GEMINI.md and memory filesMemory over MCP
Where it livesrepo or ~/.geminion a server
When it's readwith every promptwhen the agent needs it
Other computersonly the repo file
Claude, ChatGPT
Keep the rules short. Put the history where every AI can look it up.

MCP: how to plug in a long-term memory

MCP servers go in the mcpServers block of settings.json: ~/.gemini/settings.json for every project, .gemini/settings.json for one. A local server starts with command; a remote one uses url for SSE or httpUrl for Streamable HTTP.

You can also add one from the terminal. gemini mcp add --transport http <name> <url> writes it for the current project by default; add -s user to have it everywhere. Two details from the docs: don't use underscores in the server name, and remote servers that support OAuth are handled automatically. The CLI notices the server wants a sign-in, opens the browser, and stores the token in ~/.gemini/mcp-oauth-tokens.json. That browser step won't work in a headless setup or over SSH without a display.

Every MCP tool call asks first: proceed once, always allow this tool, always allow this server, or cancel. The trust option skips those questions for a server, so think before setting it on anything that can write.

With a memory server connected, the agent can search notes when a task starts, read the few that matter and save a decision before you close the terminal. There's more on the kinds of memory servers in What is an MCP memory server.

How Cobrain fits

Cobrain is a remote MCP server with OAuth 2.1, and the guides page says any program that can connect to an MCP server over HTTP connects to Cobrain by pasting https://cobrain.space/mcp. With the syntax from Gemini CLI's documentation, that's one line:

gemini mcp add -s user --transport http cobrain https://cobrain.space/mcp

Then you sign in once in the browser. From there, keep GEMINI.md for the short list of how this codebase works, and let the notes hold what happens around it: what the client asked for, what you tried, what's still open. Notes are Markdown files in folders. When one changes, the previous version stays, along with who changed it and when, even when it was your AI. And the same notes are open to Claude, ChatGPT, Claude Code, Codex and Cursor, which is the part a file in ~/.gemini can't do. How that works is on Cobrain across AIs.

Gemini CLIsaves a decision
via MCP
CobrainMarkdown notes in folders
read
Claude, ChatGPT, Codex…find the same note
The note leaves the terminal, and leaves your laptop.

Quick answers

Does Gemini CLI remember previous conversations? It saves them. Sessions are stored per project and you can reopen one with /resume or gemini --resume; by default they're deleted after 30 days. A new session doesn't know what was said in the old ones unless it was saved to a memory file.

Where is Gemini CLI's memory stored? In GEMINI.md files: the global one in ~/.gemini/GEMINI.md, one in the project and its parent folders, and others picked up as tools touch subfolders. Private project notes go in a per-project memory folder on your machine.

How do I make Gemini CLI remember something? Ask it to, in plain words ("remember that…"). It writes the fact into the right Markdown file and loads it in future sessions. You can also edit GEMINI.md yourself and run /memory reload (/memory refresh in the commands reference).

Can Gemini CLI read AGENTS.md? Yes, if you add it to context.fileName in settings.json, for example ["AGENTS.md", "GEMINI.md"].

Can Gemini CLI and Claude share the same memory? Not through GEMINI.md, which stays in the repository and on your machine. They can share notes kept behind an MCP server that both are connected to.

Free, no card needed

Start with a single note.

It is free and no card is needed. You sign in with a link sent by email, connect your AI and start building a memory that does not stay locked inside a chat.

Create your brain, freeGo to your brainA thousand notes, as many AIs as you want to connect.