grep.md

 1Fast content search tool that finds files containing specific text/patterns, returning matching paths sorted by modification time (newest first).
 2
 3<usage>
 4- Provide regex pattern to search within file contents
 5- Set literal_text=true for exact text with special characters (recommended for non-regex users)
 6- Optional starting directory (defaults to current working directory)
 7- Optional include pattern to filter which files to search
 8- Results sorted with most recently modified files first
 9</usage>
10
11<regex_syntax>
12When literal_text=false (supports standard regex):
13
14- 'function' searches for literal text "function"
15- 'log\..\*Error' finds text starting with "log." and ending with "Error"
16- 'import\s+.\*\s+from' finds import statements in JavaScript/TypeScript
17  </regex_syntax>
18
19<include_patterns>
20
21- '\*.js' - Only search JavaScript files
22- '\*.{ts,tsx}' - Only search TypeScript files
23- '\*.go' - Only search Go files
24  </include_patterns>
25
26<limitations>
27- Results limited to 100 files (newest first)
28- Performance depends on number of files searched
29- Very large binary files may be skipped
30- Hidden files (starting with '.') skipped
31</limitations>
32
33<ignore_support>
34
35- Respects .gitignore patterns to skip ignored files/directories
36- Respects .crushignore patterns for additional ignore rules
37- Both ignore files auto-detected in search root directory
38  </ignore_support>
39
40<cross_platform>
41
42- Uses ripgrep (rg) if available for better performance
43- Falls back to Go implementation if ripgrep unavailable
44- File paths normalized automatically for compatibility
45  </cross_platform>
46
47<tips>
48- For faster searches: use Glob to find relevant files first, then Grep
49- For iterative exploration requiring multiple searches, consider Agent tool
50- Check if results truncated and refine search pattern if needed
51- Use literal_text=true for exact text with special characters (dots, parentheses, etc.)
52</tips>