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
stringrequired

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
stringrequired

Path where to write the file

content
stringrequired

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
stringrequired

Directory path to list

recursive
boolean

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
stringrequired

The shell command to execute

cwd
string

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
stringrequired

Path to the script file

args
array

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
stringrequired

URL to fetch content from

method
string

HTTP method (GET, POST, etc.)

headers
object

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
stringrequired

Search query

num_results
number

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
stringrequired

Key to store the information under

value
stringrequired

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
stringrequired

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 truegemini config set file-tools-enabled falsegemini config set web-tools-enabled true

Tool Timeouts

gemini config set tool-timeout 30gemini config set web-timeout 10gemini config set shell-timeout 60

Related Resources

Learn more about tools and customization