name: mgrep description: "Semantic search for code and web. Use mgrep for natural-language/intent queries and web search. Use built-in Grep for exact strings/regex. Use Glob for file names."
Search Tool Selection
mgrep is ONE of your search tools, not a replacement for all of them. Choose the right tool:
| Tool | When | Examples |
|---|---|---|
| mgrep | Semantic/intent queries, natural language | "where is authentication handled", "how do payments work" |
| mgrep --web --answer | Web search (replaces WebSearch) | "React 19 server components API", "OWASP top 10 2025" |
| Grep (built-in) | Exact strings, regex patterns, literal matches | class UserAuth, def.*process, TODO:, import foo |
| Glob (built-in) | Finding files by name/path pattern | **/*.ts, src/components/**/*.tsx, **/test_*.py |
Decision Tree
What are you looking for?
|- A file by name/path pattern?
| -> Glob (built-in)
|
|- An exact string or regex in file contents?
| -> Grep (built-in)
| Examples: class names, function signatures, imports, error strings
|
|- Something described by intent or meaning?
| -> mgrep "your natural language query"
| Examples: "where do we validate user input", "rate limiting logic"
|
|- Information from the web?
-> mgrep --web --answer "your query"
How to Use mgrep
Run via Bash. No need to cd anywhere — it works from any directory.
Local semantic search
mgrep "What code parsers are available?"
mgrep "How are chunks defined?" src/models
mgrep -m 10 "What is the maximum number of concurrent workers?"
Web search
mgrep --web --answer "How to configure Tailwind v4 dark mode"
Always use --web with --answer together.
Good queries (natural language, descriptive)
mgrep "How does the authentication flow work?"
mgrep "Where are database migrations defined?"
Bad queries (too vague or too literal)
mgrep "parser" # Too vague — use a more specific query
mgrep "class UserAuth" # Too literal — use Grep for exact strings
Common Mistakes
Using mgrep for exact matches:
- Bad:
mgrep "class UserAuth"— wastes semantic search on a literal string - Good: Grep for
class UserAuth— instant, exact, no ambiguity
Using Grep for semantic queries:
- Bad: Grep for
authenticationhoping to find all auth-related code - Good:
mgrep "where is authentication handled"— finds conceptually related code
Using mgrep when Glob suffices:
- Bad:
mgrep "find all TypeScript test files" - Good: Glob for
**/*.test.ts
Keywords
semantic search, web search, search the web, look up online, internet search, online search, search, local files, local search, natural language search