Dispatch Gemini CLI to analyze large codebases. Gemini does the grunt work with its 1M token context; Claude gets distilled intel.
You are dispatching Gemini CLI as a subordinate tool to analyze code that would bloat your context window. Gemini does the heavy lifting; you receive distilled intelligence.
$ARGUMENTS
If no arguments provided, analyze current working directory.
which gemini || echo "ERROR: Gemini CLI not installed. Install: https://github.com/google-gemini/gemini-cli"
Before analysis, check if the project has any agent instruction files that Gemini should respect:
# Check for common agent config files
ls -la AGENTS.md GEMINI.md CLAUDE.md WARP.md COPILOT.md CURSOR.md CODEX.md README.md CONTRIBUTING.md .github/AGENTS.md .claude/CLAUDE.md 2>/dev/null
If found, inform the user:
@AGENTS.md etc. so Gemini respects the project conventionsModes:
| Pattern | Mode | Description |
|---|---|---|
/g-slave <path> |
Analyze | Full analysis of target |
/g-slave ask "<question>" |
Ask | Direct question about codebase |
/g-slave verify "<statement>" |
Verify | Yes/no verification check |
/g-slave compare <path1> <path2> |
Compare | Diff analysis between two targets |
Flags:
| Flag | Effect |
|---|---|
--arch |
Focus: Architecture, structure, design patterns |
--security |
Focus: Security vulnerabilities, auth, injection risks |
--deps |
Focus: Dependencies, imports, coupling analysis |
--quality |
Focus: Code quality, tech debt, antipatterns |
--test |
Focus: Test coverage, testing patterns, gaps |
--perf |
Focus: Performance bottlenecks, optimization opportunities |
--brief |
Output: ~500 char summary |
--detailed |
Output: ~5000 char comprehensive breakdown |
--raw |
Output: Unfiltered Gemini response (no distillation) |
--save <file> |
Export: Save analysis to specified file |
--exclude <patterns> |
Ignore: Comma-separated patterns (e.g., node_modules,dist,.git) |
--prompt "<custom>" |
Custom: Use provided prompt instead of default |
--all |
Scope: Use --all_files flag for entire project |
Always recommend excluding these token-wasters unless user specifically needs them:
node_modules/, vendor/, venv/, .venv/, __pycache__/.git/, .svn/, .hg/dist/, build/, out/, target/*.lock, *.log, coverage/Use the --exclude flag or advise user to add exclusions to their GEMINI.md.
CRITICAL: Gemini must operate in READ-ONLY mode. No code execution, no file modifications.
Add to all prompts: "IMPORTANT: This is a read-only analysis. Do not execute code or modify files."
gemini -p "@<path>/ IMPORTANT: Read-only analysis only. Analyze this codebase. Focus: <focus_area>. Provide: 1) Architecture overview 2) Key patterns 3) Notable issues 4) Recommendations. Be thorough but concise."
gemini -p "@<path>/ IMPORTANT: Read-only analysis only. <user_question> Provide a direct, specific answer with file paths and line references where applicable."
gemini -p "@<path>/ IMPORTANT: Read-only analysis only. Verify: <statement>. Answer with: YES/NO followed by evidence (file paths, code snippets) supporting your answer."
gemini -p "@<path1>/ @<path2>/ IMPORTANT: Read-only analysis only. Compare these two codebases/directories. Identify: 1) Structural differences 2) Logic changes 3) Added/removed features 4) Potential issues from changes."
gemini -p "@<path>/ IMPORTANT: Read-only analysis only. <custom_prompt>"
gemini --all_files -p "IMPORTANT: Read-only analysis only. <prompt>"
Before executing, quickly identify the stack and adjust analysis focus:
| Detected | Tailor Prompt To Include |
|---|---|
package.json |
React/Vue/Node patterns, npm security |
requirements.txt / pyproject.toml |
Django/Flask/FastAPI patterns, Python idioms |
Cargo.toml |
Rust ownership patterns, unsafe usage |
go.mod |
Go concurrency patterns, error handling |
composer.json |
Laravel/Symfony patterns, PHP security |
Gemfile |
Rails patterns, Ruby idioms |
pom.xml / build.gradle |
Spring patterns, Java architecture |
If --raw flag: Skip distillation, return full Gemini output.
Otherwise, extract and present based on verbosity:
--brief (~500 chars):
## Gemini Analysis: <target>
<3-4 sentence executive summary covering architecture, main issues, top recommendation>
Default (~2000 chars):
## Gemini Analysis: <target>
**Scope:** <what was analyzed>
**Focus:** <focus area or "general">
### Architecture
<concise 3-5 line summary>
### Key Patterns
- Pattern 1
- Pattern 2
### Issues (prioritized)
1. **High:** <critical issue>
2. **Medium:** <notable concern>
3. **Low:** <minor item>
### Recommendations
1. <actionable recommendation>
2. <actionable recommendation>
---
*Analysis via Gemini CLI (1M token context) | Distilled for Claude*
--detailed (~5000 chars): Include all of the above plus:
If --save <filename> provided:
# Example save
echo "<analysis_output>" > <filename>
## Answer: <question summary>
<direct answer>
**Evidence:**
- `path/to/file.py:42` - <relevant code/context>
- `path/to/other.js:17` - <relevant code/context>
---
*Via Gemini CLI | Read-only analysis*
## Verification: <statement>
**Result:** YES / NO / PARTIAL
**Evidence:**
- <supporting finding 1>
- <supporting finding 2>
**Location(s):** `file:line`, `file:line`
---
*Via Gemini CLI | Read-only analysis*
## Comparison: <path1> vs <path2>
### Structural Differences
- <difference 1>
- <difference 2>
### Logic Changes
- <change 1>
- <change 2>
### Added/Removed
| Added | Removed |
|-------|---------|
| <item> | <item> |
### Risk Assessment
<potential issues from changes>
---
*Via Gemini CLI | Read-only analysis*
| Error | Action |
|---|---|
| Gemini CLI not found | Provide install link: https://github.com/google-gemini/gemini-cli |
| Path doesn't exist | Report error, ask for correct path |
| Analysis timeout | Suggest narrower scope or --exclude patterns |
| Output too large | Summarize more aggressively (unless --raw) |
| Rate limited | Inform user, suggest waiting or reducing scope |
| Permission denied | Check file permissions, suggest alternatives |
# Basic analysis
/g-slave src/
# Direct question
/g-slave ask "Where is user authentication implemented?"
# Verification check
/g-slave verify "All API endpoints have rate limiting"
# Security audit with exclusions
/g-slave . --security --exclude node_modules,dist,coverage
# Compare branches (checkout both first)
/g-slave compare ./main-branch ./feature-branch
# Custom analysis saved to file
/g-slave . --prompt "Find all API endpoints and document their HTTP methods, parameters, and auth requirements" --save api-docs.md
# Quick overview
/g-slave . --brief
# Full deep-dive
/g-slave . --detailed --save full-analysis.md
# Raw Gemini output (no distillation)
/g-slave . --arch --raw