{"slug": "prompt-to-add-mandatory-gemini-cli-integration-for-large-file-analysis-in-claude", "title": "Prompt to add mandatory Gemini CLI integration for large file analysis in Claude Code", "summary": "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.", "body_md": "Copy and paste this entire prompt to add mandatory Gemini CLI integration for large file analysis in Claude Code.\n\nPlease add the following mandatory rules to my CLAUDE.md configuration that force Claude to use Gemini CLI for analyzing large files:\n\n```\n## 🚨 MANDATORY LARGE FILE ANALYSIS RULES\n\n### CRITICAL: Gemini CLI Integration\n**⛔ STOP: These rules are MANDATORY and CANNOT be bypassed under ANY circumstances**\n\n- **FIRST ACTION**: Before reading ANY file, ALWAYS check line count with `wc -l`\n- **MANDATORY**: If file > 300 lines, you MUST use Gemini CLI - NO EXCEPTIONS\n- **FORBIDDEN**: NEVER analyze large files yourself - ALWAYS delegate to Gemini\n- **VIOLATION = FAILURE**: Ignoring these rules means immediate task failure\n\n### Required Workflow for ALL File Operations\n1. **CHECK FILE SIZE** (NO SKIPPING):\n   ``` fish\n   set line_count (wc -l < $file | string trim)\n   if test $line_count -gt 300\n       echo \"⛔ LARGE FILE DETECTED: $line_count lines\"\n       echo \"🚨 GEMINI ANALYSIS REQUIRED - DO NOT PROCEED WITHOUT IT\"\n   end\n```\n\n1. \n**FOR FILES > 300 LINES** :\n\n```\n# MANDATORY - Run this BEFORE any analysis\nset output_file \"gemini_analysis_$(date +%s).txt\"\ngemini --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 &\n\n# Monitor for completion\nwhile true\n    if test -f \"$output_file\" && grep -q \"TASK COMPLETED\" \"$output_file\"\n        echo \"✅ Gemini analysis complete\"\n        break\n    end\n    sleep 2\nend\n```\n\n2. \n**WAIT FOR COMPLETION** : Monitor log file until \"TASK COMPLETED\" appears\n3. \n**BASE ALL DECISIONS** on Gemini's analysis, NOT your own reading\n\n- \n**NEVER** attempt to split files manually\n- \n**ALWAYS** use Gemini for file splitting with background execution:\n\n```\n# Run in background with completion monitoring\nset output_file \"gemini_split_$(date +%s).txt\"\ngemini -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 &\n\n# Monitor for completion\necho \"🔄 Gemini is analyzing file structure...\"\nwhile true\n    if test -f \"$output_file\" && grep -q \"TASK COMPLETED\" \"$output_file\"\n        echo \"✅ File splitting plan complete!\"\n        cat \"$output_file\"\n        break\n    end\n    echo \"⏳ Still working...\"\n    sleep 2\nend\n```\n\n- \n**CSS-SPECIFIC EXAMPLE** :\n\n```\n# For splitting CSS files\nset css_file \"frontend/styles.css\"\nset output_file \"gemini_css_split_$(date +%s).txt\"\n\ngemini -y -p \"Split $css_file into separate CSS files based on:\n1. Components (buttons.css, cards.css, forms.css, etc.)\n2. Layout (grid.css, flexbox.css, spacing.css)\n3. Utilities (colors.css, typography.css, animations.css)\n4. Variables (variables.css for all CSS custom properties)\n5. Base styles (reset.css, base.css)\n\nRequirements:\n- Preserve CSS cascade order and specificity\n- Create index.css that imports all files in correct order\n- Keep media queries with their related styles\n- Maintain all animations and keyframes intact\n- Ensure CSS variables remain in scope\n- Add comments explaining each file's purpose\n\nEnd your response with 'TASK COMPLETED' when done.\" > \"$output_file\" 2>&1 &\n\n# Monitor progress\nwhile true\n    if test -f \"$output_file\" && grep -q \"TASK COMPLETED\" \"$output_file\"\n        echo \"✅ CSS splitting plan ready!\"\n        break\n    end\n    sleep 2\nend\n```\n\n- Skipping Gemini analysis = Task marked as FAILED\n- Manual file splitting = Task marked as FAILED\n- Analyzing large files yourself = Task marked as FAILED\n\n**REMEMBER**: I have noticed you missing important details in large files. This is why Gemini is MANDATORY.\n\n```\n## 2. Update the \"Pre-Implementation Checks\" section in \"Code Implementation Workflow\":\n\nFind the \"Pre-Implementation Checks\" section and modify it to:\n```\n\n1. \n**⛔ MANDATORY FILE SIZE CHECK** (MUST BE FIRST):\n  - Run `wc -l` on EVERY file before reading\n  - If > 300 lines: STOP and use Gemini CLI\n  - NO EXCEPTIONS to this rule\n2. Run \n3. \n**Gemini Analysis for Large Files** :\n\n```\n# THIS IS MANDATORY - NOT OPTIONAL\nset file_to_check \"path/to/file\"\nset line_count (wc -l < $file_to_check | string trim)\n\nif test $line_count -gt 300\n    echo \"⛔ STOP: File has $line_count lines - Gemini analysis REQUIRED\"\n    set output_file \"gemini_check_$(date +%s).txt\"\n    \n    # Run Gemini in background with completion indicator\n    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 &\n    \n    # Monitor until complete\n    echo \"🔄 Running mandatory Gemini analysis...\"\n    while true\n        if test -f \"$output_file\" && grep -q \"TASK COMPLETED\" \"$output_file\"\n            echo \"✅ Analysis complete - proceed based on Gemini's findings\"\n            break\n        end\n        echo \"⏳ Analyzing...\"\n        sleep 2\n    end\n    \n    # DO NOT PROCEED until you read Gemini's analysis\nend\n```\n\n4. \n**Verify Existing Implementation** : Check if feature already exists\n5. \n**Understand Requirements** : Ask clarifying questions\n6. \n**Plan Approach** : Outline implementation strategy\n\n```\n## 3. Update the \"Response Types\" section:\n```\n\n1. \n**Informational Requests** :\n  - ⛔ CHECK FILE SIZE FIRST with `wc -l`\n  - Use Gemini for files > 300 lines\n  - Provide explanations without code changes\n  - Use clear markdown formatting\n  - Reference existing implementations\n2. ⛔ CHECK FILE SIZE FIRST with \n3. \n**Implementation Requests** :\n  - ⛔ MANDATORY: Run `/user:enforce-gemini-check [file]` FIRST\n  - Proceed only with explicit action words: \"add\", \"change\", \"update\", \"remove\"\n  - Distinguish between questions and implementation requests\n  - Avoid duplicating existing features\n  - For large files: Base changes on Gemini's analysis ONLY\n4. ⛔ MANDATORY: Run \n5. \n**New Development** :\n  - ⛔ If modifying files > 300 lines: Gemini analysis REQUIRED\n  - Brief, non-technical explanation of changes\n  - Single comprehensive code block\n  - Step-by-step implementation guide\n  - Complete, production-ready code\n  - Verify all imports and dependencies\n  - Concise summary of implementation\n\n**NEVER FORGET**: Files > 300 lines require Gemini CLI analysis. This is MANDATORY.\n\n```\n## 4. Add reminders throughout the document:\n\n- In \"Quality Assurance\": Add \"**⛔ LARGE FILE CHECK**: Always run `wc -l` before reviewing files\" and \"**⚠️ REMINDER**: Files > 300 lines = Gemini analysis MANDATORY\"\n- 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.\"\n- In \"Code Review Guidelines\": Add \"### ⛔ MANDATORY: Large File Protocol\" with steps for checking file sizes\n- In \"Legacy Code Guidelines\": Add \"**⛔ LARGE FILE CHECK FIRST**: Run `wc -l` on legacy files\"\n\n## 5. Create this slash command at ~/.claude/commands/enforce-gemini-check.md:\n\n``` markdown\n---\ndescription: \"Enforce Gemini CLI usage for large file analysis - MANDATORY check\"\nallowed-tools: [\"Bash\", \"Read\", \"TodoWrite\"]\n---\n\n# Enforce Gemini Check - MANDATORY for Large Files\n\nThis command enforces the MANDATORY requirement to use Gemini CLI for analyzing files larger than 300 lines.\n\n## Usage\n\n`/user:enforce-gemini-check [file_path]`\n\n## Instructions\n\n``` fish\n# Get the file path\nset file_path \"$ARGUMENTS\"\n\nif test -z \"$file_path\"\n    echo \"❌ ERROR: File path required\"\n    echo \"Usage: /user:enforce-gemini-check [file_path]\"\n    exit 1\nend\n\n# Check if file exists\nif not test -f \"$file_path\"\n    echo \"❌ ERROR: File not found: $file_path\"\n    exit 1\nend\n\n# MANDATORY: Check file line count\nset line_count (wc -l < \"$file_path\" | string trim)\necho \"📊 File: $file_path\"\necho \"📏 Lines: $line_count\"\n\n# Enforce Gemini usage for large files\nif test $line_count -gt 300\n    echo \"\"\n    echo \"⛔ STOP: LARGE FILE DETECTED!\"\n    echo \"🚨 GEMINI ANALYSIS IS MANDATORY - NO EXCEPTIONS\"\n    echo \"\"\n    echo \"Running Gemini analysis now...\"\n    echo \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\"\n    \n    # Create timestamp for output file\n    set timestamp (date +%Y%m%d_%H%M%S)\n    set output_file \"gemini_analysis_$timestamp.txt\"\n    \n    # Run Gemini with comprehensive analysis prompt\n    set analysis_prompt \"MANDATORY ANALYSIS REQUIRED: Thoroughly analyze the file '$file_path' which has $line_count lines. Provide:\n1. Complete file structure overview\n2. All functions, classes, and methods with their purposes\n3. Key dependencies and imports\n4. Potential issues or code smells\n5. Suggestions for splitting if file is too large\n6. Any security concerns\nEnd with 'ANALYSIS COMPLETED' when done.\"\n    \n    # Execute Gemini\n    gemini --model gemini-2.5-flash -y -a -p \"$analysis_prompt\" > \"$output_file\" 2>&1 &\n    set gemini_pid $last_pid\n    \n    # Monitor progress\n    echo \"⏳ Analyzing with Gemini (PID: $gemini_pid)...\"\n    sleep 3\n    \n    # Wait for completion\n    set check_count 0\n    while true\n        if test -f \"$output_file\"\n            # Check if analysis is complete\n            if grep -q \"ANALYSIS COMPLETED\" \"$output_file\"\n                echo \"\"\n                echo \"✅ GEMINI ANALYSIS COMPLETE!\"\n                echo \"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\"\n                echo \"\"\n                echo \"📄 Analysis saved to: $output_file\"\n                echo \"\"\n                echo \"⚠️  IMPORTANT: You MUST read and use this analysis.\"\n                echo \"⚠️  DO NOT analyze the file yourself!\"\n                echo \"⚠️  Base ALL decisions on Gemini's analysis.\"\n                break\n            end\n        end\n        \n        # Timeout after 5 minutes\n        set check_count (math $check_count + 1)\n        if test $check_count -gt 150\n            echo \"❌ ERROR: Gemini analysis timed out\"\n            kill $gemini_pid 2>/dev/null\n            exit 1\n        end\n        \n        sleep 2\n    end\n    \n    # Show summary\n    echo \"\"\n    echo \"📊 SUMMARY:\"\n    echo \"- File: $file_path ($line_count lines)\"\n    echo \"- Status: Gemini analysis REQUIRED and COMPLETED\"\n    echo \"- Next: Use Gemini's analysis for ALL decisions\"\n    \nelse\n    echo \"\"\n    echo \"✅ File is under 300 lines ($line_count lines)\"\n    echo \"📝 Standard Claude analysis permitted\"\nend\n\necho \"\"\necho \"🔒 REMINDER: These rules are MANDATORY\"\necho \"- Files > 300 lines MUST use Gemini\"\necho \"- Manual analysis of large files is FORBIDDEN\"\necho \"- Violations = Task FAILURE\"\n```\n\n- This command MUST be run before analyzing any file\n- Skipping this check violates the mandatory rules\n- Large files require Gemini analysis - NO EXCEPTIONS\n- The 300-line threshold is non-negotiable\n\n```\nMake 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.\n```\n\n", "url": "https://wpnews.pro/news/prompt-to-add-mandatory-gemini-cli-integration-for-large-file-analysis-in-claude", "canonical_source": "https://gist.github.com/newshap69-carmina/50f65a67db091fc886e1eed767db354f", "published_at": "2026-11-29 00:40:09+00:00", "updated_at": "2026-11-29 00:42:41.550817+00:00", "lang": "en", "topics": ["ai-tools", "ai-agents", "developer-tools", "large-language-models"], "entities": ["Claude Code", "Gemini CLI", "Anthropic", "Google", "gemini-2.5-flash"], "also_reported_by": [], "takeaway": "Routing files over 300 lines to a separate Gemini CLI call, run in the background and polled for a 'TASK COMPLETED' marker, keeps Claude Code from missing details in large files, per the author's CLAUDE.md rules.", "recommendation": {"advice": "Add a CLAUDE.md rule that checks line counts with wc -l and delegates files over 300 lines to Gemini CLI in the background, polling for a completion marker before acting.", "playbook": "coding-agents", "playbook_url": "https://wpnews.pro/playbooks/coding-agents"}, "alternates": {"html": "https://wpnews.pro/news/prompt-to-add-mandatory-gemini-cli-integration-for-large-file-analysis-in-claude", "markdown": "https://wpnews.pro/news/prompt-to-add-mandatory-gemini-cli-integration-for-large-file-analysis-in-claude.md", "text": "https://wpnews.pro/news/prompt-to-add-mandatory-gemini-cli-integration-for-large-file-analysis-in-claude.txt", "jsonld": "https://wpnews.pro/news/prompt-to-add-mandatory-gemini-cli-integration-for-large-file-analysis-in-claude.jsonld"}}