cmd-ai is a natural language shell assistant powered by AI. It turns plain English (or any prompt) into real, executable shell commands — with safety, explanation, history, and autocompletion built-in.
By default, it uses Ollama (local models on your machine), and you can also configure it to use OpenAI, Google Gemini, or Anthropic Claude APIs.

To install cmd-ai, use the following command:
npm install -g cmd-ai
Ensure you have Node.js installed (v24 via .nvmrc is recommended) on your system before proceeding with the installation.
Set your AI provider, model, reasoning effort, and API keys (where required):
ai config
This command will guide you through provider setup.
ai config checks Ollama and lets you choose one of your installed models.gpt-5.3-codex and gpt-5.3-codex-spark) and lets you choose reasoning effort.The default provider is ollama.
Your configuration is stored securely in:
$XDG_CONFIG_HOME/cmd-ai/config.json
If XDG_CONFIG_HOME is not set, cmd-ai uses:
~/.config/cmd-ai/config.json
Once installed, you can invoke this library using the ai command. For example:
ai Tell me how much free space is left on the disk
This will first display the suggested command based on your input. If you confirm by pressing "Enter," the command will then be executed.
On non-Windows systems, when the Node.js runtime supports process.execve, ai hands off execution to your shell with execve, so ai is replaced in the process tree. If execve is unavailable (or fails), ai falls back to child_process.exec.
Before generation, ai also builds a local command inventory from your PATH, detects common package managers, and samples versions of known tools. That context is included in the model prompt so it can prefer installed commands and suggest install steps when required commands appear missing. To keep token usage bounded, command names are capped.
Here some pre-defined commands:
ai [your task here] [--flags]
ai list all running Docker containers
ai remove all .DS_Store files recursively
ai config # Configure provider/model/API key/reasoning effort
ai history # View past commands
ai man # Show help
ai install-autocomplete # Automatically set up autocomplete
--explain – Ask AI to explain the command before returning it.--dry – Show the command but don’t execute it.--help or -h – Show help screen.--version – Show installed package version.Generate and install the autocompletion script:
ai install-autocomplete
This will:
$XDG_DATA_HOME/cmd-ai/cmd-ai-completion.sh$XDG_DATA_HOME/cmd-ai/cmd-ai-completion.sh to your .bashrc or .zshrcIf XDG_DATA_HOME is not set, cmd-ai uses:
~/.local/share/cmd-ai/cmd-ai-completion.sh
npm install
npm run dev:link
What this does:
ai command points to your working copy.Run automated checks on file changes while coding:
npm run dev:watch
This watches key files and reruns:
npm run dev:checkdev:check performs:
node --check bin/ai.js)node bin/ai.js --help)Build note:
npm run dev:link is enough to test changes immediately in your global ai command.In another terminal, run the linked CLI:
ai --help
ai --version
ai config
ai list files --dry
npm run dev:pack
Tip:
--dry while testing generation to avoid executing commands.HOME=/tmp ai config
HOME=/tmp ai list files --dry
npm run dev:unlink
Use this flow when shipping a new version:
git checkout main
git pull origin main
npm install
npm run dev:check
npm run dev:pack
You can run the full flow with the release helper:
npm run release
Use one of:
npm run release -- fix
npm run release -- feature
npm run release -- breaking
npm version patch
# or: npm version minor
# or: npm version major
This command updates package.json/package-lock.json, creates a release commit, and creates a git tag like v1.2.1.
git push origin main --follow-tags
npm publish
npm publish --otp=<code> # when your npm account/org requires 2FA
When using npm run release, provide OTP interactively when prompted, or set NPM_OTP:
NPM_OTP=<code> npm run release -- feature
If npm 2FA is enabled for publish, run:
npm publish --otp=<code>
npm view cmd-ai version
cmd-ai is designed with safety in mind. It includes mechanisms to filter harmful or inappropriate content. However, always review AI-generated outputs before using them in critical applications.
All AI-generated commands are saved (with timestamp and status) in:
$XDG_STATE_HOME/cmd-ai/history.json
If XDG_STATE_HOME is not set, cmd-ai uses:
~/.local/state/cmd-ai/history.json
Backward compatibility:
~/.ai-config.json and ~/.ai-command-history.json files are still read if present.View them using:
ai history
This project is licensed under the MIT License.
Made by Broda Noel (brodanoel@gmail.com)
The use of cmd-ai is entirely at your own risk.
This tool uses artificial intelligence to generate shell commands automatically. While it includes safety checks to prevent destructive operations, it does not guarantee the accuracy, safety, or appropriateness of any generated command.
You are solely responsible for reviewing and understanding every command before executing it.
The author(s) of this project accept no liability for data loss, system damage, security breaches, or any unintended consequences resulting from the use of this software.
48 commits
11 commits
JavaScript
98.5%
Shell
1.5%
cmd-ai is a natural language shell assistant powered by AI. It turns plain English (or any prompt) into real, executable shell commands — with safety, explanation, history, and autocompletion built-in.
By default, it uses Ollama (local models on your machine), and you can also configure it to use OpenAI, Google Gemini, or Anthropic Claude APIs.

