Skip to content

Instantly share code, notes, and snippets.

@arunsanna
Created July 10, 2025 22:08
Show Gist options
  • Save arunsanna/d83c50ee5dd956b51f2c7e65221ff8ea to your computer and use it in GitHub Desktop.
Save arunsanna/d83c50ee5dd956b51f2c7e65221ff8ea to your computer and use it in GitHub Desktop.
Prompt to add mandatory Gemini CLI integration for large file analysis in Claude Code

Claude Code + Gemini CLI Integration Prompt

Copy and paste this entire prompt to add mandatory Gemini CLI integration for large file analysis in Claude Code.


Prompt: Add Mandatory Gemini CLI Integration for Large Files

Please add the following mandatory rules to my CLAUDE.md configuration that force Claude to use Gemini CLI for analyzing large files:

1. Add this section right after "Privacy Rules" in CLAUDE.md:

## 🚨 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

File Splitting Rules

  • 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

Penalties for Non-Compliance

  • 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:

Pre-Implementation Checks

  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. 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
  3. Verify Existing Implementation: Check if feature already exists

  4. Understand Requirements: Ask clarifying questions

  5. Plan Approach: Outline implementation strategy


## 3. Update the "Response Types" section:

Response Types

  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. 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
  3. 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

⚠️ LARGE FILE REMINDER

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"

Important Notes

  • 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment