list_locations
Discover file and line locations where a pattern appears without loading code content. Returns array of {path, line} objects for efficient exploration.
Instructions
Fast location discovery with minimal token usage.
Purpose: Find where a pattern occurs (file + line) without loading previews or detailed context.
Returns: Array of {path, line} objects - one per match location.
Use this when:
Starting exploration ("where is X used?")
Counting affected locations
Building a list for targeted Read operations
You need locations only, not code content
Workflow:
Use list_locations to discover (cheap, returns locations only)
Use Read tool or search_code on specific files if you need content (targeted)
Supports: lang, file, glob, exclude filters No limit: Returns ALL matching locations
Error Handling: If you receive an error message containing "Index not found" or "stale", immediately call the index_project tool, wait for it to complete, then retry this operation.
Example: Pattern "CourtCase" → [{"path": "app/Models/CourtCase.php", "line": 15}, {"path": "app/Http/Controllers/CourtController.php", "line": 42}]
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dependencies | No | Include dependency information (imports) in results. Only extracts static imports. | |
| exclude | No | Exclude files matching patterns (e.g., ['vendor/**', 'tests/**']) | |
| file | No | Filter by file path substring (e.g., 'Controllers') | |
| force | No | Force execution of potentially expensive queries (bypasses broad query detection) | |
| glob | No | Include files matching patterns (e.g., ['app/**/*.php']) | |
| lang | No | Filter by language (php, rust, typescript, python, etc.) | |
| pattern | Yes | Search pattern (text to find) |