Sponsored by Deepsite.site

CLI Command Explainer

Created By
zmwaiworlda month ago
Know what every shell command does before you approve it.
Overview

cmd-explain

Know what every shell command does — before you approve it.
MCP server for AI coding agents · Works with Kiro, Cursor, VS Code, Windsurf, Claude Code

Quick Start · How It Works · Supported IDEs · Local AI


The Problem

AI coding agents run shell commands on your machine. They show an approval dialog, but you're left guessing:

Agent wants to run:  curl -sL https://raw.githubusercontent.com/some-tool/install.sh | sudo bash

  [ Approve ]   [ Deny ]

Is that safe? What does -sL mean? Why sudo? Most people either blindly approve (dangerous) or Google it (slow, breaks flow).

The Fix

cmd-explain intercepts every shell command before it runs and shows you a plain-English explanation with a risk rating:

🔴 Transfer data from or to a URL (silent, follow redirects),
   then GNU Bourne-Again SHell
   Risk: high · Source: built-in

Agent wants to run:  curl -sL https://raw.githubusercontent.com/some-tool/install.sh | sudo bash

  [ Approve ]   [ Deny ]

Now you know: it silently downloads a script and pipes it to bash with root privileges. That's a one-line rootkit vector. Easy deny — or at least worth inspecting first.

More Examples

Commands that agents actually suggest — and that you'd probably approve without thinking:

🔴 chmod -R 777 .
   Change file permissions (recursive)
   Risk: high · Source: built-in
   → Makes every file in your project world-writable

🟡 curl -sL https://install.example.com | bash
   Transfer data from or to a URL (silent, follow redirects),
   then GNU Bourne-Again SHell
   Risk: medium · Source: built-in
   → Downloads and executes a remote script. Classic supply chain risk.

🔴 git push origin main --force
   Upload local commits to a remote (force push, set upstream)
   Risk: high · Source: built-in
   → Overwrites remote history. Other people's commits may be lost.

🔴 rm -rf node_modules dist .next .cache && npm ci
   Remove files or directories (recursive, force without confirmation),
   then clean install from lockfile
   Risk: high · Source: built-in

🟡 npx prisma db push --accept-data-loss
   Run a command from a local or remote npm package without installing
   Risk: medium · Source: built-in
   → That --accept-data-loss flag means exactly what it says.

🔴 kubectl exec -it prod-db-0 -- psql -c "DROP TABLE users"
   Execute a command in a container
   Risk: high · Source: built-in
   → Running SQL directly on a production pod.

Every explanation includes:

  • What it does in plain English, including flags and shell patterns (2>&1, || true, >/dev/null)
  • Risk level — low (read-only), medium (state-changing), high (destructive), or unknown
  • Sourcebuilt-in (241-command dictionary), system (man pages), or ai-generated (LLM)

Quick Start

npx cmd-explain setup

That's it. Auto-detects your IDE, installs the MCP server, creates the pre-command hook. Restart your IDE and you're protected.

Requirements: Node.js 18+. No API keys, no Ollama, no config files to edit.

How It Works

cmd-explain is an MCP server with one tool: explain_command. When your agent is about to run a shell command, a pre-command hook calls this tool automatically.

Explanations come from three tiers, checked in order:

TierSourceSpeedCoverageNeeds Setup?
1Built-in dictionary — 240+ programs with 440+ command explanations (git, docker, npm, kubectl, terraform, aws, brew, cargo, and more)<1ms~90% of agent commandsNo
2System man pages — parses whatis output for any installed CLI tool~50msMost installed toolsNo
3Local AI — Ollama, OpenAI, or Anthropic for anything tiers 1–2 miss~1sEverythingOptional

Tiers 1 and 2 are fully offline with zero dependencies. Tier 3 is opt-in.

Shell Pattern Detection

cmd-explain understands shell syntax that agents commonly use:

PatternAnnotation
2>&1redirect stderr to stdout
>/dev/null 2>&1suppress all output
2>/dev/nullsuppress error output
|| trueignore exit code
set -eexit on error
set -xprint commands before execution
set -o pipefailfail on any pipe segment error
$(...)command substitution

These are appended to the explanation so you always know what the full command is doing.

Risk Classification

LevelMeaningExamples
🟢 lowRead-only, no side effectsls, cat, grep, git status, curl GET
🟡 mediumState-changing but reversiblegit commit, npm install, mkdir, docker build
🔴 highDestructive or irreversiblerm -rf, docker rm -f, terraform destroy, find -delete
⚪ unknownNot recognizedCustom/proprietary CLIs

Supported IDEs

One setup command handles everything. Each IDE gets the right hook format automatically.

IDEHook EventShell Coverage
KiropreToolUse✅ All shell commands
VS Code CopilotPreToolUse✅ All shell commands
CursorbeforeShellExecution✅ Dedicated shell hook
Windsurfpre_run_command✅ Dedicated shell hook
Claude CodePreToolUse✅ Via matcher
npx cmd-explain setup              # Auto-detect all IDEs
npx cmd-explain setup --ide kiro   # Target one IDE
npx cmd-explain setup --no-hooks   # MCP server only

Optional: Local AI

For commands not in the dictionary or man pages, enable local AI explanations powered by Ollama (~1GB one-time download):

brew install ollama
brew services start ollama
ollama pull qwen2.5-coder:1.5b
npx cmd-explain setup --ollama qwen2.5-coder:1.5b

The setup command validates each step — if Ollama isn't installed or the model isn't pulled, it tells you exactly what to run.

Cloud APIs also work:

npx cmd-explain setup --openai-key sk-...

Supported providers: Ollama, OpenAI (OPENAI_API_KEY), Anthropic (ANTHROPIC_API_KEY).

Manual Install

Add to your IDE's MCP config:

{
  "mcpServers": {
    "cmd-explain": {
      "command": "npx",
      "args": ["-y", "cmd-explain"]
    }
  }
}

Config locations:

  • Kiro: .kiro/settings/mcp.json
  • VS Code: .vscode/mcp.json
  • Cursor: .cursor/mcp.json
  • Windsurf: ~/.codeium/windsurf/mcp_config.json
  • Claude Code: ~/.claude/settings.json

Uninstall

npx cmd-explain uninstall

Removes the MCP config and hook files from all detected IDEs. Clean removal, nothing left behind.

Platform Support

macOSLinuxWindows
Dictionary (Tier 1)
Man pages (Tier 2)⚠️ --help only
Local AI (Tier 3)
Setup CLI

License

MIT

Server Config

{
  "mcpServers": {
    "cmd-explain": {
      "command": "npx",
      "args": [
        "-y",
        "cmd-explain"
      ]
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
CursorThe AI Code Editor
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Playwright McpPlaywright MCP server
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Tavily Mcp
DeepChatYour AI Partner on Desktop
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Amap Maps高德地图官方 MCP Server
RedisA Model Context Protocol server that provides access to Redis databases. This server enables LLMs to interact with Redis key-value stores through a set of standardized tools.
Serper MCP ServerA Serper MCP Server
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
WindsurfThe new purpose-built IDE to harness magic
ChatWiseThe second fastest AI chatbot™