<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: muzhihao1</title>
    <description>The latest articles on Forem by muzhihao1 (@muzhihao1).</description>
    <link>https://forem.com/muzhihao1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3858603%2F37cb8a18-1a83-4c34-909e-db3f5a0e78c0.png</url>
      <title>Forem: muzhihao1</title>
      <link>https://forem.com/muzhihao1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/muzhihao1"/>
    <language>en</language>
    <item>
      <title>7 Gemini CLI Tips That Save Me Hours Every Week</title>
      <dc:creator>muzhihao1</dc:creator>
      <pubDate>Fri, 03 Apr 2026 02:48:23 +0000</pubDate>
      <link>https://forem.com/muzhihao1/7-gemini-cli-tips-that-save-me-hours-every-week-2f2n</link>
      <guid>https://forem.com/muzhihao1/7-gemini-cli-tips-that-save-me-hours-every-week-2f2n</guid>
      <description>&lt;p&gt;Google's Gemini CLI is a powerful AI coding assistant that runs directly in your terminal. After using it daily for months, here are the tips and tricks that made the biggest difference in my workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Use Plan Mode for Complex Refactoring
&lt;/h2&gt;

&lt;p&gt;Instead of letting Gemini CLI modify files immediately, use Plan Mode to preview changes first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gemini plan &lt;span class="s2"&gt;"Refactor the auth module to use OAuth 2.0"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Plan Mode generates a step-by-step execution plan that you can review, edit, and approve before any files are touched. This is a lifesaver for multi-file refactoring where you want to see the full picture before committing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to use it:&lt;/strong&gt; Database migrations, API redesigns, or any change touching 3+ files.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Pipe Files for Instant Code Reviews
&lt;/h2&gt;

&lt;p&gt;Don't just describe your code - pipe it directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;src/auth.py | gemini &lt;span class="s2"&gt;"Review this code for security vulnerabilities"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or review an entire directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;find src/ &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s2"&gt;"*.py"&lt;/span&gt; &lt;span class="nt"&gt;-exec&lt;/span&gt; &lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt; + | gemini &lt;span class="s2"&gt;"Find bugs in this codebase"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives Gemini CLI the full context instead of relying on descriptions.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Save Output to Files
&lt;/h2&gt;

&lt;p&gt;Stop copying from the terminal. Redirect output directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gemini &lt;span class="s2"&gt;"Write unit tests for this function"&lt;/span&gt; &amp;lt; utils.py &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; tests/test_utils.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Combine with Plan Mode for even more control:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gemini plan &lt;span class="nt"&gt;--save&lt;/span&gt; refactor-plan.md &lt;span class="s2"&gt;"Migrate from Express callbacks to async/await"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Switch Models Based on Task Complexity
&lt;/h2&gt;

&lt;p&gt;Not every task needs the most powerful model. Use Flash Lite for quick tasks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Quick question - use the fast model&lt;/span&gt;
gemini &lt;span class="nt"&gt;-m&lt;/span&gt; flash-lite &lt;span class="s2"&gt;"What does the -g flag do in npm install?"&lt;/span&gt;

&lt;span class="c"&gt;# Complex refactoring - use the powerful model  &lt;/span&gt;
gemini &lt;span class="nt"&gt;-m&lt;/span&gt; pro &lt;span class="s2"&gt;"Redesign the database schema for multi-tenancy support"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Flash Lite responds 3-5x faster and costs significantly less. For code completion, quick Q&amp;amp;A, and batch processing, it's the better choice.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Fix "Not Responding" Issues Fast
&lt;/h2&gt;

&lt;p&gt;This is the #1 issue developers hit. When Gemini CLI hangs or freezes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Step 1: Kill the hanging process&lt;/span&gt;
pkill &lt;span class="nt"&gt;-f&lt;/span&gt; gemini

&lt;span class="c"&gt;# Step 2: Clear the cache&lt;/span&gt;
gemini cache clear

&lt;span class="c"&gt;# Step 3: Check your API key is valid&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$GEMINI_API_KEY&lt;/span&gt;

&lt;span class="c"&gt;# Step 4: Test with a simple command&lt;/span&gt;
gemini &lt;span class="s2"&gt;"Hello"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Common causes:&lt;/strong&gt; expired API key, network timeout behind corporate proxy, or Node.js version &amp;lt; 16.&lt;/p&gt;

&lt;p&gt;I wrote a &lt;a href="https://geminicli.one/troubleshooting" rel="noopener noreferrer"&gt;comprehensive troubleshooting guide&lt;/a&gt; covering all the edge cases if you're still stuck.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Use Subagents for Parallel Work
&lt;/h2&gt;

&lt;p&gt;Gemini CLI can spawn subagents to handle multiple tasks simultaneously:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gemini &lt;span class="s2"&gt;"Run tests, fix linting errors, and update documentation - do these in parallel"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Gemini CLI automatically detects that these are independent tasks and spawns a subagent for each one. The results are merged when all subagents complete.&lt;/p&gt;

&lt;p&gt;Control concurrency with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gemini config &lt;span class="nb"&gt;set &lt;/span&gt;maxSubagents 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  7. Set Up Governance Files for Team Consistency
&lt;/h2&gt;

&lt;p&gt;Create a &lt;code&gt;GEMINI.md&lt;/code&gt; file at your project root to enforce coding standards:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# Project Rules for Gemini CLI&lt;/span&gt;
&lt;span class="p"&gt;
-&lt;/span&gt; Use TypeScript strict mode
&lt;span class="p"&gt;-&lt;/span&gt; Follow the repository's existing naming conventions  
&lt;span class="p"&gt;-&lt;/span&gt; Never modify files in the /config directory without approval
&lt;span class="p"&gt;-&lt;/span&gt; Write tests for all new functions
&lt;span class="p"&gt;-&lt;/span&gt; Use async/await, never callbacks
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every team member's Gemini CLI instance will follow these rules automatically. This prevents the "AI wrote inconsistent code" problem that plagues team projects.&lt;/p&gt;




&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;p&gt;If you're getting started with Gemini CLI or running into issues, I built &lt;a href="https://geminicli.one" rel="noopener noreferrer"&gt;GeminiCLI.one&lt;/a&gt; as a comprehensive resource hub. It covers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://geminicli.one/qa/install-macos" rel="noopener noreferrer"&gt;Installation guides&lt;/a&gt; for all platforms (Windows, macOS, Linux, Docker)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://geminicli.one/troubleshooting" rel="noopener noreferrer"&gt;Troubleshooting solutions&lt;/a&gt; for common errors&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://geminicli.one/qa/first-command" rel="noopener noreferrer"&gt;First command guide&lt;/a&gt; with practical examples&lt;/li&gt;
&lt;li&gt;Guides for latest features like &lt;a href="https://geminicli.one/qa/plan-mode" rel="noopener noreferrer"&gt;Plan Mode&lt;/a&gt;, &lt;a href="https://geminicli.one/qa/subagent" rel="noopener noreferrer"&gt;Subagents&lt;/a&gt;, and &lt;a href="https://geminicli.one/qa/sandbox" rel="noopener noreferrer"&gt;Sandbox&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All free, no signup required.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;What Gemini CLI tips have saved you the most time? Drop them in the comments!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>gemini</category>
      <category>cli</category>
      <category>ai</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
