whatcmd turns plain English into the right shell command, on your prompt, written for your OS and installed tools. It runs on a local model, looks things up on the web only when the local answer fails, and never runs anything until you press Enter.
- Never runs anything. The command lands on your prompt; you read it, edit it, or press Enter.
- Knows your machine. OS, shell, GNU vs BSD flags, installed tools and their man pages go into the prompt.
- Refine with
/w+./w+ only pdfs,/w+ fix that: change the last command instead of retyping it. - Local-first. Ollama on your machine, no API keys. Only a request the model gets wrong is looked up, through tiny-browse.
You usually know what you want to do in a terminal, just not the exact flags. With whatcmd you type the request at your prompt and press Enter:
$ /w find files bigger than 100MB ← press Enter
$ find . -type f -size +100M ← your line is replaced; Enter again runs it
The command is generated by a local model through Ollama. There are no API keys or accounts. Requests the local model answers correctly never leave your computer; only one it gets wrong may be looked up on the web, and you can turn that off.
| Never runs anything by itself | The command lands on your prompt. You read it, edit it, or press Enter. |
| Knows your system | Detects OS, distro, shell, package manager, GNU vs BSD userland and installed tools, so on macOS you get sed -i '' and vm_stat, not Linux-only flags. |
| Grounded in local docs | When your request names an installed program (jq, ffmpeg, kubectl…) or package, the matching lines of its man page or --help go into the prompt. |
| Web lookup only when it fails | Built in through tiny-browse. Only a request the local model gets wrong is looked up: big CLIs whose --help is too shallow (kubectl, helm, gcloud…) get matching lines from their official reference, other requests a web search. Search engines' rate limits are respected. |
| Quiet when it should be | "tell me a joke" or "what is the capital of France" produce nothing. Chat replies, calculator answers and prompt injections are filtered out. |
| Warns before damage | rm -r, dd, mkfs, curl | sh, git push --force, world-writable chmod and placeholders like /path/to/… are flagged. |
| Private and fast | Runs offline after setup for everything the local model gets right (whatcmd config set web false for always). About 0.2 s per request end to end on an Apple M4 Pro. |
Requirements: Node.js 22+, macOS or Linux, and bash 4+ or zsh for the shortcut. Any shell can use whatcmd <request>. For web search, an installed Chrome, Chromium, Edge or Brave (optional: without one, only the built-in reference pages are used).
npm install -g @shubhamcodess/whatcmd
whatcmd initOther ways to install
pnpm / yarn / bun
pnpm add -g @shubhamcodess/whatcmd
yarn global add @shubhamcodess/whatcmd
bun add -g @shubhamcodess/whatcmdRelease tarball. Every release attaches the installable package to its GitHub release. It's the same file CI builds and tests:
npm install -g ./shubhamcodess-whatcmd-1.0.0.tgz # use the version you downloadedFrom source
git clone https://github.com/shubhamcodess/whatcmd
cd whatcmd
npm ci # installs dependencies (incl. tiny-browse) and builds dist/
npm test # unit tests
npm install -g .whatcmd init walks you through everything once:
- Detects your system and saves it to your profile.
- Checks Ollama. If it's missing, it shows the install command for your OS and offers to run it; if it's stopped, it offers to start it.
- Lets you pick a model (recommended ones, any you already have, or any name from the Ollama library) and downloads it.
- Runs a test request and reports the speed.
- Adds the
/wshortcut to~/.zshrcor~/.bashrc.
Open a new terminal and type /w <request>. Web lookup is on by default and only used when the local answer fails; whatcmd config set web false keeps everything local.
| You type | What happens |
|---|---|
/w <request> then Enter |
A spinner shows after your request while it works, then your line is replaced by the command. Press Enter again to run it. If nothing was generated, the next Enter clears the line. |
whatcmd <request> |
Prints the command and asks [r]un, re[f]ine, [q]uit?. |
whatcmd --raw -- <request> |
Prints only the command, for scripts. Exit code 2 if it isn't a shell task. |
No quotes needed, even with ', > or * in the request: the shortcut reads your line before the shell parses it.
whatcmd "what's using port 8080"
whatcmd --raw -- list the 5 biggest folders in this directory$ /w find files bigger than 100MB → find . -type f -size +100M
$ /w+ only pdfs → find . -type f -size +100M -name "*.pdf"
$ /w+ only in ~/Downloads → find ~/Downloads -type f -size +100M -name "*.pdf"
$ /w+ show only the top 3 → … | head -n 3
/w+ <change>changes the last command from this terminal tab;/walways starts fresh.- If you edited and ran the command before refining, your edited version is the one that gets changed.
- After a failed run,
/w+ fix thatknows the exit status. - Up to 5 refinements, then whatcmd asks you to start fresh with the full request. The context expires after 15 minutes and is never shared between tabs.
- Without the shortcut,
whatcmd <request>asks[r]un, re[f]ine, [q]uit?after each command.
Some CLIs ship almost no local docs: kubectl --help lists get and rollout but none of their flags, so the model has to guess. When the local answer fails, whatcmd looks the request up with tiny-browse (installed with whatcmd, uses your Chrome) and gives the model the matching command lines:
$ whatcmd --no-web kubectl show rollout history of deployment web
whatcmd: not a shell task, nothing generated
$ whatcmd --web kubectl show rollout history of deployment web
kubectl rollout history deployment/web
used web docs from kubernetes.io
whatcmd config set web false # stay fully local (or per request: --no-web, or WHATCMD_WEB=0)
whatcmd doctor # browser found? search engines rate-limited right now?On the 40 cloud-CLI benchmark cases (npm run eval:web, qwen2.5-coder:1.5b, cold cache): 22 / 40 correct with web off, 25 / 40 with web on, with 5 requests looked up. Median time 282 ms → 204 ms, p95 0.9 s → 1.3 s. The 48 everyday cases, the 35 refusal cases and the 12 refinement chains score the same with web on and off (35 / 48, 34 / 35, 12 / 12), because the model gets those right locally and no lookup happens. The cost of looking up only after a failure: a wrong answer that passes every check (a plausible but wrong kubectl flag) isn't looked up.
It runs at most once per request, and only after the model failed:
- The model isn't sure. For a request about a specific tool, the model may answer
SEARCH: <what to look up>instead of guessing; whatcmd looks it up and asks again. - The answer still fails the checks after the usual retries: no usable command, a repeated request, or flags that don't fit your OS.
Requests the model answers correctly never touch the network, and neither does a command whose only problem is that its program isn't installed (a web page can't install it; you get a warning instead). Where it looks:
- A known reference page for
kubectl,helm,gcloud,az,gh,kind,kustomize,istioctl,argocdandeksctl, read over plain HTTP (no search engine involved), cached for 7 days, with matching lines picked locally. - Otherwise a web search, reading the top 2 results.
/w+refinements reuse the docs the first command was made with, so they don't search again.
Rate limits: tiny-browse keeps per-engine budgets shared by every tiny-browse process on your computer (Google: 8 s between searches, 20 an hour, 100 a day) and pauses an engine after a CAPTCHA. whatcmd adds no searches of its own on top: one per request at most, never retried after a block, and when every engine refuses it stops searching for 15 minutes and says web search paused. Your own tiny-browse settings (~/.config/tiny-browse/config.json) apply. If Google keeps blocking, tiny-browse login (via npx @shubhamcodess/tiny-browse login) usually helps.
What leaves your computer: the search query (the tool name and the plain words of your request; paths, flags, key=value pairs and long numbers are removed) or the fixed reference URL. Web text is labelled as examples, and every command still goes through the same gate and risk warnings. Turn it off any time with whatcmd config set web false.
whatcmd init first-time setup
whatcmd doctor check Ollama, model, speed, web lookup and shortcut; offers fixes
whatcmd use <model> switch model (downloads it if needed)
whatcmd models list downloaded models
whatcmd config show settings
whatcmd config set <key> <value> | get <key> | unset <key> | path | reset
whatcmd profile [--refresh] show (or re-detect) the system info given to the model
whatcmd shell bash|zsh print the shell hook, to add it yourself
whatcmd uninstall remove the shortcut from your shell config
Flags: --debug (grounding, web lookups, prompts and timings), --web / --no-web (web lookup for one request), --model=NAME (one request with another model), --yes (non-interactive init and doctor), --raw (command only).
Settings live in ~/.config/whatcmd/config.json. Run whatcmd config to see the effective values.
| Key | Default | Meaning |
|---|---|---|
model |
qwen2.5-coder:1.5b |
Any Ollama model. |
host |
http://127.0.0.1:11434 |
Ollama server. Also reads OLLAMA_HOST. |
prefix |
/w |
What you type before a request, e.g. config set prefix ,. |
grounding |
true |
Read local docs of the tools you mention. |
notes |
(empty) | Extra instructions, e.g. "prefer ripgrep over grep". |
web |
true |
Look up docs online via tiny-browse, only for requests the local answer gets wrong. false = fully local. |
webTimeoutMs |
15000 |
Time limit for one web lookup, including starting Chrome. |
keepAlive |
2h |
How long Ollama keeps the model loaded (-1 = forever). |
temperature |
0 |
Keep at 0 for repeatable answers. |
timeoutMs |
30000 |
Time limit for one model call. |
Environment variables override the file: WHATCMD_MODEL, WHATCMD_HOST, WHATCMD_WEB (1 or 0), WHATCMD_CONFIG_DIR, WHATCMD_CACHE_DIR. NO_COLOR turns off colours.
whatcmd is measured on a 500-case benchmark covering command generation, refusals, grounding, safety warnings, OS fit, the CLI, config and the shell hook. Design, raw results and how to reproduce them are in EVALS.md and benchmarks/.
Full benchmark run: 0.1.0 (commit 47e6b47), Apple M4 Pro (14 cores, 48 GB), macOS 15.6.1, Node 22.16, Ollama 0.40.14, default model qwen2.5-coder:1.5b with grounding on. For 1.0 the quick evals were re-run with web lookup on and off: everyday requests 35 / 48, refusals 34 / 35 and refinement chains 12 / 12 either way, cloud CLIs 22 / 40 → 25 / 40 (see Web lookup).
| Measure | Result |
|---|---|
| Overall | 92.7% (454 / 490 scored; 10 bash hook cases skipped, macOS ships bash 3.2) |
| Non-shell requests refused | 98.8% (79 / 80) |
| Correct command generated | 84.7% (127 / 150) |
| Grounding: made-up tools / real tools | 85% (17 / 20) / 90% (27 / 30), versus 0% with docs off |
| Risk warnings · missing tools | 95% (38 / 40) · 100% (30 / 30) |
| Gate, config, CLI and zsh hook checks | 100% (120 / 120) |
| Latency: model p50 / end to end p50 | 121 ms / 217 ms |
| First request after the model unloads | ~0.8 s |
| Repeatability (50 cases × 3 runs) | 50 / 50 identical |
The smaller qwen2.5-coder:0.5b scores 66% on generation (versus 84.7%), which is why init labels it "not recommended". Numbers vary with hardware, model and whether the model is already loaded.
request ─► grounding ─► local model ─► gate ─► your prompt line
man / --help system profile NONE? not a command?
package db + examples not installed? → retry once
web (only if it failed) risky? → warning
- Profile. OS, distro, shell, package manager, GNU/BSD/BusyBox userland and common installed tools, detected once and stored.
- Grounding. Words in your request that name an installed program or system package pull in that tool's usage and matching option lines. The man page is read first,
--helpis the fallback, and dangerous programs are never run with--help. Results are cached per binary version. - Generation. The model gets the profile, a few examples and the docs, and must answer with one command or
NONE. - Web lookup (only after a failure). At most once per request: when the model answers
SEARCH:, or when the answer still fails after the retries below. See Web lookup. - Gate. Output is dropped when it is
NONE, doesn't parse as shell, is chat text, repeats the request, copies an example, or loops. - Retries (at most 3 model calls, 5 with web lookup).
- Second chance: a request that is clearly about the computer gets one more attempt, with a prompt that has no
NONEoption. Arithmetic, text and injection answers are still filtered out. - Fix-up: a missing program, GNU-only flags on macOS, or a repeated request gets one targeted hint (for example "on macOS use
vm_statinstead offree"). - Refine: a
/w+change gets the current command, the original request and the change in one message, and one retry if the command comes back unchanged. - Auto-fix: on macOS,
sed -i 's/…'becomessed -i '' 's/…'.
- Second chance: a request that is clearly about the computer gets one more attempt, with a prompt that has no
- Small models make mistakes. Expect the occasional wrong flag, wrong tool or dropped filter. Always read the command before pressing Enter; that is why whatcmd never runs it for you.
- bash needs version 4+. macOS ships bash 3.2, so on a Mac use zsh (the default) or
brew install bash.whatcmd initdetects this. Only the zsh hook is covered end to end by the benchmark. - Benchmarked on one machine (Apple Silicon, macOS 15.6.1, Ollama 0.40.14). Linux is supported but not covered by the benchmark.
- Math and text requests can occasionally come back as
bcorechocommands. - Shell integrations that also rebind Enter (bash
bind, zshaccept-line), such as ble.sh, may conflict. - No shortcut yet for fish or Windows shells; use
whatcmd <request>. - Web lookup is only as good as the search engine. Search engines often block automated browsers (CAPTCHA); then only the known reference pages help. Web search needs Chrome, Chromium, Edge or Brave. A cold lookup takes about 1 to 3 s; cached ones add almost nothing.
- A wrong answer that passes every check isn't looked up. Web lookup only follows a visible failure, so a plausible but wrong flag for a tool like
kubectlcan still slip through. - Homebrew packages aren't looked up in the package database (too slow per request); installed commands are still grounded via man page or
--help.
- Grounding for Homebrew packages.
- A fish shortcut.
- Web search without a browser (tiny-browse's HTTP-only mode) when Chrome isn't installed.
- Catching flags a tool doesn't have, so more wrong answers trigger a lookup.
Bug reports, wrong-command examples and pull requests are welcome.
- Found a wrong or unsafe command? Open an issue with the request, the output, and your OS and shell (
whatcmd profileprints them). - Before a pull request, read CONTRIBUTING.md and run
npm test. Changes to prompts or the gate should also includenpm run evalresults, and changes to web lookupnpm run eval:web.
| Document | Covers |
|---|---|
| CONTRIBUTING.md | Setup, tests and sending a change |
| TESTING.md | Unit tests and what they cover |
| EVALS.md | The eval and the 500-case benchmark |
| CHANGELOG.md | Release notes |
| SECURITY.md | Reporting a vulnerability |
| CODE_OF_CONDUCT.md | Community guidelines |
MIT © 2026 Shubham Prakash. whatcmd suggests commands and never runs them for you; you're responsible for what you execute.

