find_code
Fast repo-wide pattern search using ripgrep. Use it to find TODOs, error messages, env vars, route names, or any string or regex.
DESCRIPTION
This tool is for location, not explanation. Reach for it when you know roughly what you are looking for but not where it lives.
WHEN TO USE
GOOD FIT
- Finding all usages of an env variable.
- Locating a specific error message or log string.
- Finding route definitions or config keys.
- Hunting down a pattern before narrowing with read_code.
AVOID IT WHEN
- You need the implementation details of a symbol; use read_code.
- You need high-level project orientation; use get_project_context.
- You already know the exact file and symbol you need.
PARAMETERS
| Name | Type | Required | Description |
|---|---|---|---|
| path | string | Yes | Repo root to search recursively. |
| pattern | string | Yes | Search pattern. Regex is supported. |
| file_pattern | string | No | Optional glob such as "*.ts" to narrow the search. |
| case_sensitive | boolean | No | Set true when casing matters. Default is false. |
EXAMPLE
tools-call.json
{ "jsonrpc": "2.0", "id": 6, "method": "tools/call", "params": { "name": "find_code", "arguments": { "path": "/workspace/repo", "pattern": "API_KEY_SALT", "file_pattern": "*.ts" } }}OUTPUT
response.json
{ "jsonrpc": "2.0", "id": 6, "result": { "content": [ { "type": "text", "text": "src/lib/auth.ts:50 API_KEY_SALT environment variable is required\nsrc/app/api/keys/verify/route.ts:18 const salt = process.env.API_KEY_SALT\nsrc/app/api/keys/retrieve/[token]/route.ts:120 derive a dedicated encryption key from API_KEY_SALT" } ] }}TOKEN EFFICIENCY
This tool is efficient because it returns matches instead of whole files. Pair it with read_code only after you know which hit matters.