Overview
Theglob tool provides fast file pattern matching using ripgrep’s file enumeration. Use this when you need to find files by name patterns.
Source: src/tools/glob/
Implementation
Uses ripgrep (rg --files) with glob pattern matching:
- 60 second timeout
- 100 file limit
- Results sorted by modification time (newest first)
- Respects
.gitignoreand.ignorefiles
Parameters
The glob pattern to match files againstExamples:
"**/*.js"- All JavaScript files"src/**/*.ts"- TypeScript files in src/"*.json"- JSON files in current directory"**/test/*.spec.ts"- Test files"components/**/*.{tsx,jsx}"- React components
*- Match any characters except/**- Match any characters including/?- Match single character[abc]- Match one character from set{a,b}- Match either pattern
The directory to search inDefaults to current working directory.Important: Omit this field to use the default directory. DO NOT enter “undefined” or “null” - simply omit it for the default behavior.Example:
"src/components"Response
Matching file pathsSuccess with matches:No matches:Truncated results (over 100 files):Error:
Usage examples
Find all TypeScript files
Find React components
Find test files
Find config files
Search specific directory
Find markdown files
Common patterns
Find by extension
Find by directory
Find by name pattern
Exclude patterns
Use.gitignore or .ignore files to exclude patterns:
Safety limits
Timeout
Commands timeout after 60 seconds:File limit
Results are limited to 100 files:Sorting
Results are sorted by modification time (newest first):Ripgrep integration
The tool uses ripgrep’s--files mode with glob filtering:
- Respects
.gitignoreautomatically - Uses parallel directory traversal
- Skips binary files
- Handles large codebases efficiently
Auto-installation
If ripgrep is not found, the tool attempts to auto-install:- Checks for
rgin PATH - If not found, downloads platform-specific binary
- Installs to
~/.local/bin/rg - Retries command
- Linux x64/arm64
- macOS x64/arm64
- Windows x64
Error handling
Ripgrep not found
Invalid pattern
- Missing quotes:
**/*.ts(wrong) vs"**/*.ts"(right) - Invalid regex:
[a-(unclosed bracket)
Permission denied
Performance tips
Be specific
Instead of:Use file extensions
Instead of:Search subdirectories
Instead of:Comparison with find
Glob tool vs Unixfind command:
| Feature | glob | find |
|---|---|---|
| Speed | Very fast (ripgrep) | Slower |
| Gitignore | Automatic | Manual |
| Sorting | By mtime | Manual |
| Limits | 100 files, 60s | None |
| Syntax | Glob patterns | Complex expressions |
Implementation details
CLI execution
Executes ripgrep viarunRgFiles():
Result formatting
Results are formatted byformatGlobResult():
- Sorts by modification time
- Truncates to 100 files
- Adds context messages
- Handles empty results