Skip to main content

Troubleshooting

Solutions to common issues when using the PromptGuard CLI.

Installation Issues

Problem: After installation, running promptguard shows “command not found”Solutions:
  1. Check if /usr/local/bin is in PATH:
    echo $PATH | grep "/usr/local/bin"
    
    If not found, add it:
    # For Zsh (macOS default)
    echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
    source ~/.zshrc
    
    # For Bash
    echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
    source ~/.bashrc
    
  2. Install to user directory:
    mkdir -p ~/bin
    mv promptguard ~/bin/
    echo 'export PATH="$HOME/bin:$PATH"' >> ~/.zshrc
    source ~/.zshrc
    
  3. Verify installation:
    which promptguard
    # Should show: /usr/local/bin/promptguard
    
Problem: Install script fails with permission errorsSolutions:
  1. Run with sudo:
    curl -fsSL https://raw.githubusercontent.com/acebot712/promptguard-cli/main/install.sh | sudo sh
    
  2. Or install to user directory (no sudo needed):
    # Download binary
    curl -fsSL https://github.com/acebot712/promptguard-cli/releases/latest/download/promptguard-macos-arm64 -o promptguard
    chmod +x promptguard
    
    # Install to ~/bin
    mkdir -p ~/bin
    mv promptguard ~/bin/
    export PATH="$HOME/bin:$PATH"
    
Problem: Binary won’t run, shows “cannot execute binary file”Cause: Wrong architecture downloadedSolution:
  1. Check your system:
    uname -sm
    # Darwin arm64    → Use promptguard-macos-arm64
    # Darwin x86_64   → Use promptguard-macos-x86_64
    # Linux x86_64    → Use promptguard-linux-x86_64
    # Linux aarch64   → Use promptguard-linux-arm64
    
  2. Download correct binary:
    # Example for macOS M1/M2/M3
    curl -fsSL https://github.com/acebot712/promptguard-cli/releases/latest/download/promptguard-macos-arm64 -o promptguard
    chmod +x promptguard
    sudo mv promptguard /usr/local/bin/
    
Problem: Download fails with SSL/TLS errorsSolution (Linux):
# Ubuntu/Debian
sudo apt-get update
sudo apt-get install ca-certificates

# CentOS/Fedora
sudo yum install ca-certificates
Solution (macOS):
# Update certificates
brew install openssl

Initialization Issues

Problem: promptguard scan finds no LLM SDKsPossible causes:
  1. No SDK initialization in code (only imports):
    // ✗ Only import - not detected
    import OpenAI from 'openai';
    
    // ✓ Initialization - detected
    const client = new OpenAI({...});
    
  2. Files in excluded directories: Check node_modules, dist, build, .venv, venv are excluded by default
  3. Wrong file extension: CLI scans: .ts, .tsx, .js, .jsx, .py Skips: .json, .md, .txt
Solution:
# Check what files are being scanned
promptguard scan

# Verify your code has SDK initialization
grep -r "new OpenAI" src/
grep -r "OpenAI(" .  # Python
Problem: Error: “Invalid API key format”Solution:API keys must start with:
  • Test keys: pg_sk_test_
  • Production keys: pg_sk_prod_
Get a valid key:
  1. Visit app.promptguard.co/settings/api-keys
  2. Click “Generate New Key”
  3. Copy the key (starts with pg_sk_test_ or pg_sk_prod_)
  4. Run: promptguard init --api-key pg_sk_test_xxxxx
Problem: Cannot write to .env fileSolution:
  1. Check file permissions:
    ls -la .env
    # Should show -rw-r--r-- or similar
    
  2. Fix permissions:
    chmod 644 .env
    
  3. If .env doesn’t exist:
    touch .env
    chmod 644 .env
    promptguard init --api-key pg_sk_test_xxx
    
Problem: “PromptGuard is already initialized”Solution:
  1. Check status:
    promptguard status
    
  2. Re-apply changes:
    promptguard apply
    
  3. Or completely reset:
    promptguard revert -y
    promptguard init --api-key pg_sk_test_xxx
    

Runtime Issues

Problem: Application runs but no requests appear in dashboardDebugging steps:
  1. Verify transformation was applied:
    # Check if baseURL was added
    grep -r "baseURL" src/
    grep -r "base_url" .  # Python
    
    # Or check specific file
    cat src/ai.ts | grep baseURL
    
  2. Verify API key in code:
    # Check .env file
    cat .env | grep PROMPTGUARD_API_KEY
    
    # Verify app loads it
    # In your code:
    console.log(process.env.PROMPTGUARD_API_KEY);  // TypeScript
    print(os.environ.get("PROMPTGUARD_API_KEY"))   # Python
    
  3. Test connectivity:
    promptguard test
    
  4. Check if app is actually making LLM calls:
    • Trigger a feature that uses AI
    • Check app logs for errors
    • Verify LLM response is returned
  5. Verify correct API key in dashboard:
    • Dashboard shows requests for the specific API key
    • Ensure you’re looking at the right project
