Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

praveenc/copt

Repository files navigation

⚡ copt — Claude Prompt Optimizer

Optimize your prompts for Claude 4.5 models

License: MIT Rust Release Build

Claude 4.5 models do exactly what you ask — no more, no less. Prompts that worked with Claude 3.x may need adjustment. copt analyzes your prompts for anti-patterns and optimizes them using Claude 4.5 itself.


Installation

Pre-built Binaries

Platform Download
macOS (Apple Silicon) copt-macos-arm64
macOS (Intel) copt-macos-x64
Linux (x64) copt-linux-x64
Windows (x64) copt-windows-x64.exe
# macOS/Linux quick install
curl -L https://github.com/praveenc/copt/releases/latest/download/copt-macos-arm64 -o copt
chmod +x copt && sudo mv copt /usr/local/bin/
⚠️ macOS Gatekeeper note

If macOS blocks the binary, either:

  1. Go to System Settings → Privacy & Security and click "Allow Anyway"
  2. Or run: xattr -d com.apple.quarantine /usr/local/bin/copt

From Source

cargo install --git https://github.com/praveenc/copt

Quick Start

1. Set Up Credentials

# Bedrock API key (recommended — simplest setup)
export AWS_BEARER_TOKEN_BEDROCK="your-bedrock-api-key"

# Or Anthropic API
export ANTHROPIC_API_KEY="sk-ant-..."

# Or AWS credential chain (SigV4 fallback — no API key needed)
# Uses ~/.aws/credentials, AWS_PROFILE, IAM roles, SSO, etc.

To generate a Bedrock API key: Bedrock console → API keys → Generate long-term key (up to 1 year).

2. Create a Config File (optional)

copt --config-init    # Creates ~/.config/copt/config.toml

Edit the config to set your preferred defaults (including API key):

[default]
provider = "bedrock"
model = "us.anthropic.claude-sonnet-4-5-20250929-v1:0"

[bedrock]
region = "us-west-2"
api_key = "your-bedrock-api-key"   # or use AWS_BEARER_TOKEN_BEDROCK env var

[output]
format = "pretty"
show_diff = false

CLI arguments always take precedence over config values.

3. Optimize a Prompt

copt "Create a dashboard"           # Direct input
copt -f my-prompt.txt               # From file
copt -f prompt.txt --offline        # Analyze only (no API calls)
copt -f prompt.txt -i               # Interactive TUI mode

What It Does

copt detects Claude 3.x patterns and rewrites them for Claude 4.5:

Pattern Problem Fix
Don't use X Negative framing Reframe positively
Can you help... Indirect command Direct instruction
NEVER do X Aggressive caps Normal casing
Create something Vague instruction Add explicit requirements

Example transformation:

- Don't use placeholder data. Can you help me create a dashboard?
+ Use real data from the API. Create an analytics dashboard with:
+ - User metrics visualization
+ - Date range filtering
+ - Export functionality

See docs/RULES.md for the full list of 25 analysis rules across 8 categories.


CLI Reference

View full --help output
⚡ Optimize prompts for Claude 4.5 models

Usage: copt [OPTIONS] [PROMPT]

Arguments:
  [PROMPT]  Prompt text to optimize

Options:
  -f, --file <FILE>              Read prompt from file
  -o, --output <FILE>            Save optimized prompt to file
      --output-dir <DIR>         Output directory for auto-save
      --no-save                  Disable auto-save
  -p, --provider <PROVIDER>      Provider: anthropic, bedrock
  -m, --model <MODEL>            Model ID or alias
      --region <REGION>          AWS region for Bedrock
      --format <FORMAT>          Output format: pretty, json, quiet
      --diff                     Show before/after diff
      --show-prompt              Display optimized prompt
  -q, --quiet                    Quiet mode (prompt only)
      --analyze                  Analyze only, no optimization
      --offline                  Offline mode (no API calls)
      --check <CAT>              Check specific categories
      --no-suggest               Disable auto-suggestions for vague prompts
  -i, --interactive              Launch full-screen interactive TUI mode
  -e, --editor                   Open editor for multi-line input
      --skip-connectivity-check  Skip connectivity check
      --config-init              Create default config file and exit
  -v, --verbose                  Verbose output
  -h, --help                     Print help
  -V, --version                  Print version

Model Aliases

Use short aliases instead of full Bedrock ARNs:

Alias Model
sonnet / sonnet-4.5 us.anthropic.claude-sonnet-4-5-20250929-v1:0
opus / opus-4.5 us.anthropic.claude-opus-4-5-20251101-v1:0
opus-4.6 us.anthropic.claude-opus-4-6-v1
haiku / haiku-4.5 us.anthropic.claude-haiku-4-5-20251001-v1:0
copt -f prompt.txt -m opus            # Use Claude Opus 4.5
copt -f prompt.txt -m haiku           # Use Claude Haiku 4.5

Common Examples

copt -f prompt.txt --offline          # Analyze without API calls
copt -f prompt.txt --diff             # Show before/after diff
copt -f prompt.txt -p anthropic       # Use Anthropic API
copt -f prompt.txt --format json      # JSON output for scripting
copt -f prompt.txt --no-suggest       # Disable suggestions (for CI)
copt --config-init                    # Create default config file

Interactive Mode

Launch with -i for a full-screen TUI:

copt -f prompt.txt -i

Keyboard shortcuts:

Key Action
q Quit
d Toggle diff view
c Copy to clipboard
s / e Save & open in editor
? Help

Prompt Storage

Optimized prompts are auto-saved to ~/.copt/prompts/YYYY-MM-DD/ with descriptive filenames:

~/.copt/prompts/
└── 2026-02-15/
    ├── dashboard-analytics-api_143022_original.txt
    ├── dashboard-analytics-api_143022_optimized.txt
    └── dashboard-analytics-api_143022.json

Use --output-dir <DIR> to override, or --no-save to disable.


Raycast Integration

Optimize prompts directly from your clipboard. See scripts/raycast/README.md for setup.


Documentation


License

MIT — Copyright (c) 2026 Praveen Chamarthi


Built for the Claude developer community ❤️

About

⚡ CLI tool to migrate prompts from Claude 3.x to Claude 4.5 — Analyzes anti-patterns, optimizes with LLM, supports AWS Bedrock & Anthropic API

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages