bash-tool
CLAUDE.md626 starsChanged 11 months agoMITView on GitHub
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. Tests are co-located with source files (*.test.ts). Tests are included in TypeScript compilation for type checking. AI SDK tool execute calls require ToolExecutionOptions with toolCallId and messages.
The file
We split this CLAUDE.md into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 49
Destination directory: All files go to destination (default: /workspace).
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance for Claude Code when working on this project.
Project Overview
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.
Commands
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)Architecture
Entry Point
src/index.ts- Public exports only (createBashTooland types)src/tool.ts- MaincreateBashTool()function that orchestrates everything
Core Interfaces (src/types.ts)
Sandbox- Abstract interface for sandbox implementations (executeCommand, readFile, writeFile, stop)CreateBashToolOptions- Configuration for createBashToolBashToolkit- Return type with tools and sandbox instance
Sandbox Adapters (src/sandbox/)
just-bash.ts- Default adapter using just-bash (optional peer dependency)vercel.ts- Adapter wrapping @vercel/sandbox instances
Tools (src/tools/)
bash.ts- Execute bash commands with contextual LLM instructionsread-file.ts- Read file contentswrite-file.ts- Write files
File Loading (src/files/)
loader.ts- Loads files from inline content or disk directories
Key Design Decisions
- 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.
Testing
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.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

