Glob Tool
The Glob tool finds files by name pattern. It is the fastest way to locate files by extension, naming convention, or directory structure. Results are sorted by modification time (most recently modified first), helping you quickly find recently changed files.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
search_pattern | string | Yes | Glob pattern to match file paths |
search_path | string | No | Directory to search within (default: project root) |
Pattern Syntax
Glob supports the full range of standard pattern syntax:
| Syntax | Description | Example |
|---|---|---|
* | Match any characters in a single path segment | *.ts matches utils.ts, index.ts |
** | Match any characters across path segments (recursive) | **/*.test.ts matches all test files anywhere |
? | Match a single character | page?.tsx matches page1.tsx, pageA.tsx |
[abc] | Match any character in brackets | file[0-9].txt matches file1.txt, file2.txt |
{a,b} | Match either pattern (brace expansion) | *.{ts,tsx} matches all TypeScript files |
Usage Examples
Find by Extension
> Find all TypeScript files in the project
Agent invokes Glob:
search_pattern: **/*.ts
Result:
src/index.ts
src/lib/utils.ts
src/components/Button.tsx
src/__tests__/utils.test.ts
... (92 files)
Find in Specific Directory
> What's in the components directory?
Agent invokes Glob:
search_pattern: *
search_path: src/components
Result:
src/components/Button.tsx
src/components/Header.tsx
src/components/Sidebar.tsx
src/components/Footer.tsx
Find by Naming Convention
> Find all test files
Agent invokes Glob:
search_pattern: **/*.test.{ts,tsx}
Result:
src/__tests__/auth.test.ts
src/__tests__/utils.test.ts
src/__tests__/components/Button.test.tsx
... (15 files)
Find Configuration Files
> Find all config files at any depth
Agent invokes Glob:
search_pattern: **/*config*.*
Result:
next.config.ts
tailwind.config.ts
vitest.config.ts
.eslintrc.config.js
Sorting
Results are sorted by modification time, with the most recently modified files appearing first. This is useful for:
- Finding files that were recently changed
- Identifying active areas of the codebase
- Checking what was modified in the current work session
Limits
- Maximum 100 files returned per call
- If more files match, results are truncated — narrow your pattern or use
search_pathto scope the search - Common non-source directories are automatically excluded
Excluded Directories
The following directories are automatically excluded to keep results focused on source files:
node_modules.gitdistbuild__pycache__venv.nextcoverage- And other common build/output directories
When to Use Glob vs Grep
| Use Glob when... | Use Grep when... |
|---|---|
| You know the file name pattern | You know the content you're looking for |
| Finding files by extension | Finding which files contain a function |
| Discovering project structure | Searching for a specific import |
| Locating config/test files | Finding all usages of a variable |
Tip: Glob and Grep are often used together. First use Glob to find candidate files, then use Grep to find specific content within them, or Read to examine them.
Common Patterns
Find all source files in a language:
**/*.ts # TypeScript
**/*.py # Python
**/*.go # Go
**/*.rs # Rust
Find specific file types:
**/*.{ts,tsx} # All TypeScript + TSX
**/*.{css,scss} # All stylesheets
**/*.{json,yaml} # Config files
Find files at a specific depth:
src/*/index.ts # index.ts one level deep in src
src/**/index.ts # index.ts at any depth in src
Find recently modified Markdown:
**/*.md # All markdown files (sorted by mtime)
Scoped search:
*.test.ts # Files ending with .test.ts in root only
**/*.test.ts # Files ending with .test.ts anywhere
Next Steps
- Grep — Searching file contents with regex
- Read — Reading files found by Glob
- Tools Overview — All available tools