> ## Documentation Index
> Fetch the complete documentation index at: https://docs.promptguard.co/llms.txt
> Use this file to discover all available pages before exploring further.

# VS Code Extension

> PromptGuard for VS Code, see unprotected LLM SDK calls in your editor, with quick fixes that run the PromptGuard CLI.

> [!NOTE]
>
> The PromptGuard VS Code extension shows the LLM SDK calls in your workspace that are not routed through PromptGuard, and runs the PromptGuard CLI to protect them. It is a front end for the [CLI](https://docs.promptguard.co/tools/cli.md): detection, setup and scanning are all done by the CLI binary.

## Installation

### From VS Code Marketplace

1. Open VS Code
2. Go to **Extensions** (Cmd/Ctrl + Shift + X)
3. Search for **"PromptGuard"**
4. Click **Install**

### From Command Line

```bash theme={"system"}
code --install-extension promptguard.promptguard-vscode
```

### From VSIX

Download the `.vsix` from [GitHub Releases](https://github.com/promptguardhq/promptguard-vscode/releases):

```bash theme={"system"}
code --install-extension promptguard-vscode-<version>.vsix
```

### Cursor, Windsurf and other VS Code forks

The extension is published on the VS Code Marketplace only, not on Open VSX, so the extension search in Cursor, Windsurf and other forks that use Open VSX does not find it. Install the `.vsix` instead:

1. Download `promptguard-vscode-<version>.vsix` from the [latest release](https://github.com/promptguardhq/promptguard-vscode/releases/latest)
2. Open the Command Palette (Cmd/Ctrl + Shift + P) and run **Extensions: Install from VSIX...**
3. Choose the downloaded file

An extension installed from a `.vsix` this way is not updated for you: install the next release's `.vsix` the same way.

### The CLI

The extension needs the PromptGuard CLI. If it cannot find one on your `PATH` or at `promptguard.cliPath`, it offers to download the latest CLI release from GitHub, checks it against the release's `.sha256` file, and installs it in the extension's own storage. `promptguard.autoInstallCli` decides whether it asks first, installs silently, or never offers. You can also run **PromptGuard: Install/Update CLI** at any time, or install the CLI yourself (see [CLI installation](https://docs.promptguard.co/tools/cli.md#installation)).

## Features

### Inline Diagnostics

After the CLI is found, and again whenever you save a supported file (if `promptguard.scanOnSave` is on), the extension runs `promptguard scan` over each workspace folder and marks what it finds:

* **Warning** (yellow): an LLM SDK client that is not routed through PromptGuard
* **Hint**: an SDK client that is already protected

### Quick Fixes

Click the lightbulb or press `Cmd/Ctrl + .` on a PromptGuard warning:

| Fix | What it does |
| - | - |
| **Initialize PromptGuard in this project** | Runs **PromptGuard: Initialize** (preferred before the project is initialized) |
| **Apply Protection** | Runs `promptguard apply` (preferred once the project is initialized) |
| **Scan File for Threats** | Sends the file's content to the PromptGuard API for a threat scan |

### Problems Panel

All findings appear in the **Problems** panel (Cmd/Ctrl + Shift + M), with the source `PromptGuard`:

```
src/api/chat.py
  ⚠ openai SDK detected. Run 'PromptGuard: Apply Protection' to secure this call.

src/agents/helper.ts
  ⚠ anthropic SDK detected. Run 'PromptGuard: Apply Protection' to secure this call.
```

### Status Bar

The status bar item reads `promptguard status` and shows one of:

* **PromptGuard: Active** -- the project is initialized and protection is on
* **PromptGuard: Disabled** -- the project is initialized but protection is off
* **PromptGuard: Not initialized** -- PromptGuard has not been set up in this project
* **PromptGuard: Unavailable** -- the CLI could not report a status
* **PromptGuard: Unknown** -- the CLI reported a status the extension does not recognise

Click it to run **PromptGuard: Show Status**.

### Sidebar

The PromptGuard view in the Activity Bar shows the project's status and the files PromptGuard manages, with buttons to install the CLI or initialize the project when either is missing.

### Threat Scanning and Redaction

Select text and run **Scan Selection for Threats** or **Redact PII from Selection** (also in the editor's context menu), or run **Scan File for Threats** on a file. These call the PromptGuard API through the CLI, so they need an API key: set one with **PromptGuard: Set API Key**, which keeps it in VS Code's secret storage.

A scan opens the **PromptGuard** output panel with the decision, confidence, threat type and reason, and shows a notification with the verdict. A redaction replaces the selected text with the redacted text and lists the PII types it found in the same panel; if the document changed while the request ran, nothing is replaced.

## Configuration

### Settings

Open **Settings** (Cmd/Ctrl + ,) and search for "PromptGuard":

| Setting | Default | Description |
| - | - | - |
| `promptguard.cliPath` | `""` | Path to the PromptGuard CLI binary. Empty means find it on `PATH`. Machine-scoped: a workspace's settings cannot override it. |
| `promptguard.scanOnSave` | `true` | Re-scan the workspace when a supported file is saved |
| `promptguard.autoInstallCli` | `prompt` | When the CLI is not found: `prompt` (ask), `never` (do nothing), or `auto` (install silently). Machine-scoped. |

### settings.json

```json theme={"system"}
{
  "promptguard.cliPath": "/usr/local/bin/promptguard",
  "promptguard.scanOnSave": false,
  "promptguard.autoInstallCli": "never"
}
```

## Commands

Access via Command Palette (Cmd/Ctrl + Shift + P):

| Command | Description |
| - | - |
| **PromptGuard: Initialize** | Set up PromptGuard in this project (`promptguard init`) |
| **PromptGuard: Detect LLM SDKs** | List the LLM SDKs used in the workspace (`promptguard scan`) |
| **PromptGuard: Show Status** | Show the project's PromptGuard status (`promptguard status`) |
| **PromptGuard: Apply Protection** | Re-apply PromptGuard to source files (`promptguard apply`) |
| **PromptGuard: Disable Protection** | Turn protection off, keeping the configuration (`promptguard disable`) |
| **PromptGuard: Enable Protection** | Turn protection back on (`promptguard enable`) |
| **PromptGuard: Scan Selection for Threats** | Scan the selected text via the PromptGuard API |
| **PromptGuard: Redact PII from Selection** | Redact PII in the selected text via the PromptGuard API |
| **PromptGuard: Scan File for Threats** | Scan a file's content via the PromptGuard API |
| **PromptGuard: Set API Key** | Store your PromptGuard API key in VS Code's secret storage |
| **PromptGuard: Select Project** | Choose the active PromptGuard project (`promptguard projects`) |
| **PromptGuard: Refresh** | Refresh the sidebar and status |
| **PromptGuard: Install/Update CLI** | Download the latest CLI release from GitHub |

## Supported Languages

| Language | File Extensions |
| - | - |
| Python | `.py` |
| JavaScript | `.js` |
| TypeScript | `.ts` |
| JSX | `.jsx` |
| TSX | `.tsx` |

## Supported Providers

The extension shows what the CLI detects:

* OpenAI
* Anthropic
* Cohere
* Hugging Face
* Google Gemini
* Groq
* AWS Bedrock

See the CLI's [Supported Providers](https://docs.promptguard.co/tools/cli.md#supported-providers) for which of these `init` and `apply` can route through PromptGuard.

## Excluded Files

There is no ignore comment. The scan skips dependency, build and test locations: `node_modules`, `.git`, `dist`, `build`, `__pycache__`, `__tests__`, `venv`, `.venv`, `.next` and `.mypy_cache` directories, and `*.test.js`, `*.test.ts`, `*.spec.js` and `*.spec.ts` files. To stop scans on save altogether, set `promptguard.scanOnSave` to `false`.

## Troubleshooting

> [accordion] Nothing happens / CLI not found
>
> **Check**:
>
> * Is the CLI installed? Run **PromptGuard: Install/Update CLI**, or set `promptguard.cliPath`
> * Is `promptguard.autoInstallCli` set to `never`?
>
> **Try**:
>
> * Reload window: Cmd/Ctrl + Shift + P → "Reload Window"
> * Check Output panel for errors: View → Output → PromptGuard

> [accordion] Findings not showing
>
> **Check**:
>
> * Is the file in an excluded location (see [Excluded Files](#excluded-files))?
> * Does the file construct a supported SDK client?
>
> **Try**:
>
> * Run "PromptGuard: Detect LLM SDKs" manually
> * Check the Problems panel (Cmd/Ctrl + Shift + M)

> [accordion] Threat scan or redaction fails
>
> **Check**:
>
> * Have you set an API key with **PromptGuard: Set API Key**?
> * Has your plan's monthly quota run out? The extension offers a link to Billing when the API reports it.

> [accordion] Performance issues
>
> **Solutions**:
>
> * Disable `promptguard.scanOnSave` for large workspaces; every save re-scans the whole workspace

## Telemetry

The extension sends no telemetry: no usage data, no activation events and no error reports. It has no telemetry setting because there is nothing to turn off.

Its network use is:

* **The CLI download.** Installing or updating the CLI calls the GitHub releases API (`api.github.com/repos/promptguardhq/promptguard-cli/releases/latest`) and downloads the binary and its `.sha256` file from that release.
* **What the CLI does when the extension runs it.** Initialize validates your API key, and threat scanning, redaction and project selection call the PromptGuard API. Detecting SDKs, status, apply, enable and disable work on local files. The CLI sends no telemetry either; see [CLI telemetry](https://docs.promptguard.co/tools/cli.md#telemetry).

## Changelog

Release notes are in the extension's [CHANGELOG](https://github.com/promptguardhq/promptguard-vscode/blob/main/CHANGELOG.md).

## Contributing

The extension is open source:

* **Repository**: [github.com/promptguardhq/promptguard-vscode](https://github.com/promptguardhq/promptguard-vscode)
* **Issues**: Report bugs or request features
* **Pull Requests**: Contributions welcome

## Next Steps

> [card] [CLI Tool](https://docs.promptguard.co/tools/cli.md)
>
> Scan from command line

> [card] [GitHub Scanner](https://docs.promptguard.co/tools/github-scanner.md)
>
> Scan repos on push and PR

> [card] [Python SDK](https://docs.promptguard.co/guides/python-sdk.md)
>
> Runtime protection

> [card] [Node.js SDK](https://docs.promptguard.co/guides/node-sdk.md)
>
> JavaScript protection


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.