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 :
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 &
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 3. 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:
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 &
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 :
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 &
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 -lon EVERY file before reading - If > 300 lines: STOP and use Gemini CLI
- NO EXCEPTIONS to this rule
- Run
Gemini Analysis for Large Files :
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"
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 &
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
end
Verify Existing Implementation : Check if feature already exists 5. Understand Requirements : Ask clarifying questions 6. 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"]
---
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
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
if not test -f "$file_path"
echo "β ERROR: File not found: $file_path"
exit 1
end
set line_count (wc -l < "$file_path" | string trim)
echo "π File: $file_path"
echo "π Lines: $line_count"
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 "ββββββββββββββββββββββββββββββββββββββββ"
set timestamp (date +%Y%m%d_%H%M%S)
set output_file "gemini_analysis_$timestamp.txt"
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."
gemini --model gemini-2.5-flash -y -a -p "$analysis_prompt" > "$output_file" 2>&1 &
set gemini_pid $last_pid
echo "β³ Analyzing with Gemini (PID: $gemini_pid)..."
sleep 3
set check_count 0
while true
if test -f "$output_file"
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
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
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.