Copy and paste this entire prompt to add mandatory Gemini CLI integration for large file analysis in Claude Code.
Please add the following mandatory rules to my CLAUDE.md configuration that force Claude to use Gemini CLI for analyzing large files:
## π¨ MANDATORY LARGE FILE ANALYSIS RULES
### CRITICAL: Gemini CLI Integration
**β STOP: These rules are MANDATORY and CANNOT be bypassed under ANY circumstances**
- **FIRST ACTION**: Before reading ANY file, ALWAYS check line count with `wc -l`
- **MANDATORY**: If file > 300 lines, you MUST use Gemini CLI - NO EXCEPTIONS
- **FORBIDDEN**: NEVER analyze large files yourself - ALWAYS delegate to Gemini
- **VIOLATION = FAILURE**: Ignoring these rules means immediate task failure
### Required Workflow for ALL File Operations
1. **CHECK FILE SIZE** (NO SKIPPING):
```fish
set line_count (wc -l < $file | string trim)
if test $line_count -gt 300
echo "β LARGE FILE DETECTED: $line_count lines"
echo "π¨ GEMINI ANALYSIS REQUIRED - DO NOT PROCEED WITHOUT IT"
end
-
FOR FILES > 300 LINES:
# MANDATORY - Run this BEFORE any analysis set output_file "gemini_analysis_$(date +%s).txt" gemini --model gemini-2.5-flash -y -a -p "Thoroughly analyze this file and identify all key components, functions, classes, and potential issues: $file. When you have completed this analysis, end your response with 'TASK COMPLETED'." > "$output_file" 2>&1 & # Monitor for completion while true if test -f "$output_file" && grep -q "TASK COMPLETED" "$output_file" echo "β Gemini analysis complete" break end sleep 2 end
-
WAIT FOR COMPLETION: Monitor log file until "TASK COMPLETED" appears
-
BASE ALL DECISIONS on Gemini's analysis, NOT your own reading
-
NEVER attempt to split files manually
-
ALWAYS use Gemini for file splitting with background execution:
# Run in background with completion monitoring set output_file "gemini_split_$(date +%s).txt" gemini -y -p "Split $file into logical components without breaking any functionality. Ensure all imports, exports, and dependencies remain intact. When you have completed this task, end your response with 'TASK COMPLETED'." > "$output_file" 2>&1 & # Monitor for completion echo "π Gemini is analyzing file structure..." while true if test -f "$output_file" && grep -q "TASK COMPLETED" "$output_file" echo "β File splitting plan complete!" cat "$output_file" break end echo "β³ Still working..." sleep 2 end
-
CSS-SPECIFIC EXAMPLE:
# For splitting CSS files set css_file "frontend/styles.css" set output_file "gemini_css_split_$(date +%s).txt" gemini -y -p "Split $css_file into separate CSS files based on: 1. Components (buttons.css, cards.css, forms.css, etc.) 2. Layout (grid.css, flexbox.css, spacing.css) 3. Utilities (colors.css, typography.css, animations.css) 4. Variables (variables.css for all CSS custom properties) 5. Base styles (reset.css, base.css) Requirements: - Preserve CSS cascade order and specificity - Create index.css that imports all files in correct order - Keep media queries with their related styles - Maintain all animations and keyframes intact - Ensure CSS variables remain in scope - Add comments explaining each file's purpose End your response with 'TASK COMPLETED' when done." > "$output_file" 2>&1 & # Monitor progress while true if test -f "$output_file" && grep -q "TASK COMPLETED" "$output_file" echo "β CSS splitting plan ready!" break end sleep 2 end
- Skipping Gemini analysis = Task marked as FAILED
- Manual file splitting = Task marked as FAILED
- Analyzing large files yourself = Task marked as FAILED
REMEMBER: I have noticed you missing important details in large files. This is why Gemini is MANDATORY.
## 2. Update the "Pre-Implementation Checks" section in "Code Implementation Workflow":
Find the "Pre-Implementation Checks" section and modify it to:
-
β MANDATORY FILE SIZE CHECK (MUST BE FIRST):
- Run
wc -l
on EVERY file before reading - If > 300 lines: STOP and use Gemini CLI
- NO EXCEPTIONS to this rule
- Run
-
Gemini Analysis for Large Files:
# THIS IS MANDATORY - NOT OPTIONAL set file_to_check "path/to/file" set line_count (wc -l < $file_to_check | string trim) if test $line_count -gt 300 echo "β STOP: File has $line_count lines - Gemini analysis REQUIRED" set output_file "gemini_check_$(date +%s).txt" # Run Gemini in background with completion indicator gemini --model gemini-2.5-flash -y -a -p "Analyze $file_to_check thoroughly. Identify all components, dependencies, potential issues, and structure. End with 'TASK COMPLETED'." > "$output_file" 2>&1 & # Monitor until complete echo "π Running mandatory Gemini analysis..." while true if test -f "$output_file" && grep -q "TASK COMPLETED" "$output_file" echo "β Analysis complete - proceed based on Gemini's findings" break end echo "β³ Analyzing..." sleep 2 end # DO NOT PROCEED until you read Gemini's analysis end
-
Verify Existing Implementation: Check if feature already exists
-
Understand Requirements: Ask clarifying questions
-
Plan Approach: Outline implementation strategy
## 3. Update the "Response Types" section:
-
Informational Requests:
- β CHECK FILE SIZE FIRST with
wc -l
- Use Gemini for files > 300 lines
- Provide explanations without code changes
- Use clear markdown formatting
- Reference existing implementations
- β CHECK FILE SIZE FIRST with
-
Implementation Requests:
- β MANDATORY: Run
/user:enforce-gemini-check [file]
FIRST - Proceed only with explicit action words: "add", "change", "update", "remove"
- Distinguish between questions and implementation requests
- Avoid duplicating existing features
- For large files: Base changes on Gemini's analysis ONLY
- β MANDATORY: Run
-
New Development:
- β If modifying files > 300 lines: Gemini analysis REQUIRED
- Brief, non-technical explanation of changes
- Single comprehensive code block
- Step-by-step implementation guide
- Complete, production-ready code
- Verify all imports and dependencies
- Concise summary of implementation
NEVER FORGET: Files > 300 lines require Gemini CLI analysis. This is MANDATORY.
## 4. Add reminders throughout the document:
- In "Quality Assurance": Add "**β LARGE FILE CHECK**: Always run `wc -l` before reviewing files" and "**β οΈ REMINDER**: Files > 300 lines = Gemini analysis MANDATORY"
- In "Documentation Standards": Add a "### β LARGE FILE WARNING" section stating "**BEFORE documenting ANY file**: Check line count with `wc -l`. Files > 300 lines require Gemini analysis."
- In "Code Review Guidelines": Add "### β MANDATORY: Large File Protocol" with steps for checking file sizes
- In "Legacy Code Guidelines": Add "**β LARGE FILE CHECK FIRST**: Run `wc -l` on legacy files"
## 5. Create this slash command at ~/.claude/commands/enforce-gemini-check.md:
```markdown
---
description: "Enforce Gemini CLI usage for large file analysis - MANDATORY check"
allowed-tools: ["Bash", "Read", "TodoWrite"]
---
# Enforce Gemini Check - MANDATORY for Large Files
This command enforces the MANDATORY requirement to use Gemini CLI for analyzing files larger than 300 lines.
## Usage
`/user:enforce-gemini-check [file_path]`
## Instructions
```fish
# Get the file path
set file_path "$ARGUMENTS"
if test -z "$file_path"
echo "β ERROR: File path required"
echo "Usage: /user:enforce-gemini-check [file_path]"
exit 1
end
# Check if file exists
if not test -f "$file_path"
echo "β ERROR: File not found: $file_path"
exit 1
end
# MANDATORY: Check file line count
set line_count (wc -l < "$file_path" | string trim)
echo "π File: $file_path"
echo "π Lines: $line_count"
# Enforce Gemini usage for large files
if test $line_count -gt 300
echo ""
echo "β STOP: LARGE FILE DETECTED!"
echo "π¨ GEMINI ANALYSIS IS MANDATORY - NO EXCEPTIONS"
echo ""
echo "Running Gemini analysis now..."
echo "ββββββββββββββββββββββββββββββββββββββββ"
# Create timestamp for output file
set timestamp (date +%Y%m%d_%H%M%S)
set output_file "gemini_analysis_$timestamp.txt"
# Run Gemini with comprehensive analysis prompt
set analysis_prompt "MANDATORY ANALYSIS REQUIRED: Thoroughly analyze the file '$file_path' which has $line_count lines. Provide:
1. Complete file structure overview
2. All functions, classes, and methods with their purposes
3. Key dependencies and imports
4. Potential issues or code smells
5. Suggestions for splitting if file is too large
6. Any security concerns
End with 'ANALYSIS COMPLETED' when done."
# Execute Gemini
gemini --model gemini-2.5-flash -y -a -p "$analysis_prompt" > "$output_file" 2>&1 &
set gemini_pid $last_pid
# Monitor progress
echo "β³ Analyzing with Gemini (PID: $gemini_pid)..."
sleep 3
# Wait for completion
set check_count 0
while true
if test -f "$output_file"
# Check if analysis is complete
if grep -q "ANALYSIS COMPLETED" "$output_file"
echo ""
echo "β
GEMINI ANALYSIS COMPLETE!"
echo "ββββββββββββββββββββββββββββββββββββββββ"
echo ""
echo "π Analysis saved to: $output_file"
echo ""
echo "β οΈ IMPORTANT: You MUST read and use this analysis."
echo "β οΈ DO NOT analyze the file yourself!"
echo "β οΈ Base ALL decisions on Gemini's analysis."
break
end
end
# Timeout after 5 minutes
set check_count (math $check_count + 1)
if test $check_count -gt 150
echo "β ERROR: Gemini analysis timed out"
kill $gemini_pid 2>/dev/null
exit 1
end
sleep 2
end
# Show summary
echo ""
echo "π SUMMARY:"
echo "- File: $file_path ($line_count lines)"
echo "- Status: Gemini analysis REQUIRED and COMPLETED"
echo "- Next: Use Gemini's analysis for ALL decisions"
else
echo ""
echo "β
File is under 300 lines ($line_count lines)"
echo "π Standard Claude analysis permitted"
end
echo ""
echo "π REMINDER: These rules are MANDATORY"
echo "- Files > 300 lines MUST use Gemini"
echo "- Manual analysis of large files is FORBIDDEN"
echo "- Violations = Task FAILURE"
- This command MUST be run before analyzing any file
- Skipping this check violates the mandatory rules
- Large files require Gemini analysis - NO EXCEPTIONS
- The 300-line threshold is non-negotiable
Make all these changes to enforce mandatory Gemini usage for large files. This is critical because I've noticed you missing important details in large files.