Back to all articles
DevToolsCLIRust

Stop Manually Updating Your SDKs: Why We Built a CLI

Security that requires manual code changes is security that gets skipped. Here is why we built a CLI to secure codebases automatically.

Stop Manually Updating Your SDKs: Why We Built a CLI

Stop Manually Updating Your SDKs

A developer spent three hours manually updating 47 files to add security headers to their OpenAI calls. They missed file #48. File #48 was the one that got breached.

This is the Integration Gap. Security tools often fail not because they are bad, but because they are hard to install. If you have to manually find every new OpenAI() call in your 100,000-line codebase and wrap it in a try-catch block, you are going to make a mistake.

The "Zero-Code" Philosophy

We realized that if we wanted developers to actually use PromptGuard, the friction had to be zero. "Read the docs and copy-paste this snippet" is too much friction.

So we built a CLI that modifies your code for you. Safely.

How It Works (AST, not Regex)

We didn't just sed replace strings. That's how you break production. We built an AST (Abstract Syntax Tree) transformer.

When you run:

promptguard secure .

The CLI:

  1. Parses your code into an AST (using tree-sitter).
  2. Identifies LLM client instantiations (OpenAI, Anthropic, LangChain).
  3. Injects the base_url and headers configuration directly into the constructor.
  4. Preserves your comments, formatting, and weird indentation.

Safety First

We know "automatic code modification" sounds scary. That's why:

  • Dry Run by Default: It shows you a diff of exactly what will change.
  • Instant Rollback: It creates a backup. One command (promptguard revert) undoes everything.
  • Local Only: Your code never leaves your machine. The CLI runs locally.

The Result

You can secure a monolithic repo with 500+ LLM calls in about 4 seconds.

$ promptguard secure src/
> Found 512 OpenAI instances.
> Secured 512 instances.
> 0 errors.
> Time: 3.2s

Security shouldn't be a chore. It should be a command.