# Tools

Clew provides 50+ built-in tools plus dynamically loaded MCP tools. Tools are invoked by the AI model via `tool_use` blocks and executed through the StreamingToolExecutor with permission gating.

## How Tools Work

Tools are defined with Zod schemas in `src/Tool.ts` via the `buildTool()` helper and registered in `src/tools.ts`. Each tool declares its input schema, output schema, concurrency safety, read-only status, and permission requirements.

    Model emits tool_use
      Tool call normalization (toolCallParser.ts)
      Permission check (permissions.ts)
      PreToolUse hooks (plugins)
      Tool execution (StreamingToolExecutor)
      PostToolUse hooks (plugins)
      Result returned as tool_result
      Query loop continues

## File & Code Operations

Tool | Description | Schemas
--- | --- | ---
`Read` (FileReadTool) | Read files with line numbers, supports images, PDFs, Jupyter notebooks | Zod
`Write` (FileWriteTool) | Create new files with full content | Zod
`Edit` (FileEditTool) | Exact string replacement edits (surgical, diff-based) | Zod
`Glob` (GlobTool) | Fast file pattern matching, sorted by modification time | Zod
`Grep` (GrepTool) | Regex content search with context lines and multiline support | Zod
`NotebookEdit` (NotebookEditTool) | Edit Jupyter notebook cells (replace, insert, delete) | Zod
`JsonPath` (JsonPathTool) | Query, validate, format, and transform JSON data | Zod

## Shell & System

Tool | Description
--- | ---
`Bash` (BashTool) | Execute shell commands with timeout, background, sandbox support, and permission gating
`PowerShell` (PowerShellTool) | PowerShell execution on Windows (feature-gated)
`Monitor` (MonitorTool) | Stream stdout/stderr from background tasks in real-time
`TaskOutput` (TaskOutputTool) | Get output from running or completed tasks
`TaskStop` (TaskStopTool) | Stop running background tasks

## Search & Web

Tool | Description
--- | ---
`WebSearch` (WebSearchTool) | Multi-provider web search (Tavily, Brave, Serper, SearXNG, DuckDuckGo)
`WebFetch` (WebFetchTool) | Fetch and analyze content from specific URLs
`SessionSearch` (SessionSearchTool) | Full-text search across past session transcripts
`CodeIndex` (CodeIndexTool) | Fuzzy code search across indexed codebase (feature-gated: CODE_INDEX)
`ToolSearch` (ToolSearchTool) | Keyword search for deferred/lazy-loaded tools

## Browser & Automation

Tool | Description
--- | ---
`Browser` (BrowserTool) | Stealth Playwright browser — navigate, click, type, screenshot, extract, fill forms
`ComputerUse` (ComputerUseTool) | Windows-only computer use automation (feature-gated: ENABLE_COMPUTER_USE)

## Agent & Task Management

Tool | Description
--- | ---
`Skill` (SkillTool) | Invoke skills and prompt-type commands by name
`AskUserQuestion` (AskUserQuestionTool) | Ask the user interactive questions during execution
`SendMessage` (SendMessageTool) | Send messages between agents in coordinator mode
`EnterPlanMode` (EnterPlanModeTool) | Enter structured plan mode for complex tasks
`ExitPlanMode` (ExitPlanModeV2Tool) | Exit plan mode and proceed with implementation
`EnterWorktree / ExitWorktree` | Create/exit isolated git worktrees (feature-gated)
`TaskCreate / TaskGet / TaskUpdate / TaskList` | Structured task tracking (V2 todo system)
`TodoWrite` (TodoWriteTool) | Write todo items for task tracking
`Config` (ConfigTool) | Configuration management (ant-only)
`Brief` (BriefTool) | Generate brief summaries

## Scheduled Tasks

Scheduled tasks can be created from the interactive `/task` form. The form collects a name, project, schedule type, prompt, and storage mode, then creates the matching cron task through the same scheduling runtime used by `CronCreate`, `CronList`, and `CronDelete`.

User action | Behavior
--- | ---
`/task` | Open the interactive scheduled task form
Select `Daily` around `09:00` | Create a recurring daily task
Select `Weekdays` around `09:00` | Create a weekday cron such as `0 9 * * 1-5`
Select `In N minutes` with `10` | Create a one-shot reminder
Select `Custom cron` | Use a standard 5-field cron expression
`/task scheduled` | Open the same form explicitly

- Durable storage persists tasks to `.claude/scheduled_tasks.json` across sessions.
- Session-only storage keeps tasks in memory for the current session only.
- Recurring tasks auto-expire after 30 days unless they are system-created permanent tasks.
- One-shot tasks auto-delete after firing.
- Natural language scheduling can still use the model-facing cron tools directly.

    /task
    Name: Server status
    Schedule: Daily
    Time: 20:00
    Prompt: Check the server status
    Storage: Durable

## MCP (Model Context Protocol)

Tool | Description
--- | ---
`ListMcpResources` (ListMcpResourcesTool) | List available resources from connected MCP servers
`ReadMcpResource` (ReadMcpResourceTool) | Read resources exposed by MCP servers
MCP-provided tools | Dynamically loaded tools from MCP servers (filesystem, database, APIs)

## Feature-Gated Tools

Tool | Flag | Description
--- | --- | ---
`LSP` (LSPTool) | `ENABLE_LSP_TOOL=1` | Language Server Protocol integration
`ComputerUse` | `ENABLE_COMPUTER_USE=1` (Win) | Windows GUI automation
`CodeIndex` | `CODE_INDEX` feature | Fuzzy code search
`EnterWorktree / ExitWorktree` | Worktree mode | Git worktree isolation
`TeamCreate / TeamDelete / RequestShutdown` | Agent swarms | Multi-agent team management
`SubscribePrActivity / UnsubscribePrActivity` | Agent swarms | PR activity monitoring
`CronCreate / CronDelete / CronList` | `AGENT_TRIGGERS` | Scheduled task triggers
`PushNotification` | `KAIROS` | Push notification support

## Tool Safety & Permissions

Each tool declares:

- isEnabled() — Whether the tool is available in the current build
- isConcurrencySafe() — Can run in parallel with other tools
- isReadOnly() — Does not modify filesystem
- isDestructive() — Performs irreversible operations
- checkPermissions() — Tool-specific permission logic
- validateInput() — Input validation before execution
- maxResultSizeChars — Max result size before disk persistence

MCP tools from external servers are merged into the tool pool at runtime via `assembleToolPool()`. Tools are filtered by deny rules from the permission context.

CLAUDE_CODE_SIMPLE mode Setting `CLAUDE_CODE_SIMPLE=1` or using `--bare` limits tools to a minimal set: `Bash`, `Read`, `Edit`.