Prompt to add mandatory Gemini CLI integration for large file analysis in Claude Code A developer published a copy-paste CLAUDE.md prompt that forces Claude Code to delegate analysis of any file over 300 lines to the Gemini CLI, using gemini-2.5-flash in background jobs that poll for a 'TASK COMPLETED' marker. The rules require a wc -l line-count check before reading any file and prohibit Claude from analyzing or manually splitting large files itself, with violations marked as task failures. The author says the setup addresses Claude missing important details in large files. 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 1. 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 2. 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: 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: 1. ⛔ 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 2. Run 3. 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 4. 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: 1. 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 2. ⛔ CHECK FILE SIZE FIRST with 3. 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 4. ⛔ MANDATORY: Run 5. 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.