Context for Gemini CLI
The Gemini CLI uses a hierarchical system to source context. It loads various context files from several locations, concatenates the contents, and sends them to the model with every prompt.
Official Documentation Gemini.md Documentation
Hierarchical Context Files
The CLI loads files in the following order:
- Global context file:
- Location:~/.gemini/GEMINI.md (in your user home directory).
- Scope: Provides default instructions for all your projects.
- Project root and ancestor context files:
- Location: The CLI searches for a GEMINI.md file in the current working directory and then in each parent directory up to the project root (identified by a .git folder).
- Scope: Provides context relevant to the entire project.
Refresh Context
If you edit a GEMINI.md file while a session is running, the agent will not detect the changes immediately.
To force a reload of the context, use the following command:
Bash
/memory refresh
The /init Command
To help users easily create a GEMINI.md file, the /init command analyzes the current directory and generates a tailored context file.
By executing the following command, Gemini CLI creates a project-specific context file.
Bash
/init
This makes it simpler to provide project-specific instructions to the Gemini agent.
To learn more about the /init command, visit the official documentation.