Skip to main content

Commands Reference

Complete documentation for all 12 PromptGuard CLI commands.

promptguard init

Initialize PromptGuard in your project by scanning for LLM SDKs and applying transformations.

Usage

promptguard init [OPTIONS]

Options

OptionShortDescriptionDefault
--api-key <KEY>-kPromptGuard API key (required)-
--provider <PROVIDER>-pSpecific provider to configureAuto-detect
--base-url <URL>Custom proxy URLhttps://api.promptguard.co/api/v1
--yes-ySkip confirmation promptsfalse
--no-backupSkip creating backup filesfalse
--dry-runPreview changes without modifying filesfalse

Examples

promptguard init --api-key pg_sk_test_xxx

What It Does

  1. Scans project for LLM SDK usage
  2. Detects OpenAI, Anthropic, Cohere, HuggingFace SDKs
  3. Creates backup files (*.bak)
  4. Modifies SDK initialization to add baseURL/base_url
  5. Saves API key to .env
  6. Creates .promptguard.json configuration

promptguard scan

Scan project for LLM SDK usage without making any changes (dry-run).

Usage

promptguard scan [OPTIONS]

Options

OptionShortDescription
--jsonOutput results in JSON format

Examples

# Basic scan
promptguard scan

# JSON output
promptguard scan --json

Output

🛡️  PromptGuard CLI v2.0.0
==================================================

📊 LLM SDK Detection Report

OpenAI SDK (3 files, 5 instances)
├── src/services/ai.ts
├── src/utils/chat.ts
└── lib/completions.ts

Anthropic SDK (1 files, 1 instances)
└── src/services/claude.ts

Summary:
  • Total files scanned: 47
  • Total instances: 6

Providers detected:
  ✓ openai
  ✓ anthropic

Next: promptguard init

promptguard status

Show current PromptGuard configuration and status.

Usage

promptguard status

Examples

promptguard status

Output

PromptGuard Status
==================================================

Status: ✓ Active
API Key: pg_sk_test_1********* (configured)
Proxy URL: https://api.promptguard.co/api/v1

Configuration:
  • Config file: .promptguard.json
  • Files managed: 3
  • Providers: openai, anthropic

View full dashboard: https://app.promptguard.co/dashboard

promptguard apply

Re-apply transformations based on current configuration. Useful after changing proxy URL or providers.

Usage

promptguard apply

When to Use

  • After updating proxy URL in config
  • After manual code changes
  • To re-apply transformations if files were modified

Examples

promptguard apply

promptguard disable

Temporarily disable PromptGuard by restoring original files while keeping configuration and backups.

Usage

promptguard disable

What It Does

  1. Restores all files from backups
  2. Marks configuration as disabled
  3. Keeps .promptguard.json and backups

Examples

promptguard disable
Re-enable later with:
promptguard enable

promptguard enable

Re-enable PromptGuard by re-applying transformations.

Usage

promptguard enable

What It Does

  1. Re-scans project for LLM SDKs
  2. Re-applies transformations
  3. Marks configuration as enabled

Prerequisites

  • Must have been previously initialized
  • Configuration file must exist

promptguard revert

Completely remove PromptGuard by restoring original files and deleting all configuration.

Usage

promptguard revert [OPTIONS]

Options

OptionShortDescription
--yes-ySkip confirmation prompt

What It Does

  1. Restores all files from backups
  2. Deletes all backup files
  3. Removes API key from .env
  4. Deletes .promptguard.json

Examples

promptguard revert
This action cannot be undone. Your code will be restored to its original state.

promptguard config

View current configuration details.

Usage

promptguard config

Examples

promptguard config

Output

PromptGuard Configuration
==================================================

Configuration:
  Version: 1.0
  Status: Enabled ✓
  Proxy URL: https://api.promptguard.co/api/v1
  Providers: openai, anthropic
  Environment file: .env
  API key variable: PROMPTGUARD_API_KEY
  Backups: Enabled
  Backup extension: .bak

