LLM-powered CLI one-liner generator
Describe what you want in natural language, get shell commands. No more forgetting git flags or searching Stack Overflow for that perfect one-liner.
$ 1lm "search git history for modifications mentioning myFunction"
Select a command:
▸ Git log with pickaxe
git log -p -S myFunction
Search commit history for additions/deletions of the exact string "myFunction"
Git log with regex
git log -G myFunction
Search commits where "myFunction" appears in the diff (supports regex)
Git log all branches
git log --all -p -S myFunction
Search across all branches for changes mentioning "myFunction"
↑/k: up • ↓/j: down • enter: select • q: quit- Multiple options: Get 3 different approaches to choose from
- Interactive selection: Arrow keys or vim bindings to navigate
- Safety warnings: LLM-powered risk evaluation with visual indicators
- 🚨 High risk warnings for destructive operations (rm -rf, dd, etc.)
⚠️ Low risk warnings for network operations, scans, and privilege changes
- Shell integration: Commands appear in your prompt ready to execute (bash, zsh, fish)
- Cross-platform clipboard: Falls back to clipboard copy (macOS, Linux X11/Wayland)
- Context-aware: Descriptions explain what each command does and any caveats
- Reliable: Uses Anthropic's structured outputs API for guaranteed valid responses
- Real-time progress: See "Generating options..." and "Evaluating safety..." as it works
- Go 1.25 or later
- Anthropic API key
- (Optional) Clipboard tools:
pbcopy(macOS),xclip(Linux X11), orwl-copy(Linux Wayland)
git clone https://github.com/jalada/1lm.git
cd 1lm
go build -o 1lmOptionally, move the binary to your PATH:
sudo mv 1lm /usr/local/bin/For the best experience, add a shell function to your config file so selected commands appear in your prompt ready to execute.
Important: Replace /path/to/1lm with the actual path to your 1lm binary. You can find it with:
which 1lm1lm() {
local output
output=$(/path/to/1lm "$@" --output=shell-function)
if [[ -n "$output" ]]; then
READLINE_LINE="$output"
READLINE_POINT=${#output}
fi
}1lm() {
local output
output=$(/path/to/1lm "$@" --output=shell-function)
if [[ -n "$output" ]]; then
print -z "$output"
fi
}function 1lm
set -l output (/path/to/1lm $argv --output=shell-function)
if test -n "$output"
commandline -r "$output"
end
endAfter adding the shell function, reload your shell config:
# Bash/Zsh
source ~/.bashrc # or ~/.zshrc
# Fish
source ~/.config/fish/config.fishIf you don't add the shell function, 1lm will copy to clipboard by default. This works on:
- macOS: via
pbcopy - Linux (X11): via
xclip(install withapt install xcliporyum install xclip) - Linux (Wayland): via
wl-copy(install withapt install wl-clipboard)
If clipboard tools aren't available, commands will be printed to stdout.
You can control how 1lm outputs commands:
# Shell function mode (for shell integration)
1lm "find large files" --output=shell-function
# Clipboard mode (default)
1lm "find large files" --output=clipboard
# Stdout only
1lm "find large files" --output=stdoutCreate ~/.config/1lm/config.toml:
provider = "anthropic"
model = "claude-sonnet-4-5-20250929"
anthropic_api_key = "sk-ant-your-api-key-here"- Sign up at console.anthropic.com
- Navigate to API Keys
- Create a new key
- Add it to your config file
1lm "your natural language query"Find files:
1lm "find all python files modified in the last week"Process data:
1lm "count unique IP addresses in access.log"Git operations:
1lm "show commits from last month by author alice"System info:
1lm "check disk usage sorted by size"↑ork- Move selection up↓orj- Move selection downEnter- Select command and copy to clipboardqorCtrl+C- Quit without selecting
- Query: You describe what you want in natural language
- Generate: Claude generates 3 command options using structured outputs API
- Evaluate: Claude assesses each command for safety risks (destructive ops, network activity)
- Select: Interactive TUI shows options with explanations and safety warnings
- Copy: Selected command is copied to clipboard, ready to paste and run
Under the hood:
- Uses Anthropic SDK for Go with structured outputs beta
- JSON Schema enforces reliable response format
- Bubbletea powers the interactive TUI
- Lipgloss handles styling
Make sure ~/.config/1lm/config.toml exists and contains your API key:
anthropic_api_key = "sk-ant-..."The UI automatically detects terminal width. If descriptions still overflow, try resizing your terminal or updating to the latest version.
Check:
- Your API key is valid
- You have API credits remaining
- Your network connection is working
1lm/
├── main.go # Entry point and wiring
├── config/ # TOML configuration management
├── llm/ # Anthropic SDK integration
│ ├── client.go # LLM client interface
│ ├── provider.go # Structured outputs implementation
│ └── mock.go # Mock for testing
├── commands/ # Command generation logic
├── safety/ # LLM-based safety evaluation
├── ui/ # Bubbletea interactive selector
└── tests/ # Unit tests
go test ./...- TomDoc format for public functions
- Clear interfaces for testability
- Small, focused files
See PLAN.md for detailed architecture decisions and roadmap.
- ✓ Anthropic Claude integration
- ✓ Structured output with JSON schema
- ✓ Interactive TUI
- ✓ Clipboard support
- ✓ TOML configuration
- ✓ LLM-based safety warnings with visual indicators
- ✓ Multi-stage progress indicator
- ✓ Shell integration (command insertion into prompt)
- ✓ Cross-platform clipboard support (macOS, Linux X11/Wayland)
- ✓ Multiple output modes (shell-function, clipboard, stdout)
- Context awareness (cwd, OS, installed tools)
- Multiple LLM provider support
- Response caching
- Command history
Tools like GitHub Copilot CLI and Warp AI exist, but they're tied to specific editors or terminals. 1lm is a standalone tool that:
- Works in any terminal
- Gives you multiple options with explanations
- Lets you pick the approach that fits your needs
- Is easy to understand and modify
This is a learning project built collaboratively with Claude Code. Contributions welcome!
MIT
Built with Go, Anthropic Claude, and Charmbracelet tools.