Overview
All file system tools operate within arootDirectory (the current working directory or workspace root) for security. The CLI automatically respects .gitignore and .geminiignore files to avoid exposing irrelevant or sensitive files.
Available Tools
list_directory (ReadFolder)
Lists the names of files and subdirectories directly within a specified path.
Absolute or relative path to the directory
Glob patterns to exclude from listing
Configuration for
.gitignore and .geminiignore complianceThis tool only lists direct children of the specified directory. Use
glob for recursive file discovery.read_file (ReadFile)
Reads and returns the content of a specific file. Supports text, images, audio, and PDF.
Path to the file to read
Start line for text files (0-based)
Maximum number of lines to read
write_file (WriteFile)
Writes content to a specified file, overwriting it if it exists or creating it if not.
Path to the file to write
Data to write to the file
glob (FindFiles)
Finds files matching specific glob patterns across the workspace.
The glob pattern to match (e.g.,
"*.py", "src/**/*.js")Absolute path to the directory to search within. Defaults to root directory.
Whether the search should be case-sensitive
Whether to respect
.gitignore patterns- Returns absolute paths sorted by modification time (most recent first)
- Ignores common directories like
node_modulesand.gitby default - Does not require user confirmation
grep_search (SearchText)
Searches for a regular expression pattern within file contents. Returns matching lines with file paths and line numbers.
Regular expression to search for (e.g.,
"function\\s+myFunction")Absolute path to search within. Defaults to current working directory.
Glob pattern to filter files (e.g.,
"*.js", "src/**/*.{ts,tsx}")- Uses
git grepif available in a Git repository for maximum speed - Falls back to system
grepor JavaScript-based search
replace (Edit)
Replaces text within a file with precise string matching.
Path to the file to modify
Semantic description of the change being made
Exact literal text to find and replace
Exact literal text to replace with
If
true, replaces all occurrences. If false, only succeeds if exactly one occurrence is found.Security
Trusted Folders
Learn how to manage file system access permissions using trusted folders
Next Steps
File Management Tutorial
Practical examples of using file system tools
Shell Commands
Execute shell commands for advanced operations