Skip to main content

PromptGuard CLI

The PromptGuard CLI is a production-ready command-line tool that automatically configures your applications to route LLM requests through PromptGuard’s security proxy.

Built with Rust + Tree-sitter

Real AST transformations - never breaks your code. Single 5.3MB binary with zero runtime dependencies.

Why Use the CLI?

Zero Code Changes

Automatically modifies SDK initialization - no manual code rewriting required

Safe Transformations

Uses Tree-sitter AST parsing instead of regex. Preserves formatting and never breaks code.

Instant Setup

Configure your entire project in seconds with a single command

Easy Revert

Automatic backups let you revert changes anytime with one command

Quick Example

# Install CLI
curl -fsSL https://raw.githubusercontent.com/acebot712/promptguard-cli/main/install.sh | sh

# Initialize in your project
cd your-project
promptguard init --api-key pg_sk_test_xxx

# That's it! Your LLM requests now go through PromptGuard

What It Does

The CLI automatically transforms your code from:
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY
});
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("OPENAI_API_KEY")
)

Features

  • Real AST Transformations - Tree-sitter based parsing and modification
  • Multi-Language Support - TypeScript, JavaScript, Python
  • 4 LLM Providers - OpenAI, Anthropic, Cohere, HuggingFace
  • Automatic Backups - Safe revert with one command
  • Configuration Management - Enable/disable without deleting config
  • Zero Dependencies - Single static binary, no runtime requirements

Supported Platforms

  • macOS ARM64 (M1/M2/M3)
  • macOS x86_64 (Intel)
  • Linux x86_64
  • Linux ARM64

Commands

CommandDescription
initInitialize PromptGuard in your project
scanScan for LLM SDK usage (dry-run)
statusShow current configuration status
applyRe-apply transformations
disableTemporarily disable (restore originals)
enableRe-enable (re-apply transformations)
revertCompletely remove PromptGuard
configView configuration details
keyManage API keys
logsView activity logs
testTest configuration
updateCheck for updates

Architecture

The CLI follows a clean architecture with proper separation of concerns:
CLI
├── Detector (Tree-sitter AST)
│   ├── TypeScript/JavaScript detection
│   └── Python detection
├── Transformer (AST modification)
│   ├── TypeScript/JavaScript transformer
│   └── Python transformer
├── Scanner (File discovery)
├── Backup Manager (Safe revert)
├── Config Manager (Persistence)
└── Commands (12 production commands)

Next Steps

Open Source

The PromptGuard CLI is open source and built with:
  • Rust - Fast, safe, and reliable
  • Tree-sitter - Industry-standard AST parsing
  • Clap - Modern CLI framework
  • Cargo - Rust build system
GitHub: acebot712/promptguard-cli