This file provides guidance for Claude Code when working on this project.
bash-tool is a generic bash tool for AI agents, compatible with AI SDK (https://ai-sdk.dev/). It provides bash, readFile, and writeFile tools that work with a sandboxed environment.
pnpm build # Compile TypeScript to dist/
pnpm typecheck # Type check without emitting
pnpm test # Run tests in watch mode
pnpm test:run # Run tests once
pnpm lint # Check with Biome
pnpm lint:fix # Fix lint issues
pnpm knip # Check for unused exports/dependencies
pnpm validate # Run all checks (lint, knip, typecheck, test)src/index.ts- Public exports only (createBashTooland types)src/tool.ts- MaincreateBashTool()function that orchestrates everything
Sandbox- Abstract interface for sandbox implementations (executeCommand, readFile, writeFile, stop)CreateBashToolOptions- Configuration for createBashToolBashToolkit- Return type with tools and sandbox instance
just-bash.ts- Default adapter using just-bash (optional peer dependency)vercel.ts- Adapter wrapping @vercel/sandbox instances
bash.ts- Execute bash commands with contextual LLM instructionsread-file.ts- Read file contentswrite-file.ts- Write files
loader.ts- Loads files from inline content or disk directories
-
Optional peer dependencies: just-bash and @vercel/sandbox are optional. Dynamic imports with helpful error messages when not installed.
-
Destination directory: All files go to
destination(default:/workspace). This is also the working directory for commands. -
Contextual instructions: The bash tool generates LLM instructions that include the working directory and list of available files.
-
Sandbox auto-detection: The
sandboxparameter auto-detects both@vercel/sandboxinstances (checks forshellsandkill) and just-bashBashinstances (checks forexecmethod). Users can also provide a customSandboximplementation.
Tests are co-located with source files (*.test.ts). Tests are included in TypeScript compilation for type checking.
- Unit tests mock just-bash
- Integration tests (
tool.integration.test.ts) use real just-bash
AI SDK tool execute calls require ToolExecutionOptions with toolCallId and messages.