search_code
Search file contents by regex or literal text, returning path, line, column, and text matches. Supports context lines, per-file limits, and files-only mode for quick surveys.
Instructions
Search file contents and return structured path, line, column, and text matches. Uses ripgrep when installed and falls back to a built-in scanner otherwise. Supports surrounding context lines, a per-file match cap, and a files-only mode for cheap surveys.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | File or directory to search; defaults to the workspace. | |
| globs | No | Include globs such as **/*.ts, or exclude globs prefixed with "!". | |
| literal | No | Treat pattern as literal text instead of a regular expression. | |
| pattern | Yes | Regular expression, or literal text when "literal" is true. | |
| files_only | No | Return only the list of matching file paths. | |
| timeout_ms | No | Search timeout in milliseconds. | |
| max_results | No | Maximum returned matches. | |
| context_lines | No | Lines of surrounding context to include with each match. | |
| case_sensitive | No | Use case-sensitive matching; defaults to true. | |
| max_matches_per_file | No | Stop after this many matches in each file. |