8. The `read` Tool
Let Claude read files from disk.
Lets Claude see file contents. This is the most important tool — without it, the LLM is blind.
File: packages/coding-agent/src/core/tools/read.ts L17-21
const readSchema = Type.Object({
path: Type.String({ description: "Path to the file to read (relative or absolute)" }),
offset: Type.Optional(Type.Number({ description: "Line number to start reading from (1-indexed)" })),
limit: Type.Optional(Type.Number({ description: "Maximum number of lines to read" })),
});
The execute function reads from disk, adds line numbers, and truncates large files:
// Minimal read tool implementation
async execute(_toolCallId, { path, offset, limit }) {
const absolutePath = resolve(cwd, path);
const buffer = await readFile(absolutePath);
const content = buffer.toString("utf-8");
// Add line numbers, truncate if needed
return { content: [{ type: "text", text: numberedContent }] };
}
The Amp blog’s read_file is identical in spirit: read from disk, return as string. The pi version adds line numbering and truncation for production use.