search_files
Find code and file content by literal or regex pattern with filters for file type, size, date, and comment/string exclusion. Returns text or JSON results with sorting and grouping.
Instructions
Advanced file and code search tool with comprehensive filtering and matching capabilities. Searches files within allowed directories for a required literal or regex pattern, with file type filtering, size constraints, date filtering, and comment/string-aware match suppression (search always runs against the original, unmodified file content). Results can be formatted as text or JSON with configurable sorting and grouping. maxResults caps the total number of returned matches.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Alias for searchPath | |
| sortBy | No | How to sort the results | relevance |
| maxSize | No | Maximum file size in bytes | |
| minSize | No | Minimum file size in bytes | |
| pattern | Yes | Search pattern - literal text or regex depending on regexMode. Required. | |
| maxDepth | No | Maximum directory recursion depth. Unlimited if not specified | |
| multiline | No | Whether to enable multiline regex matching | |
| regexMode | No | Whether to treat pattern as a regular expression | |
| extensions | No | Array of file extensions to include (e.g., ['.js', '.ts', '.py']). Include the dot prefix | |
| maxResults | No | Maximum total number of matches to return (across all files) | |
| searchPath | No | Directory path to search in. Must be within allowed directories. Defaults to first allowed directory if not specified | |
| groupByFile | No | Whether to group results by file | |
| outputFormat | No | Output format for results | text |
| wordBoundary | No | Whether to match whole words only | |
| caseSensitive | No | Whether search should be case sensitive | |
| includeBinary | No | Whether to search in binary files | |
| modifiedAfter | No | Only include files modified after this date (ISO 8601 format) | |
| snippetLength | No | Length of text snippet around matches | |
| excludeStrings | No | Whether to exclude string literals from search | |
| followSymlinks | No | Whether to follow symbolic links | |
| modifiedBefore | No | Only include files modified before this date (ISO 8601 format) | |
| excludeComments | No | Whether to exclude comments from search (language-aware) | |
| excludePatterns | No | Array of filename patterns to exclude (supports simple wildcards) | |
| excludeGenerated | No | Whether to skip code-generated Dart part files (*.g.dart, *.freezed.dart, *.mocks.dart, *.gr.dart, *.i18n.dart) | |
| excludeExtensions | No | Array of file extensions to exclude |