---
title: "Secure Vibe Coding with AI Agents"
description: "AI coding agents make development faster but can inadvertently introduce security risks by suggesting unvetted packages. Learn how to use vet MCP server for adding security to your vibe coding adventures."
url: "https://safedep.io/blog/vibe-coding-without-getting-pwned"
author: "SafeDep Team"
published: "2025-07-25"
---

# Secure Vibe Coding with AI Agents

## Vibes and More

Recently `eslint-config-prettier`, an npm package with more than 30 million weekly downloads was compromised. We wrote about it in our earlier blog [eslint-prettier-config: Major Supply Chain Attack on npm](https://safedep.io/blog/eslint-config-prettier-major-npm-supply-chain-hack). But the fact remains, npm like other public open source package registries, is a source of supply chain attack through malicious open source packages published in these registries. AI IDEs and coding agents are likely to accelerate the risk of malicious packages in the software supply chain.

We built [SafeDep vet](https://github.com/safedep/vet) to protect software development teams against malicious packages in CI/CD. But this is not enough when it comes to AI coding agents like OpenAI Codex, Claude Code and AI IDEs like Cursor, Windsurf and others. Lets see with an example.

## Vibing like a pro

Consider you are in the vibe of building the world's best cli tool with an outstanding DevEx. You start with a boilerplate Typescript project that contains only a few dependencies like `tsc`.

```bash title="Initial dependencies"
➜ pnpm ls --depth 100 --parseable | wc -l
    8
```

You love [Claude Code](https://www.anthropic.com/claude-code) and you start with a prompt like this:

```txt title="Claude Code cli Prompt"
Set the foundation for building a multi-command cli tool with
the best developer experience for cli with interactive,
progress bars and other eye candies
```

Claude Code vibes along with you and comes up with a plan.

![Claude Code Initial Prompt](https://safedep.io/_next/static/immutable/media/vibezz-1.1og9_sqn9cg0t.png)

The plan starts with installing a bunch of 3rd party npm libraries. You are in vibe mode and go ahead with installing the 8 libraries that Claude Code suggested.

![Claude Code Plan](https://safedep.io/_next/static/immutable/media/vibezz-2.22jq46cp-rdkr.png)

After this step, you suddenly realize the number of 3rd party dependencies, code from open source, have increased to a staggering 165. You are not sure what these libraries do, but you trust Claude Code to have suggested the best libraries for your cli tool.

```bash title="After installing 8 libraries"
➜ pnpm ls --depth 100 --parseable | wc -l
    165
```

You are an advanced [vet](https://github.com/safedep/vet) user and you run a quick `vet scan` to check for potentially unpopular packages.

```bash title="Vet scan"
➜  vet --no-banner scan -M pnpm-lock.yaml \
    --insights-v2 --report-summary=false \
    --filter 'projects.exists(p, p.stars < 50)'

┌──────────────────────────┬─────────┐
│ PACKAGE                  │ VERSION │
├──────────────────────────┼─────────┤
│ proto-list               │ 1.2.4   │
│ util-deprecate           │ 1.0.2   │
│ widest-line              │ 4.0.1   │
│ os-tmpdir                │ 1.0.2   │
│ @pnpm/config.env-replace │ 1.1.0   │
│ stubborn-fs              │ 1.2.5   │
│ run-async                │ 3.0.0   │
│ is-path-inside           │ 4.0.0   │
│ @pnpm/network.ca-file    │ 1.0.2   │
│ @pnpm/npm-conf           │ 2.3.1   │
│ ansi-align               │ 3.0.1   │
│ restore-cursor           │ 3.1.0   │
│ get-east-asian-width     │ 1.3.0   │
│ is-fullwidth-code-point  │ 3.0.0   │
│ stdin-discarder          │ 0.2.2   │
│ is-in-ci                 │ 1.0.0   │
│ cli-width                │ 4.1.0   │
│ external-editor          │ 3.1.0   │
│ string_decoder           │ 1.3.0   │
│ when-exit                │ 2.1.4   │
└──────────────────────────┴─────────┘
```

You realize that you are not in control of the dependencies you are installing. You are in vibe mode and you are not thinking about the security implications of the dependencies you are installing. Many of the dependencies are not backed by even a modest community and has a similar threat profile as [eslint-config-prettier](https://safedep.io/blog/eslint-config-prettier-major-npm-supply-chain-hack). Then you hear about [Slopsquatting](https://en.wikipedia.org/wiki/Slopsquatting) and thats when it strikes you. The risk of getting hacked due to malicious code from open sources is real.

## Adding a pinch of security

Thats where [vet MCP Server](https://github.com/safedep/vet) comes in. We don't want to get in the way of your vibe coding adventures but protect you from getting hacked while vibe coding. Lets do this.

Install `vet` with homebrew or learn more about [other installation options](https://docs.safedep.io/quickstart).

```bash title="Install vet with homebrew"
brew install safedep/tap/vet
```

Add `vet` as an MCP server in Claude Code

```bash title="Add vet as an MCP server in Claude Code"
➜  claude mcp add safedep-vet vet server mcp
Added stdio MCP server safedep-vet with command: vet server mcp to local config
```

Add the following to your `CLAUDE.md` file

```txt title="Prompt for using vet MCP Server"
Always use vet-mcp to check for vulnerabilities and malware
before installing any package.
```

Thats it! Lets take Claude Code and [vet](https://github.com/safedep/vet) for a spin.

```txt title="Prompt for using vet MCP Server"
Install eslint-config-prettier@9.1.1
```

**Note:** `pkg:npm/eslint-config-prettier@9.1.1` is a known malicious package. Here we use it to test `vet` MCP server integration with Claude Code.

Claude Code now _vets_ all open source packages using [vet MCP server](https://github.com/safedep/vet), protecting you from getting hacked due to malicious code from open sources.

![Claude Code with vet MCP Server](https://safedep.io/_next/static/immutable/media/claude-code-vet-mcp.16-ga9or860-p.png)

No more getting pwned while vibe coding. You can continue your vibe coding adventures, albeit with a bit of security guardrails in place. [vet MCP Server](https://github.com/safedep/vet) supports all AI IDEs and coding agents that supports MCP. Read the [MCP Server Documentation](https://github.com/safedep/vet/blob/main/docs/mcp.md) for more details.

## Conclusion

While vibe coding is fun, security risks are real. Specifically, ensure that

1. Generated code is reviewed before use in production
2. Security vulnerabilities in generated code are fixed before use in production
3. Open source packages are vetted before installation

Finally, if you are curious, this is how the `cli` looks like after our vibe coding session.

![Claude Code Generated Tool](https://safedep.io/_next/static/immutable/media/vibezz-N.38ip-kz01a1ew.png)
