When analyzing large codebases or multiple files that might exceed context limits, use the Gemini CLI with its massive
context window. Use gemini -p
to leverage Google Gemini's large context capacity.
Use the @
syntax to include files and directories in your Gemini prompts. The paths should be relative to WHERE you run the
gemini command:
gemini -p "@package.json @src/index.js Analyze the dependencies used in the code"
gemini -p "@src/ @tests/ Analyze test coverage for the source code"
gemini -p "@./ Give me an overview of this entire project"
gemini --all_files -p "Analyze the project structure and dependencies"
Use gemini -p when:
- Analyzing entire codebases or large directories
- Comparing multiple large files
- Need to understand project-wide patterns or architecture
- Current context window is insufficient for the task
- Working with files totaling more than 100KB
- Verifying if specific features, patterns, or security measures are implemented
- Checking for the presence of certain coding patterns across the entire codebase
- Need second opinion when cannot immediately resovle some issue
IMPORTANT: For any substantial analysis, always redirect output to a file and run in background.
Why this is essential:
- Gemini analysis can take several minutes for large codebases
- Without redirection, you cannot see or save the results
- Background execution prevents blocking your terminal
- Need
2>&1
to capture both stdout and stderr in the output file
- Paths in @ syntax are relative to your current working directory when invoking gemini
- The CLI will include file contents directly in the context
- No need for --yolo flag for read-only analysis
- Gemini's context window can handle entire codebases that would overflow Claude's context
- When checking implementations, be specific about what you're looking for to get accurate results
- ALWAYS use output redirection - the analysis is useless if you can't read the results
- Always run tests with output to file so that you can grep it later
- Saving test outputs allows you to easily diff between different test runs