Built-in Tools
Comprehensive reference for all built-in tools available in Gemini CLI. These tools extend the AI's capabilities to interact with files, execute commands, browse the web, and manage memory.
Tool Categories
Built-in tools organized by functionality
File System Tools
Tools for reading, writing, and managing files and directories
read_file
Read the contents of a file
Parameters:
path
Path to the file to read
Returns:
string - The file contents
Example Usage:
AI: I'll read the package.json file for you.
Tool call: read_file
Parameters: {"path": "./package.json"}
Result: {
"name": "my-project",
"version": "1.0.0",
"dependencies": {
"express": "^4.18.0"
}
}
write_file
Write content to a file
Parameters:
path
Path where to write the file
content
Content to write to the file
Returns:
string - Success confirmation
Example Usage:
AI: I'll create a new README file for you.
Tool call: write_file
Parameters: {
"path": "./README.md",
"content": "# My Project\n\nThis is a sample project."
}
Result: File written successfully to ./README.md
list_files
List files and directories in a given path
Parameters:
path
Directory path to list
recursive
Whether to list recursively
Returns:
array - List of files and directories
Example Usage:
AI: Let me list the files in the src directory.
Tool call: list_files
Parameters: {"path": "./src", "recursive": false}
Result: [
"index.js",
"utils.js",
"components/",
"styles/"
]
Shell Tools
Tools for executing shell commands and scripts
run_shell_command
Execute a shell command
Parameters:
command
The shell command to execute
cwd
Working directory for the command
Returns:
object - Command result with stdout, stderr, and exit code
Example Usage:
AI: I'll check the current Git status.
Tool call: run_shell_command
Parameters: {"command": "git status --porcelain"}
Result: {
"stdout": " M src/index.js\n?? new-file.txt",
"stderr": "",
"exitCode": 0
}
run_script
Execute a script file
Parameters:
script_path
Path to the script file
args
Arguments to pass to the script
Returns:
object - Script execution result
Example Usage:
AI: I'll run the build script with production flag.
Tool call: run_script
Parameters: {
"script_path": "./scripts/build.sh",
"args": ["--production"]
}
Result: {
"stdout": "Building for production...\nBuild completed successfully!",
"stderr": "",
"exitCode": 0
}
Web Tools
Tools for web requests, searches, and online content
web_fetch
Fetch content from a URL
Parameters:
url
URL to fetch content from
method
HTTP method (GET, POST, etc.)
headers
HTTP headers to include
Returns:
string - The fetched content
Example Usage:
AI: I'll fetch the latest information from the API.
Tool call: web_fetch
Parameters: {
"url": "https://api.github.com/repos/google-gemini/gemini-cli",
"headers": {"Accept": "application/json"}
}
Result: {
"name": "gemini-cli",
"description": "A CLI for Google's Gemini AI",
"stars": 1250,
"language": "TypeScript"
}
web_search
Search the web for information
Parameters:
query
Search query
num_results
Number of results to return
Returns:
array - Search results with titles, URLs, and snippets
Example Usage:
AI: I'll search for information about TypeScript best practices.
Tool call: web_search
Parameters: {
"query": "TypeScript best practices 2024",
"num_results": 3
}
Result: [
{
"title": "TypeScript Best Practices for 2024",
"url": "https://example.com/typescript-best-practices",
"snippet": "Learn the latest TypeScript best practices..."
}
]
Memory Tools
Tools for managing conversation memory and context
remember
Store information for later reference
Parameters:
key
Key to store the information under
value
Information to remember
Returns:
string - Confirmation of storage
Example Usage:
AI: I'll remember your project preferences.
Tool call: remember
Parameters: {
"key": "project_style",
"value": "User prefers TypeScript with strict mode and ESLint"
}
Result: Information stored successfully under key 'project_style'
recall
Retrieve previously stored information
Parameters:
key
Key to retrieve information for
Returns:
string - The stored information
Example Usage:
AI: Let me recall your project preferences.
Tool call: recall
Parameters: {"key": "project_style"}
Result: User prefers TypeScript with strict mode and ESLint
list_memories
List all stored memory keys
Parameters:
Returns:
array - List of all memory keys
Example Usage:
AI: I'll show you what I remember about our conversation.
Tool call: list_memories
Parameters: {}
Result: [
"project_style",
"user_preferences",
"current_task"
]
Usage Guidelines
Best practices for using built-in tools effectively
Security Considerations
- β’ Tools run with your user permissions
- β’ Be cautious with shell commands
- β’ Review file operations before execution
- β’ Web tools respect rate limits
- β’ Memory tools store data locally
Performance Tips
- β’ Use specific file paths when possible
- β’ Limit recursive directory listings
- β’ Cache web requests when appropriate
- β’ Clean up memory periodically
- β’ Monitor shell command timeouts
Tool Configuration
Configure tool behavior and permissions
Enable/Disable Tools
gemini config set tools-enabled true
gemini config set file-tools-enabled false
gemini config set web-tools-enabled true
Tool Timeouts
gemini config set tool-timeout 30
gemini config set web-timeout 10
gemini config set shell-timeout 60