search_files
Locate code patterns across files with advanced filtering by regex, type, size, and date. Optionally skip comments and string literals for precise results.
Instructions
Advanced file and code search tool with comprehensive filtering and matching capabilities. Searches for patterns in files within allowed directories with support for regex patterns, file type filtering, size constraints, date filtering, and content preprocessing. When called without arguments, searches for common patterns in the current directory. Supports excluding comments and string literals for cleaner code searches. Results can be formatted as text, JSON, or structured output with configurable sorting and grouping options.
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 | No | Search pattern - can be literal text or regex depending on regexMode. Defaults to searching for common file types if not specified | .* |
| 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 number of match results to return | |
| 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) | |
| excludeExtensions | No | Array of file extensions to exclude |