Intelligent consultation orchestrator that leverages Google Gemini's CLI for analyzing codebases exceeding typical context limitations.
This skill inherits all available tools. When active, it can use any tool Claude has access to.
Intelligent consultation orchestrator that leverages Google Gemini's CLI for analyzing codebases exceeding typical context limitations.
Bridge the gap between context-constrained AI assistants and comprehensive codebase understanding by orchestrating strategic use of Google Gemini's expanded context window.
Problem it solves:
Solution approach:
Trigger Conditions (Auto-recommend):
The skill should activate when:
User Explicit Triggers:
When NOT to use:
Objective: Determine if Gemini consultation is appropriate and construct optimal query strategy.
Assessment Checklist:
assessment = {
scope_size: estimate_file_count_and_size(),
analysis_type: identify_analysis_category(),
context_available: check_current_session_context(),
query_complexity: evaluate_question_depth()
}
recommendation = {
use_gemini: scope_size > threshold || analysis_type in ['architecture', 'security_audit', 'cross_project'],
query_strategy: construct_query_plan(),
expected_value: estimate_insight_gain()
}
User Interaction:
Present recommendation clearly:
"This analysis requires examining [N files / X MB] across [scope]. I recommend using Gemini CLI because [reason].
I'll construct a query that:
Proceed with Gemini consultation? [Yes / Adjust scope / Use Claude Code only]"
Query Construction Strategy:
Based on analysis type, determine optimal @ syntax pattern:
Full Project Analysis:
gemini --all_files -p "Analyze complete project architecture"
Directory-Scoped Analysis:
gemini -p "@src/ @tests/ Compare implementation vs test coverage"
Multi-File Comparison:
gemini -p "@src/auth/login.js @src/auth/register.js @src/middleware/auth.js Analyze authentication flow consistency"
Targeted Pattern Search:
gemini -p "@src/**/*.js Find all error handling patterns and identify inconsistencies"
Objective: Execute Gemini CLI query and capture comprehensive output.
Execution Protocol:
Construct Command:
gemini_command = build_query(
scope: assessment.scope,
prompt: refined_user_question,
flags: determine_flags()
)
Execute with Monitoring:
# Execute via Bash tool
result = bash_execute(gemini_command, timeout=120)
# Monitor for:
# - CLI availability (is gemini installed?)
# - Authentication status (logged in?)
# - Rate limiting (hit quota?)
# - Error messages
Capture Output:
Error Handling:
if (error.type === 'CLI_NOT_FOUND') {
return {
status: 'blocked',
message: "Gemini CLI not installed. Install: npm install -g @google/generative-ai",
fallback: "Use Claude Code tools for subset analysis?"
}
}
if (error.type === 'AUTH_REQUIRED') {
return {
status: 'blocked',
message: "Gemini CLI requires authentication. Run: gemini auth login",
fallback: null
}
}
if (error.type === 'RATE_LIMIT') {
return {
status: 'retry',
message: "Gemini API rate limit reached. Retry in [time] or reduce scope?",
fallback: "Split analysis into smaller chunks?"
}
}
if (error.type === 'CONTEXT_OVERFLOW') {
return {
status: 'adjust',
message: "Even Gemini's context exceeded. Analysis scope too large.",
strategy: "Split into multiple focused queries with specific file patterns"
}
}
Objective: Transform Gemini's output into actionable insights for Claude Code workflow.
Synthesis Process:
Parse Gemini Response:
Contextualize for Current Session:
## Gemini Consultation Results
**Query:** [original question]
**Scope:** [files/directories analyzed]
**Key Findings:**
1. [Finding with file:line references]
2. [Finding with architectural implications]
3. [Finding with security considerations]
**Recommendations:**
- [Actionable item 1]
- [Actionable item 2]
**Follow-up Actions:**
- [ ] Review identified files in Claude Code
- [ ] Implement suggested changes
- [ ] Verify with local testing
Store in Cipher (Memory):
cipher_store("Gemini Consultation - [Topic]
Analysis Type: [architecture/security/feature/pattern]
Scope: [file patterns]
Date: [timestamp]
Key Insights:
- [Insight 1 with file references]
- [Insight 2 with implications]
Recommended Actions:
- [Action 1]
- [Action 2]
Query Pattern Used:
```bash
[gemini command]
Results archived for future reference.")
Present to User:
Clear, structured output:
"✅ Gemini Analysis Complete
Analyzed: [N files across M directories]
Critical Findings:
[Category]: [Finding]
src/file1.js:45, src/file2.js:89[Category]: [Finding] ...
Next Steps:
I've stored these insights in Cipher for future reference. Would you like me to:
A) Deep dive into specific finding [#1, #2, etc.] B) Implement recommended changes C) Run focused analysis on subset D) Continue with different question"
Trigger Patterns:
Query Construction:
gemini --all_files -p "Analyze the complete architecture:
1. Identify main components and their responsibilities
2. Map data flow between modules
3. Describe architectural patterns used
4. Note any architectural inconsistencies
5. Highlight coupling and dependency issues"
Synthesis Focus:
Trigger Patterns:
Query Construction:
gemini -p "@src/ @lib/ Perform security audit:
1. Identify potential SQL injection points
2. Check for XSS vulnerabilities
3. Verify authentication implementation
4. Review authorization logic
5. Check for exposed secrets or credentials
6. Assess input validation coverage"
Synthesis Focus:
Trigger Patterns:
Query Construction:
gemini -p "@src/ Verify [feature] implementation:
1. Locate all files implementing this feature
2. Trace the complete execution flow
3. Identify edge cases handled
4. Check for test coverage
5. Note any incomplete or inconsistent implementations"
Synthesis Focus:
Trigger Patterns:
Query Construction:
gemini -p "@src/**/*.js Analyze [pattern] usage:
1. Find all instances of this pattern
2. Compare implementations for consistency
3. Identify outliers or anti-patterns
4. Suggest standardization approach"
Synthesis Focus:
Trigger Patterns:
Query Construction:
# Note: Requires sequential queries or multi-repo setup
gemini -p "@project1/src/ Analyze [aspect] implementation"
gemini -p "@project2/src/ Analyze same [aspect] implementation"
# Then ask Gemini to compare the two analyses
Synthesis Focus:
Be Specific:
Scope Appropriately:
gemini --all_files -p "Fix bug" (too broad)gemini -p "@src/auth/ @tests/auth/ Identify why session timeout isn't working"Use Numbered Questions:
Include Expected Deliverables:
gemini -p "@src/ Analyze error handling. Provide:
1. List of all error types caught
2. Consistency analysis across modules
3. Gaps in error coverage
4. Recommendation for standardization"
When to Chain Queries:
Instead of one massive query, use sequential focused queries:
# Query 1: Discovery
gemini -p "@src/ Identify all database access patterns"
# Query 2: Deep Dive (based on Query 1 findings)
gemini -p "@src/models/ @src/repositories/ Analyze ORM usage consistency"
# Query 3: Verification
gemini -p "@tests/ Verify test coverage for identified DB patterns"
Benefits:
Workflow Pattern:
1. User asks broad question in Claude Code
2. Claude recognizes scope exceeds context
3. Gemini Consult skill activates
4. Execute Gemini query
5. Synthesize findings
6. Store in Cipher
7. Continue in Claude Code with specific file work
Example:
User: "I want to refactor our authentication system for better security"
Claude (recognizes large scope):
→ Activates Gemini Consult
→ Runs: gemini -p "@src/auth/ @middleware/ Analyze authentication architecture..."
→ Receives comprehensive analysis
→ Stores in Cipher
→ Responds: "Based on Gemini analysis, here are 5 critical areas..."
User: "Start with #1 - JWT token handling"
Claude (now focused):
→ Uses Read tool for specific files identified by Gemini
→ Implements changes using normal Claude Code workflow
→ References Gemini insights from Cipher as needed
Before any query:
# Check if gemini CLI is available
which gemini || echo "NOT_FOUND"
If not found:
Check auth status:
gemini auth status
If not authenticated:
If Gemini returns context overflow:
overflow_strategy = {
approach: "Divide and Conquer",
steps: [
"Split scope into logical chunks (by directory, feature, module)",
"Run multiple focused queries",
"Synthesize results client-side",
"Present unified findings"
],
example: {
original: "gemini --all_files -p 'Analyze everything'",
split: [
"gemini -p '@src/frontend/ Analyze frontend architecture'",
"gemini -p '@src/backend/ Analyze backend architecture'",
"gemini -p '@src/shared/ Analyze shared utilities'",
// Then synthesize findings
]
}
}
Validate Gemini output before presenting:
validation_checks = {
// Gemini hallucination check
file_references_exist: verify_files_exist(gemini_response.mentioned_files),
// Response completeness
addresses_all_query_points: check_numbered_questions_answered(),
// Actionability
has_specific_recommendations: !is_vague(gemini_response.recommendations),
// Confidence indicators
notes_uncertainties: gemini_response.includes("not sure", "possibly", "might")
}
if (!validation_checks.all_pass) {
refine_query_and_retry_OR_flag_to_user();
}
gemini_consult_state = {
active_consultation: boolean,
current_phase: 1 | 2 | 3,
assessment: {
scope: {...},
strategy: {...},
user_approved: boolean
},
execution: {
command: string,
status: 'pending' | 'running' | 'complete' | 'error',
output: string,
errors: []
},
synthesis: {
findings: [],
recommendations: [],
follow_up_actions: [],
stored_in_cipher: boolean
}
}
Store in Cipher after every successful consultation:
Retrieve from Cipher when:
Gemini for Breadth, Claude for Depth: Use Gemini to understand the forest, Claude Code to work on specific trees
Always Validate Scope: Don't waste Gemini queries on small scopes Claude Code handles efficiently
Synthesize, Don't Dump: Transform Gemini's output into actionable Claude Code workflow steps
Store Knowledge: Gemini insights go into Cipher for long-term memory
Progressive Refinement: Start broad, narrow down based on findings
User in Control: Always ask permission before executing Gemini queries (they may have quota concerns)
Graceful Fallback: If Gemini unavailable, offer Claude Code alternatives (subset analysis, iterative exploration)
Planned Features:
Current: Specification complete Next: Implement Phase 1 (Query Assessment) Future: Full 3-phase workflow, error handling, Cipher integration