grep to find text, glob to find files — bounded, path-safe, and ripgrep-accelerated when available.
Quick Start
- Python
- YAML
How It Works
| Backend | When used | Notes |
|---|---|---|
ripgrep (rg) | Auto-detected on PATH | Faster; linear-time RE2 engine; 30s timeout |
| Pure-Python | Fallback | Zero deps; regex pattern length capped at 1000 chars |
Configuration Options
grep Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
pattern | str | (required) | Regex or literal string to search for |
path | str | "." | Directory or single file to search under |
glob | str | None | Filename glob to restrict the search (e.g. "*.py") |
case_insensitive | bool | False | Case-insensitive matching when True |
max_results | int | 100 | Hard cap on matching lines returned; invalid/≤0 snaps back to 100 |
path:line: matched line entries (newline-joined), hard-capped with a truncation hint. Returns "No matches found." or "Error: …" on error.
glob Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
pattern | str | (required) | Glob pattern (e.g. "**/*.ts", "src/**/test_*.py") |
path | str | "." | Directory to search under |
max_results | int | 100 | Hard cap on paths returned; invalid/≤0 snaps back to 100 |
"No files found." on empty results.
Common Patterns
Case-insensitive search across.py files only:
Choosing Between grep, glob, and AST-Grep
Best Practices
Install ripgrep for speed (optional)
Install ripgrep for speed (optional)
ripgrep is an optional accelerator — the tools always work without it. Install for significantly faster searches on large codebases.Narrow with glob and path early
Narrow with glob and path early
Both tools default to a cap of 100 results. Use
glob and path to narrow the search before hitting the limit.Read the truncation hint
Read the truncation hint
When results are capped, the last line contains a truncation hint like:Agents can detect this string and automatically refine their query.
Trust .gitignore — it's already honoured
Trust .gitignore — it's already honoured
Both tools automatically respect
.gitignore (including negation patterns like !keep.log and directory-only rules like build/). Noise directories like .git, node_modules, __pycache__, and .venv are always skipped.User Interaction Flow
A typical agent conversation usinggrep and glob:
Related
AST-Grep Tools
Structural code search and rewrite using AST patterns
File Tools
File system operations and management utilities

