Fast file pattern matching tool that works with any codebase size.
- Searches within configured allowed directories only
- Paths can be relative to allowed directories; paths outside will be rejected
- Supports glob patterns like "**/*.js" or "src/**/*.ts"
- Returns matching file paths sorted by modification time (newest first)
- Respects .gitignore rules
- Use this tool when you need to find files by name patterns
- When you are doing an open-ended search that may require multiple rounds of globbing and grepping, use the Task tool instead
### Parameters
- `pattern`: Glob pattern to match files against (required)
- `*` matches any characters except path separators
- `**` matches any characters including path separators (recursive)
- `?` matches a single character
- `[abc]` matches any character in the brackets
- `{a,b}` matches either pattern
- `path`: Directory path to search in - can be relative or absolute within allowed directories (required)
### When to Use This Tool
- Finding files by extension: `**/*.rs`, `**/*.tsx`
- Finding files by name pattern: `**/test_*.py`, `**/*_spec.js`
- Locating configuration files: `**/Cargo.toml`, `**/package.json`
- Finding files in specific directories: `src/**/*.rs`
### When NOT to Use This Tool
- Searching for content inside files - use Grep instead
- Reading file contents - use Read instead
- Complex multi-step searches - use Task tool instead
### Examples
Find all Rust files:
```
pattern: "**/*.rs"
path: "."
```
Find all test files:
```
pattern: "**/test_*.py"
path: "."
```
Find TypeScript and TSX files:
```
pattern: "**/*.{ts,tsx}"
path: "src"
```
Find Cargo.toml files anywhere:
```
pattern: "**/Cargo.toml"
path: "."
```
### Best Practices
1. You can call multiple tools in a single response. It is always better to speculatively perform multiple searches as a batch that are potentially useful.
2. Start with broader patterns and narrow down if needed
3. Use `**` for recursive searches across all subdirectories
4. Combine with Read tool to examine found files
5. Results are sorted by modification time - most recently changed files appear first
6. Paths outside allowed directories will be rejected