Scripts2026年4月1日·1 分钟阅读

AI Shell — Natural Language to Shell Commands

AI Shell converts natural language into shell commands using AI. 5.2K+ stars. 13+ languages, chat mode, custom endpoints. MIT. By Builder.io.

Agent 就绪

这个资产会安全暂存

这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。

Stage only · 17/100策略:需暂存
Agent 入口
任意 MCP/CLI Agent
类型
Script
安装
Stage only
信任
信任等级:Established
入口
ai-shell.md
安全暂存命令
npx -y tokrepo@latest install da61dedb-cb50-41f6-bb0c-72013a520bd6 --target codex

先暂存文件;激活前需要读取暂存 README 和安装计划。

TL;DR
AI Shell translates plain English descriptions into shell commands you can execute, revise, or cancel.
§01

What it is

AI Shell is a CLI tool by Builder.io that converts natural language into shell commands using AI. You describe what you want in plain English, and it suggests the exact command to run. It supports 13+ languages, interactive chat mode, silent mode for scripting, and custom OpenAI-compatible API endpoints.

It is designed for developers who frequently look up command syntax or want faster shell workflows without memorizing flags and options.

§02

How it saves time or tokens

Instead of searching documentation or Stack Overflow for the right combination of flags, AI Shell gives you the command in seconds. The token estimate for this workflow is 369 tokens per invocation. Silent mode (ai -s) lets you pipe output directly into scripts, removing the manual copy-paste step entirely.

§03

How to use

  1. Install globally via npm: npm install -g @builder.io/ai-shell
  2. Set your API key: ai config set OPENAI_KEY=sk-...
  3. Run a query: ai 'list all log files larger than 10MB'
  4. Choose [E]xecute, [R]evise, or [C]ancel from the interactive prompt
§04

Example

# Install AI Shell
npm install -g @builder.io/ai-shell

# Configure your API key
ai config set OPENAI_KEY=sk-your-key-here

# Convert natural language to commands
ai 'find all Python files modified in the last 7 days'
# Suggests: find . -name '*.py' -mtime -7
# [E]xecute, [R]evise, [C]ancel

# Chat mode for multi-turn conversations
ai chat

# Silent mode for scripting
ai -s 'list running docker containers' | sh
§05

Related on TokRepo

§06

Common pitfalls

  • Forgetting to set the API key before first use causes a silent failure with no helpful error message
  • Silent mode pipes commands directly to the shell, which can be dangerous if you do not review the output first
  • Custom endpoints must be fully OpenAI-compatible; partially compatible APIs may return malformed suggestions

常见问题

What models does AI Shell support?+

AI Shell works with any OpenAI-compatible API endpoint. By default it uses OpenAI models, but you can configure custom endpoints to use other providers that expose an OpenAI-compatible chat completions API.

Can AI Shell run commands automatically without confirmation?+

Yes. Use silent mode with the -s flag: ai -s 'your query'. This outputs only the command text without the interactive prompt, which you can pipe to sh for automatic execution. Use with caution.

Does AI Shell work on Windows?+

AI Shell runs on any platform that supports Node.js. It works on macOS, Linux, and Windows. Install via npm and configure your API key the same way on all platforms.

How is AI Shell different from GitHub Copilot CLI?+

AI Shell is open source (MIT licensed) and works with any OpenAI-compatible API, not just GitHub's infrastructure. It was inspired by GitHub Copilot X CLI but provides more flexibility with custom endpoints and 13+ language support.

Can I use AI Shell with local LLMs?+

Yes. Point AI Shell to a local OpenAI-compatible server (such as Ollama or LM Studio) by configuring a custom endpoint. Quality depends on the local model's ability to generate accurate shell commands.

引用来源 (3)
🙏

来源与感谢

Created by Builder.io. MIT. BuilderIO/ai-shell — 5,200+ GitHub stars

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产