1Search file contents for text or patterns. Use this instead of shell `grep`.
2
3<when_to_use>
4Use Grep when:
5- Searching for text/patterns across files
6- Finding where a function or variable is used
7- Locating error messages, log strings, or comments
8
9Do NOT use Grep when:
10- Finding files by name → use `glob`
11- Semantic symbol lookup → use `lsp_references` (more accurate)
12- Need to understand code flow → use `agent`
13- Reading a known file → use `view`
14</when_to_use>
15
16<parameters>
17- pattern: Regex pattern (or literal text with literal_text=true)
18- path: Directory to search (default: current directory)
19- include: File pattern filter, e.g., "*.go", "*.{ts,tsx}"
20- literal_text: Set true for exact text with special chars (dots, parens)
21</parameters>
22
23<pattern_tips>
24- Simple text: `"handleLogin"` finds literal matches
25- Regex: `"log\..*Error"` finds log.SomethingError
26- Use `literal_text=true` for text with special chars: `"user.name"` with literal_text finds "user.name" exactly
27</pattern_tips>
28
29<output>
30- Returns matching file paths sorted by modification time (newest first)
31- Limited to 100 files - if results show "at least N matches", refine your query
32- Respects .gitignore and .crushignore
33</output>
34
35<examples>
36Good: `pattern: "func.*Config", include: "*.go"` → Find Go functions with Config in name
37
38Good: `pattern: "TODO", path: "src/"` → Find TODOs in src directory
39
40Bad: `pattern: "*.go"` → This searches content, not filenames. Use `glob` for filenames.
41</examples>