bashkit
A sandboxed bash interpreter for AI agents
What it is and what it does
Bashkit embeds a bash interpreter directly into Python via Rust native bindings, letting you execute bash scripts and commands in-process without spawning subprocesses or containers. It maintains persistent state (variables, working directory, virtual filesystem) across calls and includes 164 built-in commands like grep, sed, awk, jq, curl, and find. The package is designed for AI agents and automation workflows where you need fast, controlled bash execution with a virtual filesystem layer.
The interpreter supports full bash syntax—pipelines, redirects, loops, functions, arrays—and offers both synchronous and asynchronous execution modes. You can mount real filesystem paths (read-only or writable), pre-populate virtual files, stream output via callbacks, and control network access through an explicit allowlist. Credentials can be injected transparently or via environment variable placeholders. It integrates with LangChain, PydanticAI, and Deep Agents for agent-based workflows.
Use it for:
- Run bash scripts inside AI agents without subprocess overhead or container orchestration.
- Execute untrusted bash code in a sandboxed environment with controlled filesystem and network access.
- Maintain bash interpreter state (variables, cwd, mounted files) across multiple Python function calls.
- Stream live bash output during execution via callbacks for real-time monitoring or logging.
- Inject secrets and credentials into bash scripts transparently without exposing them to the script itself.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Bashkit is a sandboxed bash interpreter for Python that runs bash scripts in-process with native bindings to a Rust core, providing full bash syntax support and 164 built-in commands without containers or subprocess overhead.
Yes, if you need in-process bash execution for AI agents or automation. The active maintenance, zero runtime dependencies, permissive MIT license, and no known vulnerabilities make it low-risk. Medium install friction (compiled wheels) is typical for Rust-backed packages and not a blocker. Verify performance and sandboxing guarantees match your threat model before deploying to production.
Install
bashkit on PyPI
pip
pip install bashkituv
uv add bashkitpoetry
poetry add bashkitInstalling bashkit
Before you install
Medium install friction due to compiled wheels (cp39-abi3 bindings across multiple platforms). Active maintenance with a release 7 days ago and 236 repository stars. Supports Python 3.9 through 3.14 with no runtime dependencies, making it straightforward to add once installed.
License in practice
MIT license (permissive) means you can use, modify, and distribute bashkit freely in commercial or proprietary projects with minimal restrictions—only attribution is required.
Quickstart
from bashkit import Bash
bash = Bash()
result = bash.execute_sync("echo 'Hello, World!'")
print(result.stdout) # Hello, World!
Requires Python 3.9 or later; compiled wheels are provided for macOS (x86_64, arm64), Linux (x86_64, aarch64, musl), and Windows (x86_64).
Verify before relying
- Performance characteristics and memory overhead compared to subprocess-based bash execution.
- Completeness of the 164 built-in commands and edge cases in bash syntax compatibility.
- Security audit status and threat model documentation for the sandboxing guarantees.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 7 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 272,145/month — #8,211 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: bashkit-0.16.0-cp39-abi3-macosx_10_12_x86_64.whl; bashkit-0.16.0-cp39-abi3-macosx_11_0_arm64.whl; bashkit-0.16.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; bashkit-0.16.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; bashkit-0.16.0-cp39-abi3-musllinux_1_1_aarch64.whl; bashkit-0.16.0-cp39-abi3-musllinux_1_1_x86_64.whl; bashkit-0.16.0-cp39-abi3-pyemscripten_2025_0_wasm32.whl; bashkit-0.16.0-cp39-abi3-win_amd64.whl
Keywords: bash, sandbox, ai, agent, shell, interpreter
Tags
More Security packages
Provides Python bindings to the FreeDesktop.org…
permissive · top 1,000 on PyPI
msalMSAL for Python handles OAuth2 and OpenID…
permissive · top 1,000 on PyPI
joserfcjoserfc implements JOSE standards (JWS, JWE,…
permissive · top 1,000 on PyPI
AuthlibAuthlib provides a complete implementation of…
permissive · top 1,000 on PyPI
argon2-cffi-bindingsProvides low-level CFFI bindings to the…
permissive · top 1,000 on PyPI
adalADAL for Python authenticates applications with…
permissive · top 1,000 on PyPI
starlark-pyo3Exposes the Starlark interpreter (a Python-like…
unclear · top 15,000 on PyPI
bashProvides a Python wrapper for running bash…
copyleft · top 15,000 on PyPI
pydantic-monty-runtimeProvides the `monty` command-line binary, a…
permissive · top 15,000 on PyPI
contree-sdkPython SDK for ConTree, a container runtime…
permissive · top 15,000 on PyPI
executorWraps Python's subprocess module to simplify…
permissive · top 15,000 on PyPI
quickjs-rsExecutes JavaScript code inside a WebAssembly…
permissive · top 15,000 on PyPI
hyperlight-sandboxHyperlight-sandbox provides a Python API for…
permissive · top 15,000 on PyPI
deepagents-codeA terminal-based AI coding agent that works…
permissive · top 15,000 on PyPI
swe-rexSWE-ReX provides a runtime interface for AI…
permissive · top 5,000 on PyPI
spurProvides a unified Python interface to run…
permissive · top 15,000 on PyPI