How to Build a Harness

11. The `bash` Tool

Let Claude run shell commands.

Lets Claude run arbitrary shell commands. This is optional but dramatically increases capability.

File: packages/mom/src/tools/bash.ts L18-34

const bashSchema = Type.Object({
  label: Type.String({ description: "Brief description of what this command does" }),
  command: Type.String({ description: "Bash command to execute" }),
  timeout: Type.Optional(Type.Number({ description: "Timeout in seconds (optional)" })),
});

The execute function spawns a child process and captures stdout/stderr:

execute: async (_toolCallId, { command, timeout }, signal?) => {
  const result = await exec(command, { timeout, signal });
  return {
    content: [{ type: "text", text: result.stdout + result.stderr }],
  };
};

With bash, the LLM can install packages, run tests, check git status — anything you can do in a terminal.


Open this chapter inside the full course