Exclude patterns:
  • **/*.test.js
  • **/*.test.ts
  • **/node_modules/**
  • **/dist/**
  • **/__tests__/**
  • **/.venv/**

Metadata:
  CLI version: 2.0.0
  Files managed: 3

Configuration file: /path/to/project/.promptguard.json

Commands:
  promptguard disable  - Temporarily disable PromptGuard
  promptguard enable   - Re-enable PromptGuard
  promptguard revert   - Completely remove PromptGuard

promptguard key

Manage API keys (update, view, rotate).

Usage

promptguard key

What It Does

Interactive menu for:
  1. Update API key
  2. Show full key
  3. Rotate key (guidance)

Examples

promptguard key

Interactive Menu

API Key Management
==================================================

Current API key:
  PROMPTGUARD_API_KEY = pg_sk_test_...1234

Options:
  1. Update API key
  2. Show full key (masked)
  3. Rotate key
  4. Cancel

Select option (1-4):

promptguard logs

View activity logs and link to dashboard.

Usage

promptguard logs

Examples

promptguard logs

Output

Activity Logs
==================================================

ℹ Fetching logs from PromptGuard API...

View your complete activity logs at:
  https://app.promptguard.co/dashboard/activity

Recent activity:
  • Request logs
  • Security events
  • API usage

For real-time monitoring:
  Visit the dashboard at https://app.promptguard.co/dashboard
Detailed logs are available in the web dashboard. CLI shows summary and links.

promptguard test

Test configuration and verify API connectivity.

Usage

promptguard test

What It Does

  1. Validates API key format
  2. Tests connection to PromptGuard API
  3. Checks configuration status

Examples

promptguard test

Output

Test PromptGuard Configuration
==================================================

Testing configuration...

🔑 API Key Validation
  ✓ API key is valid
  ✓ Proxy endpoint is reachable

⚙️ Configuration Check
  ✓ PromptGuard is enabled
  Providers: openai
  Proxy: https://api.promptguard.co/api/v1

✓ Configuration test complete!

Next steps:
  • Run your application
  • Monitor requests: https://app.promptguard.co/dashboard
  • View logs: promptguard logs

promptguard doctor

Diagnose common configuration issues.

Usage

promptguard doctor

What It Checks

  • Configuration file exists and is valid
  • API key format
  • Backup files present
  • File permissions
  • SDK detection

Examples

promptguard doctor

promptguard update

Check for CLI updates and show installation instructions.

Usage

promptguard update

Examples

promptguard update

Output

Update PromptGuard CLI
==================================================

Current version: v2.0.0
ℹ Checking for updates...

To update PromptGuard CLI:
  • Using install script:
      curl -fsSL https://get.promptguard.co | sh

  • Using Homebrew:
      brew upgrade promptguard

  • Using cargo:
      cargo install --force promptguard-cli

Release notes:
  https://github.com/acebot712/promptguard-cli/releases

Documentation:
  https://docs.promptguard.co/cli

Global Options

Available for all commands:
OptionShortDescription
--help-hShow help for command
--version-VShow CLI version

Examples

# Show version
promptguard --version

# Help for specific command
promptguard init --help

# General help
promptguard --help

Exit Codes

CodeMeaning
0Success
1General error
2Invalid arguments
3Not initialized
4API error
5File system error
Useful for CI/CD:
if ! promptguard test; then
  echo "PromptGuard configuration test failed"
  exit 1
fi

Environment Variables

The CLI respects these environment variables:
VariableDescriptionDefault
PROMPTGUARD_API_KEYAPI key (alternative to —api-key)-
PROMPTGUARD_CONFIG_PATHCustom config file location.promptguard.json
NO_COLORDisable colored outputfalse

Examples

# Use environment variable for API key
export PROMPTGUARD_API_KEY=pg_sk_test_xxx
promptguard init

# Custom config path
export PROMPTGUARD_CONFIG_PATH=/path/to/config.json
promptguard status

Next Steps