An AI-powered CLI tool that generates shell commands from natural language prompts using Claude AI.
cmdhelper takes a plain-English description of what you want to do and uses the Anthropic Claude API to generate the appropriate shell command(s). It is context-aware — it reads your current OS, shell, working directory, directory contents, and git status to suggest commands that are relevant to your environment.
- Natural language to command — describe a task in plain English and get runnable shell commands back
- Context-aware — passes your OS, shell, current directory, file listing, and git information to Claude for better suggestions
- Multi-step commands — for tasks that require multiple commands, they are returned in the correct execution order
- Alternative commands — where applicable, alternative approaches are also suggested
- Interactive execution — select, optionally edit, and execute a command directly from the CLI
- Configurable — stores your Anthropic API key in
~/.cmdhelper
- Go 1.24.1 or later
- An Anthropic API key
go install github.com/coeeter/cmdhelper@latestOr build from source:
git clone https://github.com/coeeter/cmdhelper.git
cd cmdhelper
go build -o cmdhelper .On first run, cmdhelper will prompt you to enter your Anthropic API key. The key is saved to ~/.cmdhelper.
You can manage your configuration at any time using the config subcommand:
# Show the current configuration
cmdhelper config show
# Clear the saved configuration
cmdhelper config clearcmdhelper generate "<prompt>"# Find all Go files modified in the last 7 days
cmdhelper generate "find all go files modified in the last week"
# Stage and commit all changes
cmdhelper generate "stage all changes and commit with message 'fix: update handler'"
# List running Docker containers
cmdhelper generate "show me all running docker containers"cmdhelpersends your prompt along with environment context to Claude.- The generated commands are displayed, grouped into a main flow (ordered steps) and alternative commands.
- Enter the number of the command you want to run.
- Optionally edit the command before executing — press Enter to run it as-is.
- After execution, choose to run another command, re-run, or exit.
Generated commands:
1. find . -name "*.go" -mtime -7
Lists all Go files modified within the last 7 days
Enter the number of the command you want to execute (or q to exit): 1
You selected: find . -name "*.go" -mtime -7
Edit the command (default: press enter to execute as is):
Executing: find . -name "*.go" -mtime -7
...
Command executed successfully.
Execute another command? (y/n or number of command): n
cmdhelper/
├── main.go # Entry point
├── cmd/
│ ├── root.go # Root cobra command
│ ├── generate.go # generate subcommand
│ └── config/
│ ├── root.go # config subcommand group
│ ├── show.go # config show
│ └── clear.go # config clear
└── internal/
├── claude.go # Anthropic API integration
├── config.go # Config load/save/delete
└── context/
├── context.go # Environment context builder
├── schema.json # JSON schema for Claude responses
└── systemPrompt.txt # System prompt sent to Claude
| Package | Purpose |
|---|---|
| spf13/cobra | CLI framework |
| liushuangls/go-anthropic | Anthropic Claude API client |
| fatih/color | Coloured terminal output |
| briandowns/spinner | Loading spinner |
This project is open source. See the repository for license details.