# Tools

Tools allow Bub to read and write files, run commands, fetch web pages, and manage sessions.

## Built-in tools {#builtin-tools}

The Bub app ships with these built-in tools:

| Category | Tool | Purpose |
| --- | --- | --- |
| **Processes** | `bash` | Run Shell commands with working directory, timeout, and background options |
| | `bash.output`, `bash.kill` | Read background process output incrementally or terminate a process |
| **Files** | `fs.read`, `fs.write`, `fs.edit` | Read files by line range (or images), write whole files, and replace exact text |
| **Web** | `web.fetch` | Send HTTP GET requests to fetch web pages (prefers Markdown) |
| **Discovery** | `skill` | List discovered skills or load a skill's `SKILL.md` body |
| | `tool.describe` | Load the full schema of deferred tools (`deferred=True`) on demand |
| **Session & Tape** | `tape.info`, `tape.search` | Inspect session metrics and token usage, or search session history |
| | `tape.handoff`, `tape.reset` | Advance the context start point, or archive and reset session history |
| | `spill.read` | Read large tool outputs in chunks |
| **Subagents** | [`subagent`](/docs/app/subagents/) | Delegate a task to a background subagent |
| | `subagent.wait`, `subagent.send`, `subagent.cancel` | Wait for subagent results, send follow-up instructions, or cancel a subagent |
| **Code mode** | `run_code` | Compose multiple tools in Python when code mode is enabled |

For full parameter tables and defaults, see the [Built-in tools reference](/docs/reference/tools/).

## How tools are called {#instructions}

In the Bub app, tools can be invoked in two ways:

1. **Called by the model**: ask a question normally, and the model selects and calls tools based on their descriptions.
2. **Called directly from the terminal**: prepend the command prefix (`,` by default) to execute a tool without calling the model or spending tokens:
   ```bash
   bub run ",fs.read path=README.md"
   ```

To guide how the model uses tools:
- **Workspace rules**: add project-wide rules to `AGENTS.md` in the workspace root.
- **Step-by-step workflows**: package multi-step procedures as [skills](/docs/app/skills/).

## Code mode {#code-mode}

For tasks involving loops, conditionals, or batch data processing, repeated tool round-trips consume extra context. With code mode enabled, the model writes Python code (executed via `run_code`) to compose multiple tool calls in a single step:

```text
,code_mode enable=true
```

- Takes effect on the next Turn and persists in the current session Tape.
- Run `,code_mode enable=false` to disable code mode.
- See the [`run_code` reference](/docs/reference/tools/#run-code) for Python call syntax.

## Execution environment and security {#environment}

Built-in tools (`bash`, `fs.*`, and `run_code`) run directly on the local host with the current user's permissions:

- **No default sandbox**: commands executed by the model have real filesystem and process side effects on the host.
- **Approval and interception**: use [tool interception hooks](/docs/app/plugins/#control-a-model-or-tool-call) to require human approval or block dangerous arguments before execution.
- **Isolated environments**: provide a containerized or remote [execution environment](/docs/reference/hooks/#provide_environment) via a plugin when isolation is required.

## Extend tools {#provide-tools}

When the built-in tools are not enough, you can extend Bub in two ways:

- **Install community plugins or MCP servers**: browse [community plugins](https://hub.bub.build/) or [connect MCP servers](/docs/integrations/mcp/).
- **Write custom tool plugins**: register Python functions with `provide_tools` (see [Plugins and Hooks: Provide tools](/docs/app/plugins/#provide-tools)).