find or grep via BashTool.
GlobTool
Find files by name or path pattern
GrepTool
Search file contents with regex (powered by ripgrep)
ToolSearchTool
Discover which built-in tool to use for a task
GlobTool
Finds files whose paths match a glob pattern. Results are sorted by modification time (most recently changed first) to surface relevant files quickly. Tool name:GlobRead-only: yes
Concurrency-safe: yes
Destructive: no
Parameters
string
required
The glob pattern to match file paths against. Supports
*, **, ?, and brace expansions, e.g. "**/*.ts", "src/**/*.{ts,tsx}", "*.config.js".string
Directory to search in. Defaults to the current working directory when omitted. Must be a valid directory path — do not pass
"undefined" or "null".Return value
string[]
Relative paths (relative to the current working directory) of matching files.
number
Total number of files returned.
boolean
true when results were capped (default cap: 100 files). Use a more specific pattern or path to narrow the search.number
Wall-clock time to execute the search in milliseconds.
Usage examples
Find all TypeScript files in a project:GrepTool
Searches file contents for a regular expression pattern. Internally uses ripgrep (rg) for high performance, with automatic exclusion of VCS directories (.git, .svn, .hg, .bzr, .jj, .sl).
Tool name: SearchRead-only: yes
Concurrency-safe: yes
Destructive: no
Parameters
string
required
A regular expression pattern to search for. Full ripgrep regex syntax is supported.
string
File or directory to search in (
rg PATH). Defaults to the current working directory.string
Glob pattern to filter which files are searched, e.g.
"*.js" or "*.{ts,tsx}". Maps to rg --glob.string
default:"files_with_matches"
Controls the format of results:
"files_with_matches"— list of file paths that contain at least one match (default)"content"— matched lines with optional surrounding context lines"count"— number of matches per file
number
Lines of context before each match (
rg -B). Only used when output_mode is "content".number
Lines of context after each match (
rg -A). Only used when output_mode is "content".number
Lines of context before and after each match (
rg -C). Alias for context. Overrides -B/-A when specified. Only used when output_mode is "content".number
Alias for
-C. Lines of symmetric context around each match.boolean
default:"true"
Show line numbers in
"content" mode output (rg -n).boolean
default:"false"
Case-insensitive search (
rg -i).string
Restrict search to a ripgrep file type (
rg --type). Examples: "js", "py", "rust", "go", "java". More efficient than glob for standard language types.number
default:"250"
Limit output to the first N lines/entries, equivalent to
| head -N. Pass 0 for unlimited (use sparingly — large results consume significant context).number
default:"0"
Skip the first N lines/entries before applying
head_limit. Equivalent to | tail -n +N | head -N. Use together with head_limit for pagination.boolean
default:"false"
Enable multiline mode where
. matches newlines and patterns can span lines (rg -U --multiline-dotall).Return value
string
The output mode that was used:
"files_with_matches", "content", or "count".string[]
Matching file paths (relative to CWD). Populated for
"files_with_matches" mode. Sorted by most recently modified.number
Number of files returned.
string
Matched output as a string. Populated for
"content" and "count" modes.number
Number of output lines. Populated for
"content" mode.number
Total match count across all files. Populated for
"count" mode.number
The
head_limit that was applied, set only when truncation actually occurred.number
The
offset that was applied, set when offset > 0.ripgrep under the hood
GrepTool delegates to ripgrep (rg) and mirrors its semantics closely. Key behaviours:
- Lines are capped at 500 characters to avoid bloating results with minified files or base64 blobs.
- VCS directories are excluded automatically via
--glob !.git --glob !.svnetc. - Permission-based ignore patterns from Claude Code settings are forwarded as additional
--glob !...rules. - In
"files_with_matches"mode, results are sorted by file modification time beforehead_limitis applied.
Usage examples
Find all files containing a React hook:ToolSearchTool
A meta-tool that searches the descriptions of all available built-in tools to help the model find the right tool for a given task. Useful when an unfamiliar task might be covered by a lesser-known built-in. Tool name:ToolSearchRead-only: yes
Concurrency-safe: yes
Destructive: no
Parameters
string
required
A natural-language description of the task you want to accomplish. The tool matches against the
searchHint field registered on each built-in tool.Return value
An ordered list of tool names and their descriptions ranked by relevance toquery.