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
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.
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.
Bash
/init
This makes it simpler to provide project-specific instructions to the Gemini agent.