Providing context files to Gemini CLI is accomplished primarily through the @
symbol, which serves as the main interface for including file and directory content in your prompts. When you type @
followed by a file path or directory name, Gemini CLI reads the content of those resources and includes them as context for the AI model. For individual files, you can use @filename.js
or @src/components/Header.tsx
to include specific files in your conversation. For directories, you can use @src/
to include all files within a directory and its subdirectories, leveraging the tool’s git-aware filtering to automatically exclude irrelevant files like those listed in .gitignore.
The context management system is sophisticated and includes several advanced features to help you work with large codebases effectively. You can use the --include-all-files
flag to recursively include all files within the current directory as context, which is particularly useful when you need Gemini CLI to have complete awareness of your project structure. The tool provides context management commands like /context
to view currently loaded files, and you can compress context using the /compress
tool to replace detailed file contents with summaries when you’re approaching context limits. This is especially helpful when working with the 1 million token context window and need to balance comprehensive understanding with efficient token usage.
For more advanced context management, Gemini CLI supports project-specific configuration through GEMINI.md files, which provide persistent context that carries across sessions. These files can contain project-specific instructions, coding standards, architectural information, and context that helps the AI understand your specific development environment and requirements. You can also manage context through the emerging file context management system, which provides commands for listing active context files, checking context status, and removing or clearing files from context as needed. This comprehensive approach to context management ensures that you can provide exactly the right amount and type of information to get the most relevant and useful assistance from the AI, whether you’re working on small scripts or large enterprise applications.