Gemini CLI Memory: GEMINI.md, /memory and the Memory Tool (2026)

4 min read

How Gemini CLI remembers: GEMINI.md files at three levels, the /memory command, and the memory tool that writes Markdown. Where a memory server such as Hindsight fits. Gemini CLI docs read 2026-11-29.

Short answer: Gemini CLI remembers in plain Markdown. You write standing rules into GEMINI.md files, and the agent can save facts to them itself. Everything in those files is sent with each prompt. Use it for instructions and short facts. The docs we read describe no store for search across past sessions, and Hindsight is not an installer target for it, so any link is a manual MCP setup we have not tested.

This page covers Gemini CLI’s own memory. For the same question on the other coding agents, see AI coding agent memory. For the file-based approach in Cursor, see Cursor rules.

Sources, all read 2026-11-29 from the Gemini CLI repository’s docs: Provide context with GEMINI.md files, Memory tool, Commands reference and MCP servers with Gemini CLI.

The three kinds of memory file

LevelFileWhereWhat it is for
GlobalGEMINI.md~/.gemini/GEMINI.mdDefaults for every project, such as your coding style
Project and parentsGEMINI.mdIn your workspace folders and their parent foldersShared instructions for one project
Just in timeGEMINI.mdIn the folder of a file or directory a tool touches, up to a trusted rootRules for one part of a project, loaded only when needed

The CLI concatenates all the files it finds and sends them with every prompt. The footer shows how many context files are loaded.

The file name is not fixed. The context.fileName setting in settings.json takes a list, for example ["AGENTS.md", "CONTEXT.md", "GEMINI.md"].

Long files can be split with imports. A line such as @./components/instructions.md pulls in another file, with relative or absolute paths.

The memory tool

The memory tool stores durable facts. According to the Memory tool page, it edits Markdown files with write_file or replace, and it routes each fact to a file by scope:

  • Shared project instructions go in the repository’s GEMINI.md.
  • Private project notes go in a per-project private memory folder.
  • Personal preferences that span projects go in ~/.gemini/GEMINI.md.

The page says the stored facts load in every later session, and it asks the agent to keep them short and to avoid the same fact in several places. The page does not give the private folder’s path, so check it on your machine before you rely on it.

The /memory command

The commands reference lists three sub-commands:

  • /memory list shows the paths of the GEMINI.md files in use.
  • /memory show prints the combined text the model receives. Use it to check what is loaded.
  • /memory refresh reloads all GEMINI.md files from disk, so the model sees your latest edits.

The context page calls the last one /memory reload. Use the name your version shows in its help.

Limits to know

  • Everything loaded goes into every prompt. The docs give no size limit for GEMINI.md. A large file costs tokens on each request. Keep the shared file short and move detail into imported files.
  • Memory is plain files on disk. You can open, edit and version them with git, which also means you can delete a fact by hand.
  • Just-in-time files load late. A rule in a subfolder file only applies after a tool reads something in that folder.
  • No search over past sessions. The docs describe standing instructions and saved facts. They do not describe recall across old chats.

Where a memory server fits

A memory server such as Hindsight keeps history outside the files and returns what matches a question. For Gemini CLI, check three things first:

  • No installer. Hindsight’s Coding Agents package installs into 22 CLI agents, and Gemini CLI is not one of them (read 2026-11-12). Do not expect npx @vectorize-io/hindsight-coding-agents install gemini-cli to work.
  • An MCP server. Hindsight has an MCP server, and the Grok Bot integration uses its cloud endpoint, https://api.hindsight.vectorize.io/mcp, with OAuth. Gemini CLI connects to MCP servers through the mcpServers object in settings.json. We found no Gemini CLI setup in Hindsight’s docs, so we have not tested this connection and cannot say what it does in practice.
  • Model cost. Hindsight calls an LLM when it stores facts, and its reflect step calls one too. Gemini CLI’s file memory makes no extra model call.

Gemini CLI’s file memory is free and needs nothing extra. Keep it for rules and a few stable facts. A separate server only makes sense when you need search across many past sessions, and you should test it on your own work first.