promptrix-cli
Version:
Professional prompt engineering CLI from The Prompt Engineering Platform. Optimize AI prompts with advanced tools and analytics.
384 lines (279 loc) ⢠9.76 kB
Markdown
# Promptrix CLI
> š AI-powered prompt optimization from your terminal
[](https://www.npmjs.com/package/@promptrix/cli)
[](https://promptrix.co/terms)
Promptrix CLI brings the power of AI prompt optimization directly to your development workflow. Optimize prompts for ChatGPT, Claude, Gemini, and more with a simple command.
## šÆ Features
- **Instant Optimization**: Transform any prompt into a more effective version
- **Advanced Methods**: 21+ optimization methods with category and complexity filtering
- **Multi-Model Support**: Optimize for specific AI models (GPT-4, Claude, Gemini, etc.)
- **Multiple Styles**: Choose from concise, detailed, creative, or technical outputs
- **Pipe Support**: Integrate seamlessly with Unix tools and scripts
- **Free Tier**: 100 optimizations per month at no cost
- **Developer-Friendly**: JSON output, quiet mode, and scriptable interface
## š¦ Installation
```bash
npm install -g promptrix-cli
```
Or use directly with npx:
```bash
npx promptrix-cli "Your prompt here"
```
## š Authentication
Get your free API key (100 optimizations/month):
1. Visit [https://promptrix.co/developers](https://promptrix.co/developers)
2. Sign up for a free account
3. Copy your API key
4. Configure the CLI:
```bash
promptrix config --key your-api-key-here
```
Alternatively, set via environment variable:
```bash
export PROMPTRIX_API_KEY=your-api-key-here
```
## š Usage
### Basic Optimization
```bash
promptrix "Explain quantum computing"
```
### Target Specific Models
```bash
# Optimize for GPT-4
promptrix "Write a Python function" --target gpt-4
# Optimize for Claude
promptrix "Analyze this text" --target claude-3
# Optimize for Gemini
promptrix "Create a story" --target gemini
```
### Style Options
```bash
# Concise output
promptrix "Summarize machine learning" --style concise
# Detailed explanation
promptrix "Explain Docker" --style detailed
# Creative writing
promptrix "Write a story opening" --style creative
# Technical documentation
promptrix "Document this API" --style technical
```
### Pipe from Files or Commands
```bash
# From file
cat prompt.txt | promptrix
# From another command
echo "Explain this concept" | promptrix
# Chain with other tools
promptrix "Generate SQL query" | mysql database
```
### JSON Output
```bash
promptrix "Your prompt" --format json
```
Output:
```json
{
"improvedPrompt": "...",
"improvements": ["..."],
"confidence": 0.95
}
```
### Check Usage
```bash
promptrix usage
```
Output:
```
š Promptrix Usage Stats
āāāāāāāāāāāāāāāāāāāāāā
Used: 42 / 100 (42%)
Remaining: 58
Resets: 01/01/2024
```
### Optimization Methods
List available optimization methods:
```bash
promptrix methods
```
Output with enhanced metadata:
```
š§ Available Optimization Methods
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Your tier: PRO
Available: 21 methods
Locked: 0 methods
ā
Available Methods:
š§ Chain of Thought
Adds systematic reasoning steps to prompts
ā Basic ⢠š§ Reasoning & Analysis ⢠ā±ļø 5-15s
Tier: FREE
Use: promptrix "prompt" --method CHAIN_OF_THOUGHT
ā
Chain-of-Verification
Reduces hallucinations by adding fact-checking
āā Intermediate ⢠š Verification & Quality ⢠ā±ļø 15-30s
Tier: PRO
Use: promptrix "prompt" --method CHAIN_OF_VERIFICATION
š” Tip: Filter methods with --category or --complexity flags
```
### Filter Methods by Category
```bash
# Show only verification methods
promptrix methods --category verification
# Show only reasoning methods
promptrix methods --category reasoning
# Available categories:
# - verification: Reduce hallucinations, improve accuracy
# - reasoning: Systematic thinking, multi-perspective analysis
# - structure: Organize output, format responses
# - learning: Learn from examples, improve patterns
# - planning: Break down complex tasks, strategize
```
### Filter Methods by Complexity
```bash
# Show only basic methods (fast, simple)
promptrix methods --complexity basic
# Show only advanced methods (complex, thorough)
promptrix methods --complexity advanced
# Complexity levels:
# - basic: ā Quick optimization (5-15s)
# - intermediate: āā Balanced approach (15-30s)
# - advanced: āāā Deep optimization (25-45s)
```
### Combine Filters
```bash
# Find advanced reasoning methods
promptrix methods --category reasoning --complexity advanced
# Find basic verification methods
promptrix methods --category verification --complexity basic
```
### Use Advanced Methods
```bash
# Apply specific optimization method
promptrix "Explain blockchain" --method CHAIN_OF_VERIFICATION
# Use expert panel method for multiple perspectives
promptrix "Design a system" --method EXPERT_PANEL_SIMULATOR
```
## š ļø Advanced Usage
### Configuration File
The CLI stores configuration in `~/.promptrix/config.json`:
```json
{
"apiKey": "your-key",
"defaultStyle": "concise",
"defaultTargetModel": "gpt-4",
"analytics": true
}
```
### Scripting Example
```bash
#!/bin/bash
# optimize_prompts.sh
for file in prompts/*.txt; do
optimized=$(cat "$file" | promptrix --quiet)
echo "$optimized" > "optimized/$(basename "$file")"
done
```
### CI/CD Integration
```yaml
# GitHub Actions Example
- name: Optimize prompts
run: |
npm install -g @promptrix/cli
echo "${{ secrets.PROMPTRIX_API_KEY }}" | promptrix config --key -
promptrix "Deploy message" > deploy_message.txt
```
## šØ Command Reference
| Command | Description |
|---------|-------------|
| `promptrix [prompt]` | Optimize a prompt |
| `promptrix methods` | List optimization methods |
| `promptrix methods --category <cat>` | Filter methods by category |
| `promptrix methods --complexity <level>` | Filter methods by complexity |
| `promptrix methods show <name>` | Show method details |
| `promptrix --help` | Show help message |
| `promptrix --version` | Show version |
| `promptrix config --key <key>` | Set API key |
| `promptrix usage` | Check usage stats |
### Options
| Option | Description | Example |
|--------|-------------|---------|
| `--method <name>` | Use specific optimization method | `--method CHAIN_OF_VERIFICATION` |
| `--target <model>` | Target AI model | `--target gpt-4` |
| `--style <style>` | Output style | `--style concise` |
| `--level <level>` | Complexity level | `--level expert` |
| `--format <format>` | Output format | `--format json` |
| `--lang <language>` | Output language | `--lang es` |
| `--quiet` | Suppress decorative output | `--quiet` |
| `--no-analytics` | Disable anonymous telemetry | `--no-analytics` |
### Method Filter Options (for `promptrix methods` command)
| Option | Description | Values |
|--------|-------------|--------|
| `--category <cat>` | Filter by category | `verification`, `reasoning`, `structure`, `learning`, `planning` |
| `--complexity <level>` | Filter by complexity | `basic`, `intermediate`, `advanced` |
## š” Examples
### Development Workflows
```bash
# Optimize code documentation
promptrix "Document this function: $(cat function.js)"
# Generate commit messages with verification method
git diff | promptrix "Write commit message for these changes" --method CHAIN_OF_VERIFICATION
# Create test cases with expert panel method
promptrix "Generate test cases for login function" --method EXPERT_PANEL_SIMULATOR
# Find methods suitable for code tasks
promptrix methods --category structure --complexity basic
```
### Content Creation
```bash
# Blog post outline
promptrix "Create blog outline about AI trends" --style detailed
# Social media posts
promptrix "Tweet about product launch" --style creative --target gpt-4
# Email templates
promptrix "Customer support email for refund request" --style professional
```
### Data & Analysis
```bash
# SQL queries
promptrix "Query to find top customers by revenue" --style technical
# Data analysis
cat data.csv | head -10 | promptrix "Analyze this data pattern"
# RegEx patterns
promptrix "Regex to match email addresses" --format json
```
## š Pro Tips
1. **Save commonly used prompts**: Create aliases for frequent optimizations
```bash
alias commit-msg='git diff | promptrix "Write commit message"'
```
2. **Batch processing**: Process multiple files efficiently
```bash
find . -name "*.prompt" -exec promptrix {} \;
```
3. **Integration with AI tools**: Pipe optimized prompts directly to AI CLIs
```bash
promptrix "Your prompt" | gpt-cli
```
4. **Version control prompts**: Track prompt evolution in git
```bash
promptrix "Initial prompt" > prompts/v1.txt
git add prompts/v1.txt
```
## š Pricing
- **Free**: 100 optimizations/month
- **Pro** ($19/month): 1,000 optimizations/month
- **Business** ($99/month): 10,000 optimizations/month
Upgrade at [https://promptrix.co/pricing](https://promptrix.co/pricing)
## š Links
- [Documentation](https://docs.promptrix.co)
- [API Reference](https://docs.promptrix.co/api)
- [GitHub Issues](https://github.com/pupik1989/promptrix-cli)
- [Web Dashboard](https://app.promptrix.co)
## š License
Copyright Ā© 2024 Promptrix Inc. All rights reserved.
This software is proprietary and confidential. Unauthorized copying, modification, or distribution is strictly prohibited. See [Terms of Service](https://promptrix.co/terms) for details.
## š¤ Support
Need help? We're here for you:
- š§ Email: kpupik@gmail.com
- š Issues: [Report on GitHub](https://github.com/pupik1989/promptrix-cli)
---
Made with ā¤ļø by the Promptrix team