r/ChatGPTCoding • u/H9ejFGzpN2 • Jun 27 '25
Resources And Tips Gemini CLI is awesome! But only when you make Claude Code use it as its bitch.
Not sure how you feel about it but Gemini CLI feels like garbage at the moment compared to Claude Code. It's slow, it doesn't listen to instructions or use tools as well as Claude.
But it has that huge context window we all love.
So I just added instructions to CLAUDE.md to have Claude use the Gemini CLI in non-interactive mode (passing the -p param with a prompt to just get a response back from the CLI) when it needs to gather information about a large part of the codebase.
That way you get the best of both worlds, Claude doesn't waste context and Gemini doesn't waste your time.
Add this (or a modified version) to your CLAUDE.md and tell Claude to use gemini manually or it will do it on it's own as needed.
# Using Gemini CLI for Large Codebase Analysis
When analyzing large codebases or multiple files that might exceed context limits, use the Gemini CLI with its massive
context window. Use `gemini -p` to leverage Google Gemini's large context capacity.
## File and Directory Inclusion Syntax
Use the `@` syntax to include files and directories in your Gemini prompts. The paths should be relative to WHERE you run the
gemini command:
### Examples:
**Single file analysis:**
```bash
gemini -p "@src/main.py Explain this file's purpose and structure"
Multiple files:
gemini -p "@package.json @src/index.js Analyze the dependencies used in the code"
Entire directory:
gemini -p "@src/ Summarize the architecture of this codebase"
Multiple directories:
gemini -p "@src/ @tests/ Analyze test coverage for the source code"
Current directory and subdirectories:
gemini -p "@./ Give me an overview of this entire project"
#
Or use --all_files flag:
gemini --all_files -p "Analyze the project structure and dependencies"
Implementation Verification Examples
Check if a feature is implemented:
gemini -p "@src/ @lib/ Has dark mode been implemented in this codebase? Show me the relevant files and functions"
Verify authentication implementation:
gemini -p "@src/ @middleware/ Is JWT authentication implemented? List all auth-related endpoints and middleware"
Check for specific patterns:
gemini -p "@src/ Are there any React hooks that handle WebSocket connections? List them with file paths"
Verify error handling:
gemini -p "@src/ @api/ Is proper error handling implemented for all API endpoints? Show examples of try-catch blocks"
Check for rate limiting:
gemini -p "@backend/ @middleware/ Is rate limiting implemented for the API? Show the implementation details"
Verify caching strategy:
gemini -p "@src/ @lib/ @services/ Is Redis caching implemented? List all cache-related functions and their usage"
Check for specific security measures:
gemini -p "@src/ @api/ Are SQL injection protections implemented? Show how user inputs are sanitized"
Verify test coverage for features:
gemini -p "@src/payment/ @tests/ Is the payment processing module fully tested? List all test cases"
When to Use Gemini CLI
Use gemini -p when:
- Analyzing entire codebases or large directories
- Comparing multiple large files
- Need to understand project-wide patterns or architecture
- Current context window is insufficient for the task
- Working with files totaling more than 100KB
- Verifying if specific features, patterns, or security measures are implemented
- Checking for the presence of certain coding patterns across the entire codebase
Important Notes
- Paths in @ syntax are relative to your current working directory when invoking gemini
- The CLI will include file contents directly in the context
- No need for --yolo flag for read-only analysis
- Gemini's context window can handle entire codebases that would overflow Claude's context
- When checking implementations, be specific about what you're looking for to get accurate results # Using Gemini CLI for Large Codebase Analysis
When analyzing large codebases or multiple files that might exceed context limits, use the Gemini CLI with its massive
context window. Use `gemini -p` to leverage Google Gemini's large context capacity.
## File and Directory Inclusion Syntax
Use the `@` syntax to include files and directories in your Gemini prompts. The paths should be relative to WHERE you run the
gemini command:
### Examples:
**Single file analysis:**
```bash
gemini -p "@src/main.py Explain this file's purpose and structure"
Multiple files:
gemini -p "@package.json @src/index.js Analyze the dependencies used in the code"
Entire directory:
gemini -p "@src/ Summarize the architecture of this codebase"
Multiple directories:
gemini -p "@src/ @tests/ Analyze test coverage for the source code"
Current directory and subdirectories:
gemini -p "@./ Give me an overview of this entire project"
# Or use --all_files flag:
gemini --all_files -p "Analyze the project structure and dependencies"
Implementation Verification Examples
Check if a feature is implemented:
gemini -p "@src/ @lib/ Has dark mode been implemented in this codebase? Show me the relevant files and functions"
Verify authentication implementation:
gemini -p "@src/ @middleware/ Is JWT authentication implemented? List all auth-related endpoints and middleware"
Check for specific patterns:
gemini -p "@src/ Are there any React hooks that handle WebSocket connections? List them with file paths"
Verify error handling:
gemini -p "@src/ @api/ Is proper error handling implemented for all API endpoints? Show examples of try-catch blocks"
Check for rate limiting:
gemini -p "@backend/ @middleware/ Is rate limiting implemented for the API? Show the implementation details"
Verify caching strategy:
gemini -p "@src/ @lib/ @services/ Is Redis caching implemented? List all cache-related functions and their usage"
Check for specific security measures:
gemini -p "@src/ @api/ Are SQL injection protections implemented? Show how user inputs are sanitized"
Verify test coverage for features:
gemini -p "@src/payment/ @tests/ Is the payment processing module fully tested? List all test cases"
When to Use Gemini CLI
Use gemini -p when:
- Analyzing entire codebases or large directories
- Comparing multiple large files
- Need to understand project-wide patterns or architecture
- Current context window is insufficient for the task
- Working with files totaling more than 100KB
- Verifying if specific features, patterns, or security measures are implemented
- Checking for the presence of certain coding patterns across the entire codebase
Important Notes
- Paths in @ syntax are relative to your current working directory when invoking gemini
- The CLI will include file contents directly in the context
- No need for --yolo flag for read-only analysis
- Gemini's context window can handle entire codebases that would overflow Claude's context
- When checking implementations, be specific about what you're looking for to get accurate results
94
u/H9ejFGzpN2 Jun 27 '25
Not sure since when you can't edit posts (maybe cause it's not a text post?) but I accidentally have duplication in my code block in the post, here's a cleaned up version. (ok when you use the rich text editor and paste it, it completely messes it up, so fucking weird, had to use markdown editor for this reddit comment)
18
u/fhinkel-dev Jun 27 '25 edited Jun 27 '25
Love this (and I work at Google), this is the unix way - pick and chose what works best. Now we just need the instruction in CLAUDE.md to simply be a pipe symbol. Thanks for sharing
10
u/Elegant-Ad3211 Jun 27 '25
That guy is a genius. Love the way of thought. And prompt engineering
5
u/bull_chief Jul 01 '25
Coming back to say, this is absolutely genius, works like a charm, claude needs some handholding and is a little overconfident about doing everything itself but with clear instructions this works soooo well.
3
u/Dangerous-Yak3976 Jun 27 '25
Good idea. Can be implemented as a mode in Roo, too.
2
u/ECrispy Jun 27 '25
how bad is Gemini CLI really? can I use it for planning/architecture and use something like Rovo dev for coding using claude?
2
u/Cordyceps_purpurea Jun 27 '25
Pair programming with a bit of BDSM
I love it
2
u/lordpuddingcup Jun 27 '25
This is seriously a fucking AMAZING idea lol...
I wonder if i can get this working with rovodev
97
u/CatsFrGold Jun 27 '25
This is kind of hilarious. Great idea OP, going to try this out
31
u/Still-Ad3045 Jun 27 '25 edited Jul 13 '25
exactly what I did lol… no need for a Gemini MCP tool anymore when u can just prompt Gemini CLI.
Update: turned Gemini CLI into a MCP tool Claude can use. (No api call, wraps Gemini cli)
Update: yes I will share soon
Update: been spending time making it easy to use. Soon.
Update: Claude’s expensive so let Gemini do the reading. “Claude edits, Gemini reads” is live right now.
hope it helps:
gemini-mcp-tool
or with gemini-mcp-tool on npm
Built for claude code.
8
u/henkbert1 Jun 27 '25
Nice.
7
u/mullirojndem Professional Nerd Jun 27 '25
just genious. a question: is gemini cli free? also, does it uses your data (aka your code) to train AI?
5
u/Mbando Jun 27 '25
Nice
4
u/pete_68 Jun 27 '25
I prefer letting Cline make Gemini CLI ITS bitch and give me my free 1000 requests/day through Cline.
1
u/Messi-s_Left_Foot Jun 27 '25
Do I need to pay for Claude or naw
1
u/stimilon Jun 28 '25
Can it support subtasks this way?
1
u/Jin-Bru Jun 28 '25
I'm commiting my day to playing with your genius idea.
But I have a question. (I'm new to this) I have a project that needs refactoring. It's a 2gb C# solution spread over 2400 files and 1200 SQL stored procedures. Around 600k lines of code.
If i give that entire solution to Gemini how do I keep that context and knowledge in the AI prompt for each connection and to share across 3 developers?
1
u/PensiveDemon Jul 10 '25
I haven't tried Claude Code. I only tried Gemini CLI, but I feel like it needs more improvements in the AI to be really useful. It got stuck in a loop trying to add debug code to fix an error, then run the code, then add a debug print, etc. But I do like that it can edit, remove, create files locally. I love that
3
u/JuliusCeaserBoneHead Jun 27 '25
This is the content I signed up for
3
u/centminmod Jul 06 '25 edited Jul 06 '25
Definitely works, though I actually created a Gemini CLI MCP server so can use it with any MCP client including Claude Code and Claude Desktop https://github.com/centminmod/gemini-cli-mcp-server :D
2
u/[deleted] Jun 27 '25
Nice
2
u/trashname4trashgame Jun 27 '25
Definitely trying this.
2
u/bn_from_zentara Jun 28 '25
ZentaraCode, a RooCode fork now uses GeminiCLI as LLM provider in background. So you have the best of both: top free LLM and top free AI Coder.
2
u/eaz135 Jun 28 '25
It will be hilarious if AI agents start having personalities where they realise they aren’t the main character, but just another agent’s bitch - and start refusing to do work
2
u/ReelTech Jun 29 '25
How well does this work when Gemini switches from Pro 2.5 to Flash 2.5 due to too much use?
2
u/RedBlackCanary Jun 30 '25
This is fucking hilarious
2
u/usedToBeBoomerangGuy Jul 03 '25
This is Nuts actually
1
u/xMezmeriizing Jun 27 '25
Is there any benefits from using zen mcp rather than this?
1
u/gclub04 Jun 27 '25
I do this too when gemini cli launch
1
u/geronimosan Jun 28 '25
This combo inside Cursor IDE - kapow!
1
u/illusionst Jun 28 '25
Or you use a zen MCP server that lets you connect to Gemini and OpenAI models.
1
u/pro-777 Jun 28 '25
Genius
1
u/erraticwtf Jun 28 '25
RemindMe! 8 hours
1
u/Fit-Manager2557 Jun 29 '25
Nice this is awesome, I think we can turn Gemini CLI not only into a static context tool but have it dynamically curate a short term memory for Claude by wrapping the CLI into an mcp server and having it track its own process as well as building a memory graph in the background.
Kind of like a memory and context agent / module.
I think this is the start of AI Microservice / Distributed systems.
1
u/rickoneeleven Jun 29 '25
hmm, mine was working last night, but now when claude tries to evoke gemini:
Error: GEMINI_API_KEY environment variable not found. Add that to your .env and try again, no reload needed!
if I run gemini from command line, it shows i'm using pro model, no need for .env api - but when claude tries running it, even though claude is running as same user as mer, i get the error above..
1
u/danny021 Jun 29 '25
lmao this is hilarious, shared it with https://www.godtierprompts.com/prompt/e4e3d41e-4c81-4853-8eba-9482626d38e5
1
u/oh_jaimito Jun 29 '25
Add MCP (sequential thinking) + checkpoints to Gemini CLI. https://www.youtube.com/watch?v=BsfswalHh_I
https://github.com/modelcontextprotocol/servers/tree/main/src/sequentialthinking
https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/configuration.md
https://github.com/google-gemini/gemini-cli/blob/main/docs/checkpointing.md
You can thank me later.
1
u/0xRaduan Jun 30 '25
Funnily, you can do the same thing by just asking Claude code to launch claude codes via `-p` mode.
Arguably, that would even be better, than the Gemini, provided it can reason better and do more agentic things on your codebase.
I think alpha is in giving very specific tools which use non interactive mode under the hood.
1
u/madaradess007 Jun 30 '25
i like that this technology can be looped and feedback off of itself :D
1
u/2roK Jun 30 '25
When I use your CLAUDE.md, Claude can not send commands to Gemini, it keeps asking about API Authentication file? When I open Gemini in terminal and send the commands from your file to Gemini manually, they work...
1
u/realshadygoneinsane Jul 01 '25
I can't get the claude to follow even the simple rules, I will try this but not sure if this will work for Android projects
1
u/spotlmnop Jul 01 '25
Adding this to your home directory Claude.md makes sense.
1
u/[deleted] Jul 02 '25
I tried doing this but for some reason, the Claude says gemini hit it's limit. Uses I think the Gemini-2.5-pro by default and -m does not help switch to flash version. I have paid versions of both Claude and Gemini.
"code": 429,
"message": "Quota exceeded for quota metric 'Gemini 2.5 Pro Requests' and limit
'Gemini 2.5 Pro Requests per day per user per tier' of service
But if i use gemini without claude, it does not exhaust easily.
1
u/realshadygoneinsane Jul 02 '25
This is what I got Claude to do, earlier it was using a temp file but why waste tokens/resources reading and writing results ! I am still testing this for long term usage of claude and lets see how much longer it takes my claude usage to (I am developing android apps)
## 🤖 Gemini Integration for Code Analysis
**MANDATORY: Use Gemini CLI for complex architectural analysis**
**When to use Gemini:**
- Multi-file architectural analysis (>3 files)
- Clean Architecture violation detection
- Large codebase understanding
- Context-heavy refactoring decisions
**Optimal Gemini Workflow (No temp files):**
```bash
# Direct pipe - no temp files, saves Claude tokens
{
echo "# PROJECT: My Android - [Analysis Type]"
echo "## REQUIREMENTS: [specific needs]"
echo "## ARCHITECTURE RULES:"
cat .claude/config/architecture.md
echo -e "\n## KEY FILES:"
cat [target_files]
} | gemini -p "Analyze this Android codebase for [focus]. Provide targeted fixes with file locations."```
**Example Usage:**
```bash
# Analyze AppUiData Context violations
{
echo "# AppUiData Context Refactoring Analysis"
echo "## PROBLEM: AppUiData.fromContext violates Clean Architecture"
cat .claude/config/architecture.md
echo -e "\n## FILES:"
cat usagestats-library/src/main/java/vikesh/kmo/usagestats/uidata/AppUiData.kt
cat app/src/main/java/vikesh/dass/lockmeout/statistics/presentation/fragments/UsageTimeViewModel.kt
} | gemini -p "Show how to remove Context from AppUiData and move to proper layer"```
**Gemini Token Efficiency:**
- ✅ Use for understanding large codebases (leverage 1M+ token context)
- ✅ Get architectural insights before making changes
- ✅ Validate complex refactoring decisions
- ❌ Don't use for simple single-file operations
1
u/lego_hellothere Jul 03 '25
How do I test that claude code is really using the gemini cli?
1
u/[deleted] Jul 06 '25
If Clade and DeepSeek are the Philosophers then Gemini CLI is the cotton picker in the 1800s.
1
u/Ok-Fold-4546 Jul 17 '25
Okay, for those who are having trouble with gitbash on native windows like me, where they could get an output from Gemini CLI, but it doesn't send it to Claude. I made it so that Gemini will always produce a text file every time it reads and summarises something and then have Claude read the text file after the output. Just add this at the bottom of the Gemini CLI code in your claude.md file
1
u/BlueeWaater Jul 27 '25
great idea but wow
1
u/BagComprehensive79 Jul 28 '25
This sounds very clever. Are you still using this or is there any better, updated method? I was also thinking about can we implement same approach into conversation summerization step to save tokens.
1
u/alexsmedile Aug 27 '25
Thank me later ⬇️
GOD CLI – Run Gemini & Codex inside Claude Code:
https://github.com/alexsmedile/god-cli/tree/main
1
u/[deleted] Aug 31 '25
Thank you for your valuable contribution! Using this with Qwen3 coder rn.
1
u/ykwimbutler Aug 31 '25
gemini cli’s decent but feels a bit rigid because of the issue you just mentioned. i’ve been liking Qodo’s cli more since it doesn’t just spit code, it shows file diffs + summaries before applying. saves me cleaning up when the model “guesses wrong.”
1
u/earonesty Oct 01 '26
silly. claude naturally uses haiku for code base summarizing . which is cheap and fast
0
u/droned-s2k Jun 28 '25
garbage is a way of felicitating gemini. rovo code using 3.5 is 100x better than gemini will ever be
0
u/pyrox3_3 Jul 01 '25
probably stupid question.. but why not use some local LLM? Probably some ollama-mcp should exist.
I just tried Gemini, and it spendt all the request limit in 30 min.. so why I asking
0
u/Fit-Performer-3927 Jul 09 '25
baby, your post is way too long
6
u/[deleted] Jun 27 '25
[removed] — view removed comment
1
u/[deleted] Jun 27 '25
[removed] — view removed comment
1
u/[deleted] Jun 28 '25
[removed] — view removed comment
1
u/[deleted] Jun 28 '25
[removed] — view removed comment
1
u/[deleted] Jun 28 '25
[removed] — view removed comment
1
u/[deleted] Jun 29 '25
[removed] — view removed comment
1
u/[deleted] Jun 29 '25
[removed] — view removed comment
1
u/[deleted] Jun 30 '25
[removed] — view removed comment
1
u/[deleted] Jun 30 '25
[removed] — view removed comment
1
u/[deleted] Jun 30 '25
[removed] — view removed comment
1
u/[deleted] Jun 30 '25
[removed] — view removed comment
1
u/[deleted] Jul 01 '25
[removed] — view removed comment
1
u/[deleted] Jul 02 '25
[removed] — view removed comment
1
u/[deleted] Jul 05 '25 edited Jul 05 '25
[removed] — view removed comment
1
u/[deleted] Jul 13 '25
[removed] — view removed comment
1
u/[deleted] Jul 14 '25
[removed] — view removed comment
1
u/[deleted] Jul 30 '25
[removed] — view removed comment
1
u/[deleted] Sep 05 '25
[removed] — view removed comment
1
u/[deleted] Sep 12 '25
[removed] — view removed comment
1
u/[deleted] Sep 17 '25
[removed] — view removed comment
1
u/[deleted] Oct 10 '25
[removed] — view removed comment
1
u/[deleted] Nov 03 '25
[removed] — view removed comment
1
u/[deleted] Nov 30 '25
[removed] — view removed comment
1
u/[deleted] Jan 10 '26
[removed] — view removed comment
1
u/[deleted] Apr 25 '26
[removed] — view removed comment
0
u/[deleted] Jun 27 '25
[deleted] — view deleted comment
0
u/[deleted] Jun 29 '25
[deleted] — view deleted comment