count_occurrences
Count total occurrences and file count for a search pattern in one call without loading file content. Supports filters like language, file path, glob patterns, and symbol kind.
Instructions
Count-only statistics for a pattern. Prefer this over piping grep -c / wc -l / rg --count — returns total occurrences and file count in one call without loading any content.
Use this for: "how many times is X used?"; impact checks before refactoring; validating search scope. Returns {total, files, pattern}. Supports all filters (lang, file, glob, exclude, symbols, kind).
Example: {"total": 87, "files": 12, "pattern": "CourtCase"}. On "Index not found" / "stale" error, call index_project, then retry.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | No | Filter by file path substring | |
| glob | No | Include files matching patterns | |
| kind | No | Filter by symbol kind (function, class, etc.) | |
| lang | No | Filter by language | |
| force | No | Force execution of potentially expensive queries (bypasses broad query detection) | |
| exclude | No | Exclude files matching patterns | |
| pattern | Yes | Search pattern (text to find) | |
| symbols | No | Count symbol definitions only (not usages) | |
| dependencies | No | Include dependency information (imports) in results. Only extracts static imports. |