Skip to main content

Semgrep Guardian

Semgrep Guardian integrates natively with AI coding agents like Claude Code and Cursor to catch security issues before they ship. It bundles the Semgrep MCP server, Hooks, and Skills into a single install, and scans every file an agent generates using Semgrep Code, Supply Chain, and Secrets. When findings are detected, the agent is prompted to regenerate code until Semgrep returns clean results or you choose to dismiss them.

The plugin uses each IDE's native hook or MCP system:

This guide covers setup for each of the preceding products listed, but the plugin works with any MCP client.

Prerequisites

  • Python 3.10 or later (the Semgrep CLI requires it at runtime regardless of how it was installed)
  • Homebrew, pipx, or uv to install Semgrep
  • A Semgrep account

Install the Semgrep CLI

These steps are the same regardless of which IDE you use.

  1. Install Semgrep using Homebrew, pipx, or uv:

    # install using Homebrew
    brew install semgrep

    # or, install using pipx (https://pipx.pypa.io/stable/how-to/install-pipx/)
    pipx install semgrep

    # or, install using uv (https://docs.astral.sh/uv/)
    uv tool install semgrep
  2. Verify that you've installed the latest version of Semgrep:

    semgrep --version
  3. Sign in to your Semgrep account and install the Semgrep Pro engine:

    semgrep login && semgrep install-semgrep-pro

    semgrep login launches a browser window. You can also use the activation link printed in the terminal.

Connect to your IDE

  1. Start a new Claude Code instance in the terminal:

    claude
  2. Open the plugin manager:

    /plugin
  3. Go to Discover, search for Semgrep, and click Install.

  4. Set up the Guardian:

    /setup-semgrep-plugin

The plugin registers a post-tool hook so Claude Code scans every file it writes. Learn more about Claude Code plugins and hooks.

Scan your code

  1. Open up your IDE's AI chat window.
  2. Ensure that you're in the correct context to use Semgrep.
  3. Prompt your IDE to scan with Semgrep.

By default, the Semgrep Guardian runs all three Semgrep products: Code, Supply Chain, and Secrets.

Additional resources


Not finding what you need in this doc? Ask questions in our Community Slack group, or see Support for other ways to get help.