search_code
Locate code in a repository by searching file contents, returning file:line matches. Supports literal or regex patterns, glob filters, and context lines.
Instructions
Search file contents across the repository and return matching lines with file:line locations. This is the primary way to find code — far cheaper than reading files. Supports literal or regex patterns, glob filters, and surrounding context lines. Respects .gitignore.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Restrict the search to this subdirectory. | |
| regex | No | Treat pattern as a regular expression. Default false (literal). | |
| exclude | No | Skip files matching these globs. | |
| include | No | Only search files matching these globs, e.g. ["**/*.java", "src/**/*.ts"]. | |
| pattern | Yes | Text to find, or a regular expression when regex=true. | |
| workspace | No | Workspace alias. Defaults to the active workspace. | |
| max_results | No | Default 100, max 1000. | |
| context_lines | No | Lines of context around each match, 0-10. Default 0. | |
| case_sensitive | No | Default false. |