Gemini CLI memory: GEMINI.md, /memory and MCP
How Gemini CLI remembers across sessions: GEMINI.md files, /memory commands, saved memories, context.fileName, resume and a shared memory server over MCP.
Gemini CLI has three kinds of memory. GEMINI.md files are instructions, loaded into every prompt. Saved memories
are facts the agent writes into those Markdown files when you ask it to remember something. gemini --resume
reopens one saved chat. For memory shared across repos, machines and teammates, you add an MCP memory server in
~/.gemini/settings.json.
How Gemini CLI loads GEMINI.md
The GEMINI.md docs describe three tiers. The CLI joins every file it finds and sends the result with every prompt:
- Global.
~/.gemini/GEMINI.mdholds defaults for all your projects. - Workspace. The CLI searches your workspace directories and their parent directories for
GEMINI.md. - Just in time. When a tool reads a file or directory, the CLI scans that directory and its parents, up to a
trusted root, and loads any
GEMINI.mdit finds there.
Details that matter in practice:
- The upward search stops at the first directory with a
.gitin it. Change the markers withcontext.memoryBoundaryMarkers. An empty list turns parent search off (configuration). - At most 200 directories are searched by default (
context.discoveryMaxDirs). - The footer shows how many context files are loaded.
- A large file can be split with imports. A line like
@./docs/style.mdpulls that file in, with relative or absolute paths (import processor). - In an untrusted folder, with Trusted Folders turned on, the CLI
ignores the project's
.gemini/settings.jsonand connects to no MCP servers.
The /memory commands
/memory works on the loaded context:
/memory showprints the full joined text the model gets. Use it when a rule seems ignored./memory listlists the paths of theGEMINI.mdfiles in use./memory reload(aliasrefresh) scans all locations again. Run it after you edit a file mid session./memory inboxopens the Auto Memory review list, if you turned that feature on.
save_memory and where memories go
Older Gemini CLI versions had a save_memory tool. It appended each fact as a bullet under a
## Gemini Added Memories heading in your global ~/.gemini/GEMINI.md.
The current memory docs no longer list that tool. When you say
"remember that the staging server is 10.0.0.5", the agent edits a Markdown memory file itself, with write_file
or replace. It picks the file by kind:
- Shared project instructions go into the repo's
GEMINI.md. - Private project notes go into a per-project private memory folder.
- Personal preferences for all projects go into
~/.gemini/GEMINI.md.
Saved facts load in all future sessions, like the rest of the hierarchy. See the memory tutorial.
Auto Memory is an experimental extra. Turn it on with:
{
"experimental": {
"autoMemory": true
}
}After a restart it scans past sessions in the background. Only sessions idle for three hours with at least 10 of
your messages count. It drafts memory patches and skills into an inbox, and nothing applies until you approve it in
/memory inbox. It cannot write project GEMINI.md files, only private project memory, your global file and
skills. Transcript excerpts may be sent to the model during extraction.
Use AGENTS.md or another file name
GEMINI.md is only the default. context.fileName in settings.json takes one name or a list:
{
"context": {
"fileName": ["AGENTS.md", "CONTEXT.md", "GEMINI.md"]
}
}With AGENTS.md in the list, one file can serve Gemini CLI and the other agents that read AGENTS.md. Put the
setting in ~/.gemini/settings.json for all projects, or in .gemini/settings.json for one repo.
Checkpointing and resuming sessions
Resume is not memory, but it often solves the same problem: picking up where you stopped.
Session management saves every chat on its own, in
~/.gemini/tmp/<project_hash>/chats/, per project:
gemini --resume # latest session
gemini --resume 1 # by index from --list-sessions
gemini --list-sessionsInside the CLI, /resume opens a session browser with search. /resume save <tag> and /resume resume <tag> keep
named points in a chat. /chat is an alias.
Checkpointing is about files. It is off by default:
{
"general": {
"checkpointing": {
"enabled": true
}
}
}Before a tool edits files, the CLI commits a snapshot to a shadow git repo in ~/.gemini/history/<project_hash>.
/restore lists the checkpoints and rolls files and chat back to one. A resumed chat only knows what was said in it.
Add an MCP server in settings.json
MCP servers go under mcpServers in ~/.gemini/settings.json, or in .gemini/settings.json for one project
(MCP docs). Use command for a local server, httpUrl for a
streamable HTTP server and url for SSE:
{
"mcpServers": {
"local-tool": {
"command": "npx",
"args": ["-y", "some-mcp-server"]
},
"remote-tool": {
"httpUrl": "https://example.com/mcp"
}
}
}Or run gemini mcp add --transport http <name> <url>. Its scope is project by default; add -s user for the
global file. Remote servers can use OAuth: when a server answers 401, the CLI discovers its endpoints, opens the
browser and stores the tokens in ~/.gemini/mcp-oauth-tokens.json. /mcp auth <name> logs in again.
How the layers compare
| Layer | Written by | Stored | Shared with a team |
|---|---|---|---|
GEMINI.md in the repo | You, or the agent on request | Repo | Yes, through git |
~/.gemini/GEMINI.md | You, or the agent on request | Your home | No |
| Private project memory | The agent on request | Your machine | No |
| Auto Memory | Background agent, after your approval | Your machine | No |
| Sessions and checkpoints | The CLI | ~/.gemini/tmp, ~/.gemini/history | No |
| MCP memory server | The agent, through tools | The server | Depends on the server |
Checked November 2026.
Where GEMINI.md and save_memory stop
- Lessons from chat. A fact lands in a file only when you ask the agent to remember it, or approve an Auto Memory patch.
- Teammates. Your global file and private memories stay on your machine. Only a committed
GEMINI.mdis shared. - Other agents. Claude Code and Cursor do not read
~/.gemini/GEMINI.mdor Gemini's private memory. - Knowledge beyond one repo. Servers, accounts and deploy steps have no natural
GEMINI.md. - Rules that must hold. A line in
GEMINI.mdis guidance.
If you work alone in one repo, a GEMINI.md in git plus saved memories is often enough. Stop there.
A shared memory server: agexs brain
An MCP memory server gives every agent the same store. Over MCP alone, though, the agent has to decide to search, and agents rarely search for what they do not know they are missing.
agexs brain works over MCP in Gemini CLI. Add it to ~/.gemini/settings.json:
{
"mcpServers": {
"agexs-brain": {
"httpUrl": "https://brain.agexs.dev/mcp"
}
}
}Start Gemini CLI. The server asks for a login, and the CLI opens the browser for your agexs account. If it does
not, run /mcp auth agexs-brain. Then:
- The agent loads your always-on rules and the memories for its task with
memory_context, and can search, save and update memories. - One store for Gemini CLI, Claude Code, Codex and Cursor, with private and team spaces. See Memories and spaces.
What you do not get in Gemini CLI: the one-command install and the hooks. agexs install covers only Claude Code,
Codex and Cursor (Connect your agents). Gemini CLI has its own
hooks (SessionStart, BeforeAgent, BeforeTool and more), but agexs brain
does not ship hooks for it. So nothing is pushed on its own, and rules that block a command or
ask first do not apply. See Connect MCP clients.
Your existing GEMINI.md can be imported, one memory per rule or fact, and the file stays as
it is. See Plans and billing.
FAQ
Does Gemini CLI have persistent memory?
Yes. GEMINI.md files load with every prompt, and facts you ask it to remember are written into Markdown memory
files that load in future sessions. All of it stays on your machine unless you commit a GEMINI.md to git.
Where does Gemini CLI save memories?
Personal facts go into ~/.gemini/GEMINI.md, private project notes into a per-project memory folder, and shared
project rules into the repo's GEMINI.md. Older versions put every fact under ## Gemini Added Memories in the
global file.
Can Gemini CLI read AGENTS.md?
Yes. Set context.fileName in settings.json to a list such as ["AGENTS.md", "GEMINI.md"].
Why does Gemini CLI ignore my GEMINI.md changes?
The session keeps the context it loaded. Run /memory reload, then /memory show to see what the model gets. Also
check that the folder is trusted and that the file is not above the repo root, where the upward search stops.
How do I share Gemini CLI memory with my team?
Commit GEMINI.md and .gemini/settings.json to the repo. For memory beyond one repo or one agent, add a memory
server over MCP.
Last updated on
Cursor memory: rules, AGENTS.md, hooks and MCP
Does Cursor remember between chats? What happened to Cursor Memories, how rules, AGENTS.md and @Chats carry context, and how to add memory over MCP and hooks.
Share Cursor rules across a team and many repos
Share Cursor rules with your team: .cursor/rules in git, AGENTS.md, Team Rules, a team plugin marketplace, or synced files across repos. The tradeoffs.