docs/cli/tutorials/memory-management.md
Control what Gemini CLI knows about you and your projects. In this guide, you'll
learn how to define project-wide rules with GEMINI.md, teach the agent
persistent facts, and inspect the active context.
Gemini CLI is powerful but general. It doesn't know your preferred testing
framework, your indentation style, or your preference against any in
TypeScript. Context management solves this by giving the agent persistent
memory.
You'll use these features when you want to:
The most powerful way to control the agent's behavior is through GEMINI.md
files. These are Markdown files containing instructions that are automatically
loaded into every conversation.
In the root of your project, create a file named GEMINI.md.
Add your instructions:
# Project Instructions
- **Framework:** We use React with Vite.
- **Styling:** Use Tailwind CSS for all styling. Do not write custom CSS.
- **Testing:** All new components must include a Vitest unit test.
- **Tone:** Be concise. Don't explain basic React concepts.
Start a new session. Gemini CLI will now know these rules automatically.
Context is loaded hierarchically. This lets you have general rules for everything and specific rules for sub-projects.
~/.gemini/GEMINI.md (Rules for every project you work on)../GEMINI.md (Rules for the current repository)../src/GEMINI.md (Rules specific to the src folder).Example: You might set "Always use strict typing" in your global config, but "Use Python 3.11" only in your backend repository.
Sometimes you don't want to write a config file. You just want to tell the agent something once and have it remember forever. You can do this naturally in chat.
Just tell the agent to remember something.
Prompt: Remember that I prefer using 'const' over 'let' wherever possible.
The agent will use the save_memory tool to store this fact in your global
memory file.
Prompt: Save the fact that the staging server IP is 10.0.0.5.
Once a fact is saved, you don't need to invoke it explicitly. The agent "knows" it.
Next Prompt: Write a script to deploy to staging.
Agent Response: "I'll write a script to deploy to 10.0.0.5..."
As your project grows, you might want to see exactly what instructions the agent is following.
To see the full, concatenated set of instructions currently loaded (from all
GEMINI.md files and saved memories), use the /memory show command.
Command: /memory show
This prints the raw text the model receives at the start of the session. It's excellent for debugging why the agent might be ignoring a rule.
If you edit a GEMINI.md file while a session is running, the agent won't know
immediately. Force a reload with:
Command: /memory reload
GEMINI.md. Keep
instructions actionable and relevant to code generation.GEMINI.md files to remove outdated
rules./memory options.