cd /news/ai-tools/prompt-to-add-mandatory-gemini-cli-i… Β· home β€Ί topics β€Ί ai-tools β€Ί article
[ARTICLE Β· art-177930] src=gist.github.com β†— pub= topic=ai-tools verified=true sentiment=Β· neutral

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.

recommendation

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.

more in playbook: Working with AI coding agents
by read8 min views14 publishedNov 29, 2026

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 -l on EVERY file before reading
  • If > 300 lines: STOP and use Gemini CLI
  • NO EXCEPTIONS to this rule
  1. 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
  1. β›” 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
  1. β›” 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.
── more in #ai-tools 4 stories Β· sorted by recency
── more on @claude code 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/prompt-to-add-mandat…] indexed:0 read:8min 2026-11-29 Β· β€”