Problem: Transformation didn’t add baseURL/base_urlPossible causes:
  1. Already has baseURL: CLI skips if already configured
  2. Unsupported SDK pattern: CLI looks for standard initialization patterns
Solution:
  1. Check if already present:
    cat src/file.ts | grep baseURL
    
  2. Manually add if needed:
    const client = new OpenAI({
      apiKey: process.env.OPENAI_API_KEY,
      baseURL: "https://api.promptguard.co/api/v1"  // Add this
    });
    
  3. Then run:
    promptguard config  # Verify configuration
    
Problem: App crashes or throws errors after PromptGuard initializationDebugging:
  1. Check error message: Common errors:
    • baseURL is not a valid option → Old SDK version
    • ECONNREFUSED → Network issue
    • API key invalid → Wrong key
  2. Verify SDK version:
    # Check package.json
    cat package.json | grep openai
    
    # Update if needed
    npm install openai@latest
    
  3. Test without PromptGuard:
    # Disable temporarily
    promptguard disable
    
    # Run app
    npm run dev
    
    # If works, re-enable
    promptguard enable
    
  4. Check proxy URL:
    # Verify URL is correct
    promptguard config | grep "Proxy URL"
    
    # Should be: https://api.promptguard.co/api/v1
    
Problem: LLM API calls are very slow or timeoutPossible causes:
  1. Network latency to PromptGuard proxy
  2. Slow upstream LLM provider
  3. Heavy security scanning
Solution:
  1. Test direct connection:
    curl -I https://api.promptguard.co/api/v1/chat/completions
    # Should return 200 OK quickly
    
  2. Check dashboard for latency: Visit app.promptguard.co/dashboard
    • View “Response Time” metrics
    • PromptGuard adds ~10-50ms typically
  3. Increase timeout in code:
    const client = new OpenAI({
      baseURL: "https://api.promptguard.co/api/v1",
      timeout: 60000  // 60 seconds
    });
    
  4. Contact support if persistent: [email protected]

Configuration Issues

Problem: .promptguard.json is invalid or corruptedSolution:
  1. Validate JSON:
    cat .promptguard.json | jq
    # If error, JSON is invalid
    
  2. Delete and reinitialize:
    rm .promptguard.json
    promptguard init --api-key pg_sk_test_xxx
    
  3. Or manually fix: Edit .promptguard.json with proper JSON syntax
Problem: promptguard revert doesn’t restore filesPossible causes:
  1. No backup files (.bak files deleted)
  2. Backups disabled during init
Solution:
  1. Check for backups:
    find . -name "*.bak"
    
  2. If backups exist:
    # Manually restore
    for f in $(find . -name "*.bak"); do
      original="${f%.bak}"
      cp "$f" "$original"
    done
    
  3. If no backups, use git:
    git checkout -- .
    git clean -fd
    
Always keep backups. Never use --no-backup flag.
Problem: Multiple config files in monorepo causing confusionSolution:Each project should have its own config:
monorepo/
├── packages/
│   ├── frontend/
│   │   ├── .promptguard.json  ← Separate
│   │   └── .env
│   └── backend/
│       ├── .promptguard.json  ← Separate
│       └── .env
Run CLI in each directory:
cd packages/frontend
promptguard init

cd ../backend
promptguard init

Command-Specific Issues

Problem: promptguard test shows errorsCommon failures:
  1. API key invalid:
    ✗ API key is invalid
    
    → Get new key from dashboard
  2. Proxy unreachable:
    ✗ Connection failed: Network error
    
    → Check internet connection → Verify https://api.promptguard.co is accessible
  3. Config not found:
    Error: Not initialized
    
    → Run promptguard init first
Problem: Disable/enable commands don’t change filesSolution:
  1. Check status:
    promptguard status
    # Should show: Status: Disabled / Enabled
    
  2. Verify backups exist:
    find . -name "*.bak"
    
  3. Manually check files:
    # After disable, baseURL should be gone
    cat src/ai.ts | grep baseURL
    # Should return nothing
    
    # After enable, baseURL should be present
    promptguard enable
    cat src/ai.ts | grep baseURL
    # Should show: baseURL: "..."
    

Getting Help

If you’re still stuck:

Run Diagnostics

promptguard doctor
Checks common issues

Check Logs

promptguard logs
View activity logs

GitHub Issues

Report bugs or request features

Collecting Debug Information

When reporting issues, include:
# 1. CLI version
promptguard --version

# 2. Operating system
uname -a

# 3. Configuration (remove API key first!)
cat .promptguard.json | sed 's/"api_key": ".*"/"api_key": "REDACTED"/'

# 4. Scan results
promptguard scan

# 5. Test results
promptguard test

# 6. Error message (full output)
promptguard <command> 2>&1 | tee error.log
Send the output to [email protected]

Next Steps