# AI use cases for Semgrep (semgrep/semgrep)

Repo: [semgrep/semgrep](https://github.com/semgrep/semgrep) | Use cases: 3 | Page: https://dedupedai.com/use-cases/semgrep-semgrep/

Semgrep is a fast static analysis engine for finding bugs and vulnerabilities in source code and dependencies. Rules look like the code you already write, it supports 30+ languages, and it runs from the CLI, in CI on pull requests, or as an MCP server for AI coding assistants.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Search your code for a bug pattern in one command: https://dedupedai.com/use-cases/semgrep-semgrep/search-your-code-for-a-bug-pattern-with-semgrep/
- Scan a project for vulnerabilities with Semgrep ci: https://dedupedai.com/use-cases/semgrep-semgrep/scan-a-project-with-semgrep-ci/
- Give your AI coding assistant Semgrep scans over MCP: https://dedupedai.com/use-cases/semgrep-semgrep/give-your-ai-coding-assistant-semgrep-scans/

## How to search your code for a bug pattern in one command with Semgrep

Repo: [semgrep/semgrep](https://github.com/semgrep/semgrep) | Difficulty: Beginner | Time: 15 minutes | Basis: From the README

Install the CLI and write a pattern query inline with -e.

**Who it is for:** A developer who wants a quick structural search that grep cannot do.

**The problem:** Plain text search cannot match code by structure, such as the same expression on both sides of a comparison.

**The outcome:** A list of matches in your source folder for the pattern you wrote.

### Steps

1. Install with `pipx install semgrep`
2. Run `semgrep -e '$X == $X' --lang=py path/to/src`, using your own source path
3. Read each match, which is a Python comparison with identical sides and a possible bug
4. Change the pattern and rerun to look for other shapes

### Prompt to paste into your agent

```text
Using semgrep/semgrep, install it with `pipx install semgrep` and run `semgrep -e '$X == $X' --lang=py path/to/src` on my code. Summarise each match and say which look like real bugs.
```

### Caveat

This card is written from the semgrep/semgrep README, not from a test run by Deduped. Before you start, make sure you have Python and pip, or pipx, uv, Homebrew or Docker. Check the repo for newer instructions before you rely on these steps.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/semgrep-semgrep/search-your-code-for-a-bug-pattern-with-semgrep/

## How to scan a project for vulnerabilities with Semgrep ci

Repo: [semgrep/semgrep](https://github.com/semgrep/semgrep) | Difficulty: Intermediate | Time: 30 minutes | Basis: From the README

Log in once and scan source code and dependencies from the app root.

**Who it is for:** A team that wants a first security scan of an existing repository.

**The problem:** Nobody has checked the codebase and its dependencies for known vulnerable patterns.

**The outcome:** A report of findings in your source code and its dependencies.

### Steps

1. Install with `uv tool install semgrep`
2. Run `semgrep login` to create your account and log in, which is optional but unlocks more rules
3. Go to your app's root directory
4. Run `semgrep ci` to scan the project
5. Triage the findings and fix the real ones

### Prompt to paste into your agent

```text
With semgrep/semgrep installed via `uv tool install semgrep`, run `semgrep ci` in my project root and group the findings by severity with a suggested fix for each.
```

### Caveat

The README says registry configs report pseudonymous rule metrics; use --metrics=off to disable them.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/semgrep-semgrep/scan-a-project-with-semgrep-ci/

## How to give your AI coding assistant Semgrep scans over MCP with Semgrep

Repo: [semgrep/semgrep](https://github.com/semgrep/semgrep) | Difficulty: Intermediate | Time: 30 minutes | Basis: From the README

Start the built-in MCP server so assistants can run scans while they write code.

**Who it is for:** A developer using Cursor, VS Code or another MCP client who wants security checks on generated code.

**The problem:** AI generated code ships without any automatic security scan.

**The outcome:** An MCP server your assistant can call to scan files it just wrote.

### Steps

1. Install with `pipx install semgrep`
2. Start the server locally with `semgrep mcp`
3. Register it in your MCP client following your client's settings
4. Ask the assistant to scan code it generated and fix what Semgrep reports

### Prompt to paste into your agent

```text
Using semgrep/semgrep, install it with `pipx install semgrep`, start `semgrep mcp`, then scan the files you changed and fix every finding.
```

### Caveat

This card is written from the semgrep/semgrep README, not from a test run by Deduped. Before you start, make sure you have Python and pip, or pipx, uv, Homebrew or Docker. Check the repo for newer instructions before you rely on these steps.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/semgrep-semgrep/give-your-ai-coding-assistant-semgrep-scans/
