Overview
The Glob tool finds files matching name patterns using glob syntax. Results are sorted by path length (shortest first) to prioritize files in the current directory. It’s ideal for discovering files when you know their name pattern.Parameters
The glob pattern to match against file paths. Supports wildcards and brace expansion.
The directory to search in. Defaults to the current working directory.
Pattern Syntax
Wildcards
*- Matches any sequence of non-separator characters**- Matches any sequence including separators (directory traversal)?- Matches any single non-separator character[abc]- Matches any character in the brackets[!abc]- Matches any character not in the brackets[a-z]- Matches any character in the range
Brace Expansion
{a,b,c}- Matches any of the comma-separated patterns{*.js,*.ts}- Matches files ending in .js or .ts
Examples
Features
Gitignore Support
Glob automatically respects:.gitignorepatterns in the search directory.crushignorepatterns for additional filtering
Hidden Files
Hidden files (starting with.) are automatically skipped to match standard tool behavior.
Performance
Glob uses:- Ripgrep (rg) if available for fast file system traversal
- Go implementation as fallback with doublestar matching
- Result limit of 100 files to prevent overwhelming output
Sorting
Results are sorted by path length (shortest first):Usage Examples
Find JavaScript Files
Find TypeScript Files
Find Config Files
Find Test Files
Find in Specific Directory
Output Format
Glob returns a list of file paths:Common Patterns
Source Files
Test Files
Configuration Files
Documentation
Best Practices
Pattern Design
- Start specific - Begin with narrow patterns, broaden if needed
- Use brace expansion - Combine related extensions
- Anchor patterns - Use
**/to search subdirectories explicitly - Test patterns - Try simple patterns first, add complexity
Efficiency
- Limit scope - Search specific directories when possible
- Be specific - More specific patterns = faster, fewer results
- Use path parameter - Narrow search to relevant directories
- Check truncation - Refine pattern if results are truncated
Workflow Integration
- Combine with Grep - Find files with Glob, search contents with Grep
- Before editing - Find files to modify
- After changes - Verify files exist in expected locations
- Project exploration - Discover file organization
Permissions
Glob does not require permissions when:- Searching within the working directory
- Reading directory listings
Cross-Platform Notes
Path Separators
Always use forward slashes/ in patterns:
- ✅
src/**/*.js - ❌
src\\**\\*.js
- Windows:
C:/Users/name/file.js - Unix:
/home/user/file.js
Hidden Files
Hidden files (starting with.) are skipped on all platforms.
Case Sensitivity
- Unix/Linux/macOS - Case-sensitive matching
- Windows - Case-insensitive matching
Troubleshooting
No Files Found
- Check pattern syntax
- Verify search path exists
- Check if files are in .gitignore
- Try simpler pattern (e.g.,
*to see all files) - Use LS to verify directory contents
Too Many Results
- Make pattern more specific
- Add file extension to pattern
- Specify a narrower search path
- Check if pattern is too broad
Missing Expected Files
- Check .gitignore and .crushignore
- Verify files aren’t hidden (starting with
.) - Check file extension matches pattern
- Verify search path is correct
Performance Issues
- Narrow search with path parameter
- Make pattern more specific
- Check if searching very large directories
- Install ripgrep for better performance
Glob vs Other Tools
Glob vs Grep
Use Glob when:- Finding files by name
- File path pattern matching
- Discovering file structure
- You know the filename pattern
- Searching file contents
- Finding specific code patterns
- Text pattern matching
- You know what text to find
Glob vs LS
Use Glob when:- Finding files by pattern
- Searching across subdirectories
- Specific file extensions
- File discovery
- Viewing directory structure
- Seeing file organization
- Exploring unfamiliar directories
- Hierarchical view needed
Glob vs Bash find
Use Glob tool:- Respects .gitignore automatically
- Sorted by path length
- Integrated into Crush workflow
- Simple pattern syntax
- Cross-platform consistent
- Complex search criteria
- File attribute testing (size, time, permissions)
- Executing actions on results
- Advanced filtering
Advanced Patterns
Exclude Patterns
Glob doesn’t support negation directly, but you can:- Use .crushignore to exclude patterns
- Combine with more specific patterns
- Use Grep after Glob for content filtering
Multiple Extensions
Nested Patterns
Specific Depths
Common Workflows
File Discovery
- Use Glob to find files by name pattern
- View files to understand contents
- Edit or modify as needed
Batch Operations
- Use Glob to find all target files
- Iterate through results with multiple edits
- Verify changes by viewing files
Code Navigation
- Use Glob to find implementation files
- Use Grep to search their contents
- Use View to read specific files
- Follow imports with more Glob searches
Project Structure
- Use LS to see overall structure
- Use Glob to find specific file types
- Use Grep to understand usage patterns
- Document findings for future reference