To install cmd-ai, use the following command:
npm install -g cmd-ai
Ensure you have Node.js installed (v24 via .nvmrc is recommended) on your system before proceeding with the installation.
Set your AI provider, model, reasoning effort, and API keys (where required):
ai config
This command will guide you through provider setup.
ai config checks Ollama and lets you choose one of your installed models.gpt-5.3-codex and gpt-5.3-codex-spark) and lets you choose reasoning effort.The default provider is ollama.
Your configuration is stored securely in:
$XDG_CONFIG_HOME/cmd-ai/config.json
If XDG_CONFIG_HOME is not set, cmd-ai uses:
~/.config/cmd-ai/config.json
Once installed, you can invoke this library using the ai command. For example:
ai Tell me how much free space is left on the disk
This will first display the suggested command based on your input. If you confirm by pressing "Enter," the command will then be executed.
On non-Windows systems, when the Node.js runtime supports process.execve, ai hands off execution to your shell with execve, so ai is replaced in the process tree. If execve is unavailable (or fails), ai falls back to child_process.exec.
Before generation, ai also builds a local command inventory from your PATH, detects common package managers, and samples versions of known tools. That context is included in the model prompt so it can prefer installed commands and suggest install steps when required commands appear missing. To keep token usage bounded, command names are capped.
Here some pre-defined commands:
ai [your task here] [--flags]
ai list all running Docker containers
ai remove all .DS_Store files recursively
ai config # Configure provider/model/API key/reasoning effort
ai history # View past commands
ai man # Show help
ai install-autocomplete # Automatically set up autocomplete
--explain – Ask AI to explain the command before returning it.--dry – Show the command but don’t execute it.--help or -h – Show help screen.--version – Show installed package version.Generate and install the autocompletion script:
ai install-autocomplete
This will:
$XDG_DATA_HOME/cmd-ai/cmd-ai-completion.sh$XDG_DATA_HOME/cmd-ai/cmd-ai-completion.sh to your .bashrc or .zshrcIf XDG_DATA_HOME is not set, cmd-ai uses:
~/.local/share/cmd-ai/cmd-ai-completion.sh
npm install
npm run dev:link
What this does:
ai command points to your working copy.Run automated checks on file changes while coding:
npm run dev:watch
This watches key files and reruns:
npm run dev:checkdev:check performs:
node --check bin/ai.js)node bin/ai.js --help)Build note:
npm run dev:link is enough to test changes immediately in your global ai command.In another terminal, run the linked CLI:
ai --help
ai --version
ai config
ai list files --dry
npm run dev:pack
Tip:
--dry while testing generation to avoid executing commands.HOME=/tmp ai config
HOME=/tmp ai list files --dry
npm run dev:unlink
Use this flow when shipping a new version:
git checkout main
git pull origin main
npm install
npm run dev:check
npm run dev:pack
You can run the full flow with the release helper:
npm run release
Use one of:
npm run release -- fix
npm run release -- feature
npm run release -- breaking
npm version patch
# or: npm version minor
# or: npm version major
This command updates package.json/package-lock.json, creates a release commit, and creates a git tag like v1.2.1.
git push origin main --follow-tags
npm publish
npm publish --otp=<code> # when your npm account/org requires 2FA
When using npm run release, provide OTP interactively when prompted, or set NPM_OTP:
NPM_OTP=<code> npm run release -- feature
If npm 2FA is enabled for publish, run:
npm publish --otp=<code>
npm view cmd-ai version
cmd-ai is designed with safety in mind. It includes mechanisms to filter harmful or inappropriate content. However, always review AI-generated outputs before using them in critical applications.
All AI-generated commands are saved (with timestamp and status) in:
$XDG_STATE_HOME/cmd-ai/history.json
If XDG_STATE_HOME is not set, cmd-ai uses:
~/.local/state/cmd-ai/history.json
Backward compatibility:
~/.ai-config.json and ~/.ai-command-history.json files are still read if present.View them using:
ai history
This project is licensed under the MIT License.
Made by Broda Noel (brodanoel@gmail.com)
The use of cmd-ai is entirely at your own risk.
This tool uses artificial intelligence to generate shell commands automatically. While it includes safety checks to prevent destructive operations, it does not guarantee the accuracy, safety, or appropriateness of any generated command.
You are solely responsible for reviewing and understanding every command before executing it.
The author(s) of this project accept no liability for data loss, system damage, security breaches, or any unintended consequences resulting from the use of this software.
48 commits
11 commits
JavaScript
98.5%
Shell
1.5%