How Tools Work
You use tools indirectly through natural language prompts. The model decides when tools are needed and requests them automatically.You provide a prompt
@package.json.Model analyzes the request
Tool validation
User confirmation
Tool Categories
Gemini CLI tools fall into three main categories:User-Triggered
Model-Triggered
Information
User-Triggered Tools
You can directly trigger these tools using special syntax in your prompts.File Access (@)
Include file or directory contents in your prompt using the @ symbol.
Syntax:
read_many_files tool, which reads and includes the content in your prompt context.Shell Commands (!)
Execute shell commands directly using the ! symbol.
Syntax:
Model-Triggered Tools
The model automatically requests these tools when needed to fulfill your requests. You don’t call them manually.File Management Tools
These tools let the model explore and modify your local codebase.list_directory - List files and folders
list_directory - List files and folders
dir_path- Absolute or relative path to directoryignore- Optional glob patterns to excludefile_filtering_options- Optional.gitignoreand.geminiignorecompliance
- “What files are in the src directory?”
- “Show me the project structure”
- “List all components”
read_file - Read file contents
read_file - Read file contents
file_path- Path to the fileoffset- Optional start line (0-based)limit- Optional maximum lines to read
- “Read the config file”
- “What’s in index.js?”
- “Show me the README”
write_file - Write or create files
write_file - Write or create files
file_path- Path to the filecontent- Data to write
- “Create a new component file”
- “Update the package.json”
- “Write this config to settings.json”
glob - Find files by pattern
glob - Find files by pattern
pattern- Glob pattern (e.g.,*.py,src/**/*.js)path- Optional directory to search (defaults to root)case_sensitive- Optional case sensitivity (defaults to false)respect_git_ignore- Optional .gitignore compliance (defaults to true)
- “Find all TypeScript files”
- “Locate test files”
- “Show me all markdown documents”
grep_search - Search file contents
grep_search - Search file contents
pattern- Regular expression to search forpath- Optional directory to searchinclude- Optional glob pattern to filter files
- “Find all TODO comments”
- “Search for function definitions”
- “Where is this variable used?”
replace - Edit file contents
replace - Edit file contents
file_path- Path to the fileinstruction- Semantic description of the changeold_string- Exact text to findnew_string- Exact text to replace withallow_multiple- Optional flag to replace all occurrences
- “Update the API endpoint URL”
- “Change the port number”
- “Rename this function”
Agent Coordination Tools
These tools help the model plan tasks and interact with you.ask_user - Request clarification
ask_user - Request clarification
- Model needs more context
- Ambiguous requirements
- Missing configuration details
save_memory - Save to GEMINI.md
save_memory - Save to GEMINI.md
GEMINI.md file).When used:- You ask to remember something
- Important project conventions noted
- Persistent preferences established
write_todos - Manage task lists
write_todos - Manage task lists
- Breaking down large tasks
- Tracking multi-step operations
- Planning complex changes
activate_skill - Load specialized knowledge
activate_skill - Load specialized knowledge
- Domain-specific workflows needed
- Specialized procedures required
- Expert guidance necessary
browser_agent - Automate web tasks
browser_agent - Automate web tasks
- Filling web forms
- Navigating websites
- Extracting web page data
get_internal_docs - Access CLI documentation
get_internal_docs - Access CLI documentation
- Questions about CLI features
- Configuration help needed
- Command reference required
Information Gathering Tools
These tools provide access to external data and services.web_fetch - Retrieve web content
web_fetch - Retrieve web content
url- The URL to fetchoptions- Optional request configuration
- “Get content from this URL”
- “Fetch the API documentation”
- “Read this blog post”
google_web_search - Search the web
google_web_search - Search the web
query- Search query string
- “Search for best practices”
- “Find recent documentation”
- “Look up current syntax”
Security and Confirmation
Safety is a core part of the tool system. Gemini CLI implements several safeguards:User Confirmation
You must manually approve tools that modify files or execute shell commands.Sandboxing
You can run tool executions in secure, containerized environments to isolate changes from your host system.Learn More About Sandboxing
Trusted Folders
Configure which directories allow the model to use system tools.Configure Trusted Folders
Policy Engine
Use fine-grained control over tool execution with the Policy Engine.Policy Engine Reference
Extending with MCP Servers
You can extend Gemini CLI with custom tools using Model Context Protocol (MCP) servers. Example MCP integrations:MCP Server Integration
Tool Development
You can create custom tools for Gemini CLI.Tools API Reference
Best Practices
Use descriptive prompts
Use descriptive prompts
Review confirmations carefully
Review confirmations carefully
- File paths are correct
- Changes match your intent
- Commands are safe to execute
Use @ for context
Use @ for context
Leverage GEMINI.md for instructions
Leverage GEMINI.md for instructions
GEMINI.md:Troubleshooting
Tool execution fails
Tool execution fails
- Insufficient permissions
- File or directory doesn’t exist
- Not in a trusted folder
- Check file permissions
- Verify paths are correct
- Configure trusted folders
Model doesn't use tools
Model doesn't use tools
- Prompt is too vague
- Tool not needed for the task
- Tool disabled in settings
- Be more specific in your request
- Explicitly mention what you want (e.g., “read the file and…”)
- Check tool configuration in settings
Unwanted tool confirmations
Unwanted tool confirmations
- Security settings require confirmation
- Operating in untrusted directory
- Add directory to trusted folders
- Adjust confirmation settings
- Use sandbox mode for experimentation