scan_patterns
Search any codebase with regex patterns to locate code affected by field, function, or string changes. Returns per-file hits with line numbers for impact analysis.
Instructions
在代码库中搜索任意正则表达式 pattern,支持 Python/TypeScript/JavaScript/任意文本文件。这是最通用的搜索工具,适用于所有变更场景:字段访问、函数调用、字符串值、常量、配置项、API 路径、SQL 字段名、注释、枚举值等任何内容。当用户描述任何类型的代码变更并想知道影响范围时,调用此工具。由 Claude 根据变更描述决定要搜什么 pattern,此工具只负责机械执行搜索。返回按文件聚合的 JSON:{engine, total_found, returned, truncated, files:[{file:相对路径, hits:[{line, code, patterns, confidence}]}]}。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| patterns | Yes | 正则表达式列表,支持任意内容。例如:字段访问: ["machine\.x", "machine\['x'\]"] | 函数调用: ["calculate_distance\("] | 字符串值: ["'success'", "\"failed\""] | 常量: ["STATUS_OK", "MAX_RETRY"] | API路径: ["/api/external/"] | SQL字段: ["survey_status_today"] | 导入: ["from plogen_tools import"] | |
| extensions | No | 文件扩展名,默认 ['.py','.ts','.tsx','.js','.jsx'] | |
| max_results | No | 最大返回结果数,默认 500;truncated=true 时可增大后重试 | |
| exclude_dirs | No | 排除目录,不传则使用默认排除列表(node_modules/.venv/dist 等),传 [] 则不排除任何目录 | |
| project_path | Yes | 项目根目录绝对路径 |