Lesson 10.02 · Phase 10 · Coding & Computer-Use Agents

File read, edit & search tools

A model can't see your editor. All it has is what your tools print. Good file tools page long files with line numbers, cap search results and say how many were hidden, edit by exact unique match, refuse edits to files the model hasn't read (or that changed since), and turn every failure into a message that tells the model what to do next.

Learning objectives

  • Implement readfile with line numbers, paging, long-line truncation and binary detection.
  • Implement a search that skips vendored directories, caps results and reports how many it hid.
  • Implement exact-match editfile with uniqueness checks, a read-before-edit guard, diffs and undo.
  • Write failure messages that tell the model the next action, and recognise the short-old pitfall.

Give a model open(path).read() and path.writetext(content) and watch what happens. It reads a 4,000-line file into its context and forgets the top. It rewrites a whole file to change one line and drops a function it never saw. It edits config.py after another process changed it, and silently reverts that change. It searches for get( and drowns in 3,000 matches from nodemodules.

Loading the full lesson…