bai
bai AI shell-command helper
natural language in, shell command out

bai keeps the command line sharp.

Describe what you want in plain language. bai returns a proposed shell command, copies it to your clipboard, and leaves the final decision to you. No auto-run. No chat sprawl. Just a fast path from intent to command.

Install Learn
Scope single-shot CLI helper
Safety you approve every command
Providers Anthropic or OpenAI
~/Projects/bai
copied to clipboard, ready to paste or edit

Small tool. Hard edge.

bai does one job: turn a natural-language shell request into a command shaped for your environment. It includes lightweight context such as shell, OS, and current directory so the output fits your machine instead of a generic tutorial example.

Command-first output The default path prints the command to stdout and gets out of the way.
Config without shell-file clutter Use environment variables or drop files in ~/.config/bai/.
Composability JSON mode, clipboard integration, shell overrides, and API docs all stay available without bloating the core UX.

Built for real shells.

Use --shell when editor launchers or wrappers obscure the parent process. Use --strict when guessing is the wrong move. Use --show-config when you need to see exactly what runtime state bai resolved.

--explain Sends a short reason to stderr while keeping stdout pipeline-safe.
--json Returns machine-readable output for wrappers, editors, and tooling.
prompt.md Append your own command preferences without touching the source tree.

Install it the direct way.

Pull a release package if you just want the binary. Build from source if you want to hack on it, read the Crystal code, or generate the API docs. Releases are available on GitHub.

Arch Linux

Download the .pkg.tar.zst asset from the latest release.

sudo pacman -U ./bai-*.pkg.tar.zst

Debian / Ubuntu

Download the .deb asset, then install the package.

sudo dpkg -i ./bai_*.deb
sudo apt-get install -f

From source

Requires Crystal and just.

git clone https://github.com/trans/bai
cd bai
just install

Try it fast

bai count lines of Crystal code in src
bai find files modified in the last day
bai show the largest 10 files under home

Config lives here

~/.config/bai/provider
~/.config/bai/anthropic_api_key
~/.config/bai/openai_api_key
~/.config/bai/shell
~/.config/bai/prompt.md

Alt-Enter trick

Bind bai to Alt-Enter and rewrite your current prompt buffer in place. Type the request, hit the keybinding, edit if needed, then run it.

fish: bind \e\r bai-replace
bash: bind -x '"\e\r": _bai_replace'
zsh:  bindkey '^[^M' _bai_replace
Need the internals? Public Crystal docs are generated into docs/api/ and ship with the site.
Open API docs