GC-101 · Module 4
Code Reviews & Codebase Investigation
3 min read
Gemini CLI includes a built-in codebase_investigator agent tool — a specialized sub-agent designed to explore and understand codebases. When you ask Gemini to analyze your codebase architecture, trace data flows, or understand dependencies, it can delegate to the codebase investigator for deep analysis. This is more thorough than simple file reads because the investigator follows references, maps relationships, and builds a holistic understanding.
# Let Gemini investigate your codebase
"Trace the request lifecycle from the API route to the database query"
"Map all the dependencies of the AuthService module"
"Find all places where user permissions are checked"
# Custom review command
/review @src/auth/ "Focus on OWASP top 10 vulnerabilities"
PR reviews are a natural fit for Gemini CLI. Create a custom /review command that analyzes diffs against your team's standards. The 1M context window is a real advantage here — you can load the full PR diff alongside relevant test files, documentation, and coding standards without hitting context limits. The review catches logical errors, security issues, and style violations that humans often miss in large PRs.
Documentation generation is another high-value workflow. Point Gemini at a module with no docs and ask it to generate JSDoc comments, README sections, or architecture decision records. The codebase investigator ensures Gemini understands the code deeply before documenting it — not just surface-level function signatures but actual behavior, edge cases, and design intent.
Do This
- Use the codebase investigator for deep analysis — architecture, dependencies, flows
- Build custom /review commands tailored to your team's standards
- Generate documentation from code — let Gemini read the implementation and explain it
Avoid This
- Manually grep through files when the investigator can trace relationships for you
- Use generic prompts like "review this code" without specifying what to look for
- Write documentation by hand when Gemini can draft it from actual code behavior