files.regex_search
Find exact regex matches in file contents with line numbers. Use when full-text search misses substrings, URLs, or code identifiers; optionally scan a single known file.
Instructions
Match a JS regex against file bodies. Default mode scans every file in scope (project, KB, or all) and returns per-file hits with line numbers — slower than FTS files.search because it reads each file's content; use only when FTS misses substrings, URLs, or code identifiers. Pass file_id to instead scan just that one file (catches what FTS misses within a single known file); response shape changes to {file_id, path, pattern, match_count, truncated, matches}. Read-only; no side effects, auth, or rate limits. Multi-file mode capped at 500 files / 10 hits per file by default (files_truncated reports the cap); single-file mode capped at 100 hits by default, max 500. project_id/kind are ignored when file_id is set. Invalid regex throws.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kind | No | Filter by content class before scanning. Ignored when `file_id` is set. | |
| file_id | No | Scan only this file instead of every file in scope. When set, `project_id`/`kind`/`max_files`/`max_matches_per_file` are ignored in favor of `max_matches`. | |
| pattern | Yes | JavaScript RegExp source | |
| max_files | No | Cap on files scanned (default 500). Ignored when `file_id` is set. | |
| project_id | No | Scope to one project, null for KB-only, omit for everything. Ignored when `file_id` is set. | |
| max_matches | No | Cap on returned hits in single-file mode (default 100). Only used when `file_id` is set. | |
| case_insensitive | No | If true, match pattern case-insensitively (RegExp 'i' flag). Default false. | |
| max_matches_per_file | No | Per-file hit cap in multi-file mode (default 10). Ignored when `file_id` is set. |