-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add blog post: Gemini CLI trusted directories configuration #7298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,380 @@ | ||||||
| --- | ||||||
| title: "Streamline Your Gemini CLI Workflow with Trusted Directories" | ||||||
| subtitle: "Stop wasting time on approval prompts and boost your productivity" | ||||||
| date: 2025-12-28 10:30:05 -0530 | ||||||
| author: Layer5 Team | ||||||
| thumbnail: ./gemini-cli-hero.png | ||||||
| darkthumbnail: ./gemini-cli-hero.png | ||||||
| description: "Learn how to configure Gemini CLI trusted directories through interactive prompts, commands, or manual configuration to eliminate repetitive approval prompts and accelerate your AI-powered development workflow." | ||||||
| type: Blog | ||||||
| category: AI | ||||||
| tags: | ||||||
| - ai | ||||||
| - Engineering | ||||||
| - devops | ||||||
| featured: false | ||||||
| published: true | ||||||
| resource: true | ||||||
| --- | ||||||
|
|
||||||
| import { BlogWrapper } from "../../Blog.style.js"; | ||||||
| import { Link } from "gatsby"; | ||||||
| import Blockquote from "../../../../reusecore/Blockquote"; | ||||||
| import CTA_FullWidth from "../../../../components/Call-To-Actions/CTA_FullWidth"; | ||||||
| import CTAImg from "../../../../assets/images/layer5/5 icon/png/light/5-light-no-trim.webp"; | ||||||
|
|
||||||
| <BlogWrapper> | ||||||
|
|
||||||
| <div class="intro"> | ||||||
| <p> | ||||||
| As AI-powered coding assistants become essential development tools, managing file access permissions efficiently is crucial. If you're using Gemini CLI and finding yourself repeatedly approving the same directory prompts, this guide will help you configure trusted directories and reclaim your valuable development time. | ||||||
| </p> | ||||||
| </div> | ||||||
|
|
||||||
| The Gemini CLI is Google's powerful command-line interface for interacting with Gemini AI models directly from your terminal. Whether you're building <Link to="/cloud-native-management/meshery">cloud native applications</Link>, automating infrastructure tasks, or leveraging AI for code generation, the Gemini CLI can significantly enhance your productivity—but only if it's properly configured. | ||||||
|
|
||||||
| ## The Trust Prompt Challenge | ||||||
|
|
||||||
| When you first run Gemini CLI in a new directory, you'll encounter trust dialogs that ask for permission to access files in that location. While this security feature protects your sensitive data, it can become a productivity bottleneck when working across multiple projects or frequently switching between directories. | ||||||
|
|
||||||
| **The problem:** Every time you navigate to a new folder, you're interrupted by permission requests. For platform engineers and DevOps practitioners managing multiple repositories, microservices, or infrastructure-as-code projects, these interruptions add up quickly. | ||||||
|
|
||||||
| **The solution:** Configure trusted directories once, and work uninterrupted across all your projects. | ||||||
|
|
||||||
| ## Three Ways to Configure Trusted Directories | ||||||
|
|
||||||
| Gemini CLI offers three flexible approaches to managing trusted directories, each suited to different workflows and preferences. Let's explore each method in detail. | ||||||
|
|
||||||
| ### 1. Interactive Prompts: The Quick Start Method | ||||||
|
|
||||||
| The most straightforward way to configure trust settings is through the interactive prompts that appear when you first use Gemini CLI in a new directory. | ||||||
|
|
||||||
| #### How It Works | ||||||
|
|
||||||
| When running Gemini CLI in an untrusted folder, you'll see a dialog with two primary options: | ||||||
|
|
||||||
| **Trust Folder**: This option trusts only the current directory. Choose this when: | ||||||
| - You're working in a single, isolated project | ||||||
| - The directory contains sensitive information and you want granular control | ||||||
| - You want to test Gemini CLI functionality in a specific location | ||||||
|
|
||||||
| **Trust Parent Folder**: This option trusts the current folder and all its subdirectories. This is ideal when: | ||||||
| - You're managing a monorepo with multiple projects | ||||||
| - Your workspace contains related microservices | ||||||
| - You want to streamline trust management across a project hierarchy | ||||||
|
|
||||||
| <Blockquote | ||||||
| quote="Trusting parent folders intelligently reduces configuration overhead—one decision covers an entire project tree, letting you focus on building rather than managing permissions." | ||||||
| person="Platform Engineering Best Practice" | ||||||
| title="Layer5 Community" | ||||||
| /> | ||||||
|
|
||||||
| #### Modifying Trust Settings | ||||||
|
|
||||||
| Already working in a directory but want to change its trust level? No problem. Simply run: | ||||||
|
|
||||||
| ```bash | ||||||
| /permissions | ||||||
| ``` | ||||||
|
|
||||||
| This command brings up the interactive dialog from within your current directory, allowing you to adjust trust settings on the fly without leaving your workflow. | ||||||
|
|
||||||
| ### 2. Command-Line Multi-Directory Support | ||||||
|
|
||||||
| For engineers who prefer command-line efficiency or need to work across multiple unrelated directories simultaneously, Gemini CLI provides powerful command-line options for directory management. | ||||||
|
|
||||||
| #### Starting a Session with Multiple Directories | ||||||
|
|
||||||
| To give Gemini CLI access to multiple directories from the start, use the `--include-directories` flag: | ||||||
|
|
||||||
| ```bash | ||||||
| gemini --include-directories path/to/dir1,path/to/dir2,path/to/dir3 | ||||||
| ``` | ||||||
|
|
||||||
| **Key points:** | ||||||
| - Paths can be **absolute** (e.g., `/home/user/projects/api`) or **relative** (e.g., `../frontend`) | ||||||
| - Separate multiple paths with commas (no spaces) | ||||||
| - This is particularly useful for cross-project workflows | ||||||
|
|
||||||
| **Example use case:** A platform engineer working on a <Link to="/cloud-native-management/meshery">Meshery</Link> deployment might need access to: | ||||||
| - The main application repository | ||||||
| - A shared Kubernetes manifests directory | ||||||
| - Infrastructure-as-code configurations | ||||||
| - Documentation repository | ||||||
|
|
||||||
| ```bash | ||||||
| gemini --include-directories ~/projects/meshery-app,~/k8s/manifests,~/terraform/prod,~/docs/api | ||||||
| ``` | ||||||
|
|
||||||
| #### Adding Directories During an Active Session | ||||||
|
|
||||||
| Already in a Gemini CLI session and need to add another directory? Use the `/directory add` command: | ||||||
|
|
||||||
| ```bash | ||||||
| /directory add <path> | ||||||
| ``` | ||||||
|
|
||||||
| You can even add multiple directories at once by separating them with commas: | ||||||
|
|
||||||
| ```bash | ||||||
| /directory add ~/new-project,~/shared-utils,~/config | ||||||
| ``` | ||||||
|
|
||||||
| The alias `/dir` works identically for convenience: | ||||||
|
|
||||||
| ```bash | ||||||
| /dir add ~/another-project | ||||||
| ``` | ||||||
|
|
||||||
| #### Viewing Active Directories | ||||||
|
|
||||||
| To see all directories currently accessible in your session: | ||||||
|
|
||||||
| ```bash | ||||||
| /directory show | ||||||
| ``` | ||||||
|
|
||||||
| Or using the shorter alias: | ||||||
|
|
||||||
| ```bash | ||||||
| /dir show | ||||||
| ``` | ||||||
|
|
||||||
| This command displays a complete list of all trusted directories for the current session, helping you verify your configuration and understand the scope of file access. | ||||||
|
|
||||||
| <div class="tip"> | ||||||
| <h3>💡 Pro Tip for DevOps Teams</h3> | ||||||
| <p>When working with <Link to="/cloud-native-management/kanvas">infrastructure design tools like Kanvas</Link>, organize your Kubernetes manifests, Helm charts, and configuration files in a parent directory. Trust that parent folder once, and Gemini CLI will have seamless access to your entire infrastructure-as-code setup.</p> | ||||||
| </div> | ||||||
|
|
||||||
| ### 3. Manual Configuration: The Power User Approach | ||||||
|
|
||||||
| For advanced users, automation enthusiasts, or those managing multiple machines, manually editing the trusted folders configuration file provides the ultimate control and reproducibility. | ||||||
|
|
||||||
| #### Understanding the Configuration File | ||||||
|
|
||||||
| Trusted folder rules are stored in a JSON file located at: | ||||||
|
|
||||||
| ```bash | ||||||
| ~/.gemini/trustedFolders.json | ||||||
| ``` | ||||||
|
|
||||||
| This file resides in your home directory's `.gemini` folder and persists across CLI sessions. | ||||||
|
|
||||||
| #### File Structure and Format | ||||||
|
|
||||||
| The `trustedFolders.json` file uses a straightforward JSON structure. Here's an example: | ||||||
|
|
||||||
| ```json | ||||||
| { | ||||||
| "trustedFolders": [ | ||||||
| "/home/username/projects/meshery", | ||||||
| "/home/username/kubernetes/clusters", | ||||||
| "/home/username/terraform/infrastructure", | ||||||
| "/opt/shared/configs" | ||||||
| ] | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| #### Editing the Configuration File | ||||||
|
|
||||||
| You can edit this file directly using any text editor: | ||||||
|
|
||||||
| ```bash | ||||||
| nano ~/.gemini/trustedFolders.json | ||||||
| ``` | ||||||
|
|
||||||
| Or with your preferred editor: | ||||||
|
|
||||||
| ```bash | ||||||
| vim ~/.gemini/trustedFolders.json | ||||||
| code ~/.gemini/trustedFolders.json # VS Code | ||||||
| ``` | ||||||
|
|
||||||
| #### Adding and Removing Paths | ||||||
|
|
||||||
| **To add a new trusted directory:** | ||||||
| 1. Open the file in your editor | ||||||
| 2. Add the full path to the `trustedFolders` array | ||||||
| 3. Ensure proper JSON formatting (commas between entries, quotes around paths) | ||||||
| 4. Save the file | ||||||
|
|
||||||
| **To remove a trusted directory:** | ||||||
| 1. Open the file | ||||||
| 2. Delete the line containing the path (and any trailing comma if it's the last entry) | ||||||
| 3. Save the file | ||||||
|
|
||||||
| **Example workflow:** | ||||||
|
|
||||||
| ```bash | ||||||
| # Backup your current configuration | ||||||
| cp ~/.gemini/trustedFolders.json ~/.gemini/trustedFolders.json.backup | ||||||
|
|
||||||
| # Edit the configuration | ||||||
| nano ~/.gemini/trustedFolders.json | ||||||
|
|
||||||
| # Verify JSON syntax (optional but recommended) | ||||||
| python3 -c "import json; json.load(open('$HOME/.gemini/trustedFolders.json'))" | ||||||
|
||||||
| python3 -c "import json; json.load(open('$HOME/.gemini/trustedFolders.json'))" | |
| python3 -m json.tool "$HOME/.gemini/trustedFolders.json" > /dev/null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 4907083. Changed validation command to python3 -m json.tool "$HOME/.gemini/trustedFolders.json" > /dev/null for better portability and proper quote handling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The meta description is too long. The description field contains 168 characters, which exceeds the recommended SEO limit of 150-160 characters. Search engines typically truncate descriptions beyond 160 characters, potentially cutting off important information. Consider shortening to: "Learn how to configure Gemini CLI trusted directories through interactive prompts, commands, or manual configuration to eliminate approval prompts and accelerate your workflow." (154 characters)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 4907083. Meta description shortened from 168 to 153 characters, now within the SEO-recommended 150-160 character limit.