Agent tools

grep

grep({ pattern, path?, glob?, ignore_case?, max_results? })

Search file contents with a regular expression. Returns path, line number and the matching line.

category: readfree100 results by default
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

patternstringrequired

A regular expression.

pathstring

Where to search.

globstring

Only files matching this pattern, e.g. **/*.js.

ignore_caseboolean

Case-insensitive.

max_resultsinteger100

How many matching lines to return.

What comes back

src/auth.js:42: if (!token) throw new Unauthorized();
src/auth.js:88: // TODO: rotate the token here
src/session.js:14: const token = await exchange(key);

Path, line, text — enough for the agent to decide which file to open, without opening any of them.

Narrow with glob, not with a bigger pattern

glob cuts the search; max_results cuts the answer

A pattern that matches a lot in a large tree fills the turn with lines. Restricting the files is cheaper than restricting the output, because the output is what is paid for.

The usual sequence

grep to find where, read { paths } to see the places, edit to change them. Three turns for a change across a project.