search_in_files
Search active project files for literal or regex matches, skipping gitignored, binary, or oversized files, with context and glob filters to locate every occurrence for verification and replacement prep.
Instructions
Exact scan of current file contents — literal text by default, regex when use_regex=true. Use search_in_files when you need every occurrence, exact verification, audits, or safe replacement prep. Unlike shell grep/rg, results are confined to the active project (no .git/, node_modules/, build artefacts, or anything else .gitignore excludes), binary files are skipped (null-byte sniff of the first 8 KB), files larger than max_file_bytes (50 MiB default) are skipped before opening, globs with a literal directory prefix (e.g. "src/**/*.go") prune sibling directories from the walk. Smart-case (case-insensitive when the pattern is all lowercase), supports context lines and glob file filters.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| glob | No | Glob to restrict which files are searched, e.g. '*.go' or '**/*_test.go' | |
| path | No | Directory to search in (absolute path, file:// URI, or workspace-relative path). Defaults to the workspace root. | |
| exclude | No | Glob patterns for paths to exclude, e.g. ["vendor", "*.pb.go", "testdata/**"]. Matched against the entry's base name and relative path. Matching directories are pruned from the walk; matching files are skipped. | |
| pattern | No | Plain text to search for by default; regular expression when use_regex is true. | |
| use_regex | No | Treat pattern as a regular expression (Go RE2). Default false — pattern is literal text. | |
| max_results | No | Maximum number of matching lines to return. Default 200. | |
| context_lines | No | Number of lines of context to show before and after each match (like rg -C). Default 0. Total output is capped at 200 KiB regardless, and truncation is labelled. | |
| case_sensitive | No | Force case-sensitive matching. Default (omitted): smart-case — case-insensitive when pattern is all lowercase, case-sensitive otherwise. Pass false to force case-INSENSITIVE matching even for an uppercase pattern. | |
| include_hidden | No | Include hidden files and directories (starting with '.'). Default false. | |
| max_file_bytes | No | Skip files larger than this many bytes. Default 52428800 (50 MiB). | |
| include_enclosing_symbol | No | When true and an LSP is available, annotate each match with the deepest enclosing symbol (function, method, type, etc.) from the language server. One LSP query per distinct matched file; results cached within the call. Silently omitted when the LSP is unavailable. |