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

> 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.

Source: https://aiagentmemory.org/articles/gemini-cli-memory/ · Updated 2026-11-29 · aiagentmemory.org


**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](https://github.com/vectorize-io/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](/articles/ai-coding-agent-memory/). For the file-based approach in Cursor, see [Cursor rules](/articles/cursor-rules/).

Sources, all read 2026-11-29 from the Gemini CLI repository's docs: [Provide context with GEMINI.md files](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/gemini-md.md), [Memory tool](https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/memory.md), [Commands reference](https://github.com/google-gemini/gemini-cli/blob/main/docs/reference/commands.md) and [MCP servers with Gemini CLI](https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md).

## The three kinds of memory file

| Level | File | Where | What it is for |
|---|---|---|---|
| Global | `GEMINI.md` | `~/.gemini/GEMINI.md` | Defaults for every project, such as your coding style |
| Project and parents | `GEMINI.md` | In your workspace folders and their parent folders | Shared instructions for one project |
| Just in time | `GEMINI.md` | In the folder of a file or directory a tool touches, up to a trusted root | Rules 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](https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/memory.md) 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](https://github.com/google-gemini/gemini-cli/blob/main/docs/reference/commands.md) 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](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/gemini-md.md) 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](https://hindsight.vectorize.io/sdks/integrations/coding-agents) 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.

## Related

- [AI coding agent memory](/articles/ai-coding-agent-memory/): how the main coding agents keep their instructions.
- [Gemini CLI install](/articles/gemini-cli-install/): install and first run.
- [Cursor rules](/articles/cursor-rules/): the same file-based approach in Cursor.
- [Claude Code memory](/articles/claude-code-memory/): CLAUDE.md and auto memory.


## FAQ

### How does Gemini CLI remember things?

Through Markdown files. Gemini CLI loads GEMINI.md files from your home folder, your project and its parent folders, and the folders a tool touches, then sends them with every prompt. Its memory tool also writes durable facts into these files, so they carry into later sessions.

### What does the /memory command do in Gemini CLI?

The commands reference lists three sub-commands: /memory list shows the paths of the GEMINI.md files in use, /memory show prints their combined text, and /memory refresh reloads them from disk. The context page calls the last one reload, so check the name your version shows.

### Can Hindsight be used as memory for Gemini CLI?

Not with an installer. Hindsight's Coding Agents package covers 22 CLI agents, and Gemini CLI is not one of them. Hindsight has an MCP server, and Gemini CLI can connect to MCP servers through settings.json. We have not tested that connection, and we found no Gemini CLI setup in Hindsight's docs.

### Does Gemini CLI memory have a size limit?

The docs we read give no size limit for GEMINI.md files. Every loaded file is sent with every prompt, so long files cost tokens on each request. Keep the shared file short, and move detail into imported files with @file.md.

