ChatCMD is an open source AI-driven CLI-based command lookup using multiple AI models to lookup relevant CLI commands based on user input and other generating and lookup features.
- Security Hardened: SQL injection prevention, secure API key storage, input validation hardening
- Secure Key Storage: API keys stored in system keyring (macOS Keychain, Windows Credential Manager, Linux Secret Service) with encrypted file fallback
- Command Injection Prevention: Enhanced validation to block dangerous patterns (backticks, command substitution, variable expansion)
- Database Integrity Checks: Automatic integrity verification on startup
- Error Message Sanitization: Sensitive information redacted from error messages
- UUID v1 Privacy: Uses randomized node to prevent MAC address exposure
- Google Genai Update: Migrated to new google-genai package
- Multi-provider workflow with unified model management (list models, model info, current model, performance stats)
- Provider-specific API key storage via secure keyring; legacy OpenAI flags kept for backward compatibility
- Optional length argument for
--random-password(default 18) - Enhanced, colored help and unified header output
- CLI-based command lookup using multiple AI models (OpenAI, Anthropic, Google, Cohere, Ollama)
- Generate SQL query using AI
- Generate a random user-agent
- Generate a random password
- Get your public IP address
- Get a color Hex code by describing the color
- Lookup HTTP Code
- Lookup any port number
- Auto copy command to clipboard
- Disable copy feature
- Store Data in Sqlite Database
- Add or update API keys for multiple providers
- Validate API keys
- Display API Keys
- Display last command
- Display last {number} of commands
- Delete last Command
- Delete last {number} of commands
- Display the total number of commands
- Clear all history records
- Display the database file size
- Clear and validate user inputs
- Clear and validate lookup results to ensure only valid CLI commands are returned
- Enhanced error handling with human-readable messages
- Display library information
| Feature | Implementation | AI/API Usage | Description |
|---|---|---|---|
| CLI Command Lookup | π’ AI-Powered | β AI Models | Uses OpenAI, Anthropic, Google, Cohere, Ollama |
| SQL Query Generation | π’ AI-Powered | β AI Models | AI generates SQL based on natural language |
| Random User-Agent | π΄ Static Code | β No AI | Uses predefined user-agent strings |
| Random Password | π΄ Static Code | β No AI | Uses Python's random library |
| Public IP Address | π‘ External API | Uses external IP service (not AI) | |
| Color Hex Code | π΄ Static Code | β No AI | Uses predefined color database |
| HTTP Code Lookup | π΄ Static Code | β No AI | Uses predefined HTTP status codes |
| Port Lookup | π΄ Static Code | β No AI | Uses predefined port database |
| Database Operations | π΄ Static Code | β No AI | Uses SQLite for local storage |
| API Key Management | π΄ Static Code | β No AI | Local storage and validation |
| Command History | π΄ Static Code | β No AI | Local database operations |
| Clipboard Operations | π΄ Static Code | β No AI | Uses pyperclip library |
| Input Validation | π΄ Static Code | β No AI | Regex and string validation |
Summary:
- π’ AI-Powered (2 features): CLI lookup and SQL generation
- π΄ Static Code (10 features): Most core features work offline
- π‘ External API (1 feature): IP address lookup only
- Regex Pattern Generator - Create regex patterns for common use cases
- Base64 Encoder/Decoder - Encode or decode base64 strings
- UUID Generator - Generate UUIDs in different formats (v1 with privacy protection, v3, v4, v5)
- Timestamp Converter - Convert between different timestamp formats
| Feature | Implementation | AI/API Usage | Benefits |
|---|---|---|---|
| Regex Pattern Generator | π΄ Static Code | β No AI | Instant response, predefined patterns |
| Base64 Encoder/Decoder | π΄ Static Code | β No AI | Fast, built-in Python library |
| UUID Generator | π΄ Static Code | β No AI | Fast, uses Python's uuid library with privacy protection |
| Timestamp Converter | π΄ Static Code | β No AI | Reliable, uses datetime library |
Key Benefits:
- 100% Static Code: All developer tools work offline without API calls
- No AI Costs: Developer tools don't consume AI API credits
- Fast Response: Instant results without network latency
- Reliable: No dependency on external AI services
- Fully Offline: Works without internet connection
- OpenAI Models: GPT-3.5 Turbo, GPT-4, GPT-4 Turbo
- Anthropic Claude Models: Claude 3 Haiku, Sonnet, Opus
- Google Models: Gemini Pro
- Cohere Models: Command, Command Light
- Local Models (Ollama): Llama 2, Code Llama, Mistral, Llama 3.2 3B
Python >= 3.8.9
AI provider account and valid API key (OpenAI, Anthropic, Google, Cohere, or Ollama for local models)
Get API keys:
- OpenAI: https://platform.openai.com/signup
- Anthropic: https://console.anthropic.com/
- Google: https://makersuite.google.com/app/apikey
- Cohere: https://dashboard.cohere.ai/
- Ollama: https://ollama.ai/ (for local models)
pip3 install chatcmd
If pip not installed:
python3 -m pip install chatcmd
Installation output should display:
Collecting chatcmd
Using cached chatcmd-2.2.0-py3-none-any.whl
Installing collected packages: chatcmd
Successfully installed chatcmd-2.2.0
pip3 install --upgrade chatcmd
If pip not installed:
python3 -m pip install --upgrade chatcmd
pip3 uninstall chatcmd
If pip not installed:
python3 -m pip uninstall chatcmd
# Set OpenAI API key
chatcmd --set-model-key openai
# Set Anthropic API key
chatcmd --set-model-key anthropic
# Set Google API key
chatcmd --set-model-key google
# Set Cohere API key
chatcmd --set-model-key coherechatcmd --list-models# Use default model (GPT-3.5 Turbo)
chatcmd --cmd
# Use specific model
chatcmd --model gpt-4 --cmd
# Generate a random password with custom length (default is 18)
chatcmd --random-password 24
Usage:
chatcmd [options]
Core Features:
-c, --cmd looking up a CLI command.
-q, --sql generate SQL query.
Tools:
--random-useragent generate a random user-agent
--get-ip get your public IP address.
--random-password [<length>] generate a random password (default: 18).
--color-code get a color Hex code.
--lookup-http-code lookup HTTP Code by code number.
--port-lookup lookup any port number.
--regex-pattern generate regex pattern for description.
--base64-encode encode text to base64.
--base64-decode decode base64 text.
--generate-uuid <version> generate UUID (1, 3, 4, 5).
--timestamp-convert <format> convert timestamp (unix, iso, readable).
Library Options:
-k, --set-key set or update API key (legacy OpenAI only).
-o, --get-key display API key (legacy OpenAI only).
-m, --model <model> select AI model (gpt-3.5-turbo, gpt-4, claude-3-haiku, etc.)
--list-models list all available AI models
--model-info <model> show information about a specific model
--set-model-key <provider> set API key for specific provider
--get-model-key <provider> get API key for specific provider
--current-model show current model and provider
--performance-stats show model performance statistics
--reset-config clear config and stored keys (with confirmation)
-g, --get-cmd display the last command.
-G, --get-last=<value> display the last [number] of commands.
-d, --delete-cmd delete the last command.
-D, --delete-last-cmd=<value> delete the last [number] of commands.
-t, --cmd-total display the total number of commands.
-r, --clear-history clear all history records.
-s, --db-size display the database size.
-n, --no-copy disable copy feature.
-h, --help display this screen.
-v, --version display ChatCMD version.
-x, --library-info display library information.
# Use default model
chatcmd --cmd "find all files larger than 100MB"
# Use specific model
chatcmd --model gpt-4 --cmd "create a backup of my database"# Generate regex pattern
chatcmd --regex-pattern "email validation"
# Encode/decode base64
chatcmd --base64-encode "Hello World"
chatcmd --base64-decode "SGVsbG8gV29ybGQ="
# Generate UUID (versions 1, 3, 4, 5)
chatcmd --generate-uuid 4
# Convert timestamp
chatcmd --timestamp-convert unix# List available models
chatcmd --list-models
# Use Claude 3 Sonnet
chatcmd --model claude-3-sonnet --cmd
# Use local Llama 2 (requires Ollama)
chatcmd --model llama2 --cmd
# Check current model
chatcmd --current-model
# View performance statistics
chatcmd --performance-stats# Set API key for a specific provider (recommended)
chatcmd --set-model-key openai
chatcmd --set-model-key anthropic
chatcmd --set-model-key google
chatcmd --set-model-key cohere
# Get masked API key for a provider
chatcmd --get-model-key openai# Install Ollama
# macOS: brew install ollama
# Linux: curl -fsSL https://ollama.ai/install.sh | sh
# Pull models
ollama pull llama2
ollama pull codellama
ollama pull mistral
ollama pull llama3.2:3b
# Use local models
chatcmd --model llama2 --cmd
chatcmd --model codellama --cmd
chatcmd --model llama3.2:3b --cmd| Model | Speed | Quality | Cost | Best For |
|---|---|---|---|---|
| gpt-3.5-turbo | ββββ | βββ | ββ | General use, fast responses |
| gpt-4 | ββ | βββββ | β | Complex commands, best quality |
| claude-3-haiku | ββββ | βββ | ββ | Fast, good quality |
| claude-3-sonnet | βββ | ββββ | ββ | Balanced performance |
| claude-3-opus | ββ | βββββ | β | Best quality, complex tasks |
| gemini-pro | βββ | ββββ | ββ | Google ecosystem |
| command | βββ | βββ | βββ | Cost-effective |
| llama2 (local) | βββ | βββ | βββββ | Privacy, no API costs |
| codellama (local) | βββ | ββββ | βββββ | Coding tasks, privacy |
| llama3.2:3b (local) | ββββ | ββββ | βββββ | Small, fast local model |
Include an exception message for each error if occurs.
| Code | Description |
|---|---|
| 1001 | General exception |
| 1002 | Failed to connect to database |
| 1003 | Failed to get API key from database |
| 1004 | Failed to output API key |
| 1005 | Failed to save API key to database |
| 1006 | Invalid ChatGPT API key |
| 1007 | Failed requesting API key |
| 1008 | Failed to add command |
| 1009 | API key is invalid or missing |
| 1010 | OpenAI API error occurred |
| 1011 | Lookup exception occurred |
| 1012 | Failed to add command |
| 1013 | Failed to get last command |
| 1014 | Failed to get list of command |
| 1015 | Failed deleting last command |
| 1016 | Failed to get last command |
| 1017 | Failed clearing history |
| 1018 | Failed to copy command |
In order to perform a Graphics-related job in a Unix environment, the DISPLAY variable needs to be set initially. An error can occur when connecting to Linux via SSH, particularly if there is no copy/paste mechanism like Xclip installed. To resolve this, you can try installing Xclip using the following command: "sudo apt-get install xclip". Additionally, you need to export the DISPLAY variable by running: "export DISPLAY=:0.0".
To avoid the error message, you can use the "-no-copy" option when looking up a command, as it disables the copy feature.
Developed and maintained by:
Naif Alshaye
https://naif.io
[email protected]
The MIT License (MIT). Please see License File MIT License for more information.