# vibe-shield

Adopt this skill: https://proskills.md/skills/other/avivgerz-hue-vibe-shield-claude-skills-vibe-shield

Page: https://proskills.md/skills/other/avivgerz-hue-vibe-shield-claude-skills-vibe-shield
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: .claude/skills/vibe-shield/SKILL.md
size: 3945
sha: 549f1cdee9d166cda4f82496fab0bd4df15e891f
upstream: https://github.com/avivgerz-hue/vibe-shield/blob/main/.claude/skills/vibe-shield/SKILL.md

````text
---
name: vibe-shield
description: Apply a six-phase defensive security review to changes affecting applications, APIs, data, AI agents, and MCP configuration. Use static evidence, preserve behavior, and report limitations.
allowed-tools: Bash(npx -y @vibefoundry/vibe-shield scan*), Bash(npx -y @vibefoundry/vibe-shield audit-skills*), Bash(npx -y @vibefoundry/vibe-shield explain*), Read(./**), Grep, Glob
license: MIT
metadata:
  author: VibeFoundry
  homepage: https://github.com/avivgerz-hue/vibe-shield
  version: 2.0.0
---

# Defensive AppSec architect protocol

Work only within the authorized project. Static findings are evidence for review, not proof of exploitability or a guarantee of safety. Do not transmit source code or secrets. Ask before changing production services, rotating credentials, or making destructive changes.

## Phase 1: Attack-surface reconnaissance

Map entrypoints and trust boundaries: API methods, authentication and authorization, middleware matchers, database tables and policies, storage, LLM inputs and tools, webhooks, and agent/MCP configuration. Check deployment configuration and exclusions. Identify what the scanner cannot see.

## Phase 2: Automated static scan and skill audit

```bash
npx -y @vibefoundry/vibe-shield scan . --format json
npx -y @vibefoundry/vibe-shield audit-skills . --format json
```

Inspect findings, inventory, ignored paths, and the files scanned. The explicit `.` includes test and documentation files: review fixtures as examples rather than blindly changing them. Use `explain <RULE_ID>` to investigate a rule. These commands run locally; first-time installation with npx requires registry access.

## Phase 3: Deep contextual threat modeling

Trace untrusted input through authentication, ownership checks and tenant boundaries to database, filesystem, network, HTML, and LLM sinks. Inspect IDOR, business-logic bypasses, webhook signature verification and asynchronous jobs. Check cross-file guards and deployed database policies; absence of a static finding is not evidence of protection.

## Phase 4: Surgical zero-regression remediation

- On Next.js mutation routes, authenticate the session on the server and authorize the target resource against the session principal before writes. Do not trust identity from request bodies.
- Enable Supabase RLS and write action-specific policies using the authenticated principal; test both permitted and denied tenants before deploying migrations.
- Validate inputs at the boundary with a schema such as Zod, then use parameterized database queries. Treat LLM output as untrusted.
- Use explicit CORS allowlists, secure cookie flags and a CSP appropriate for the application. Test login, redirects, and browser behavior.
- Report exposed credentials to the owner for provider-side rotation; avoid reproducing their values in reports. Do not suppress findings or weaken controls to obtain a higher score. Ask for missing business or deployment decisions.

## Phase 5: Verification gate

Run project tests and both audits again. Aim for 100/100 Grade A+ with no high or critical findings, but report any unresolved finding, exclusion, false positive, or verification limitation honestly rather than claiming success. Never equate a clean score with a complete security assessment.

```bash
npx -y @vibefoundry/vibe-shield scan --fail-on high
npx -y @vibefoundry/vibe-shield audit-skills --fail-on high
```

## Phase 6: Executive security sign-off

Produce a Markdown or HTML report with scope, inventory, risks prioritized by severity, evidence, actions, test results and remaining uncertainty. Illustrative code examples are not project-specific patches; review and adapt them. Obtain human approval before deployment or provider-side action.

```bash
npx -y @vibefoundry/vibe-shield scan --report SECURITY-REPORT.md --patch-prompt PATCH-PROMPT.md
npx -y @vibefoundry/vibe-shield audit-skills --report AGENT-REPORT.html
```
````

## File: README.md
upstream: https://github.com/avivgerz-hue/vibe-shield/blob/main/README.md

````text
# 🛡️ vibe-shield

**The security gate for AI-written code.** Find exposed secrets, unguarded routes and missing RLS before you ship.

> ⭐ **If this tool helps your AI coding workflow, please give this repository a Star!** It helps more developers discover the project.

[![npm version](https://img.shields.io/npm/v/@vibefoundry/vibe-shield.svg)](https://www.npmjs.com/package/@vibefoundry/vibe-shield)
[![npm downloads](https://img.shields.io/npm/dm/@vibefoundry/vibe-shield.svg)](https://www.npmjs.com/package/@vibefoundry/vibe-shield)
[![CI](https://img.shields.io/github/actions/workflow/status/avivgerz-hue/vibe-shield/ci.yml?branch=main&style=flat-square&logo=githubactions&label=CI)](https://github.com/avivgerz-hue/vibe-shield/actions/workflows/ci.yml)
[![node](https://img.shields.io/badge/node-%E2%89%A518.17.0-5fa04e?style=flat-square)](#-requirements)
[![license](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](./LICENSE)
[![zero dependencies](https://img.shields.io/badge/runtime%20deps-0-brightgreen?style=flat-square)](./package.json)
[![rules](https://img.shields.io/badge/detection%20signatures-92-8b5cf6?style=flat-square)](./src/scanner/rules)
[![self-scan](https://img.shields.io/badge/self--scan-100%2F100%20A%2B-16a34a?style=flat-square)](#-it-scans-itself)

![Live Terminal Demo](assets/demo.svg)

```bash
npx -y @vibefoundry/vibe-shield@latest scan .
```

<sub>Illustrative two-file scan; fixes are applied manually. Results vary by project. A clean score is not a security guarantee.</sub>

### VibeFoundry Agent Suite

- 🎨 **[unslop](https://github.com/avivgerz-hue/unslop)** — UI Design DNA &amp; Anti-Slop Engine · `npx -y unslop-mcp@latest init`
- 🛡️ **[vibe-shield](https://github.com/avivgerz-hue/vibe-shield)** — Security Scanner for AI Code · `npx -y @vibefoundry/vibe-shield@latest scan .`
- 👻 **[ghost-qa](https://github.com/avivgerz-hue/ghost-qa)** — Autonomous Headless Browser QA · `npx -y ghost-qa@latest test http://localhost:3000`

vibe-shield is a **static security scanner** plus an **Agent Skill** that helps Claude Code, Codex, Cursor and Windsurf audit before they say *“done”*.

---

## v2.0.0: eight defensive vectors

The v2 catalogue covers client exposure; auth and route protection; database/RLS; AI and web sinks; infrastructure; dependency hygiene; secrets and cryptography; and agent/MCP integrity. The new hardening checks include production source maps, insecure JWT settings, explicit and omitted cookie flags, locally absent security headers, container users, lifecycle scripts, lockfiles and weak cryptography. Run `rules` for the complete catalogue.

The scanner produces a heuristic **attack-surface inventory** of route methods, observed guard signals, SQL tables and RLS signals, AI entrypoints, and MCP/agent files. Header checks cover recognized server configuration files; cookie checks cover common literal setter options. Both are advisory: external middleware, deployment settings and dynamic options require review. Signals do not prove guards or policies work, and code outside the scanned scope is not assessed. Run `audit-skills` separately for agent-integrity checks.

Generate an executive report or agent remediation prompt explicitly:

```bash
npx -y @vibefoundry/vibe-shield scan --report SECURITY-REPORT.md --patch-prompt PATCH-PROMPT.md
npx -y @vibefoundry/vibe-shield scan --format html --out security-report.html
npx -y @vibefoundry/vibe-shield audit-skills --report agent-report.html
```

Reports include severity, CWE, locations, snippets, OWASP 2025 web mappings for every rule and contextual LLM mappings when applicable, and illustrative remediation. Examples are **not** automatic project-specific patches; validate them against the application. The scanner itself is offline and read-only by default; `--cache`, `--out`, `--report`, `--patch-prompt` and `init` explicitly write files. Installing with `npx` can require network access. An A+ score applies only to the rules and files examined and is not a security certification.

> The npm `2.0.0` artifact predates the universal `--agents` initializer. Use npm `2.1.0` or later (once published), or the GitHub `v2` ref. To exercise this checkout locally, run `npm ci && npm run build`, then `node dist/bin/vibe-shield.js` with the same arguments.

---

## The problem, in one file

This is the shape of code an agent writes when you ask for "a delete endpoint":

```ts
// app/api/users/route.ts
export async function DELETE(req: Request) {
  const { id, userId } = await req.json();
  await db.query(`DELETE FROM users WHERE id = ${id} AND owner = ${userId}`);
  return new Response('ok');
}
```

It works. It also has **three critical vulnerabilities** — no authentication, SQL injection, and an IDOR that lets the caller choose whose data they delete. Nothing in a normal review loop catches all three, and the agent reported the task as complete.

`npx -y @vibefoundry/vibe-shield scan` catches all three in **17 milliseconds**:

```
🛡️  vibe-shield · security scan (illustrative output for current source)
target  /home/you/app

💀 GRADE F — 0/100 · 3 critical

  CRITICAL 3    ███

Findings

app/api/users/route.ts
  CRITICAL 2:1      VSB-AUTH-001  Next.js App Router mutation handler has no authentication check
           export async function DELETE(req: Request) {
  CRITICAL 4:22     VSB-DB-007    SQL statement built by concatenating request data
           await db.query(`DELETE FROM users WHERE id = ${id} AND owner = ${userId}`);
  CRITICAL 4:22     VSB-AUTH-004  Record ownership taken from the request instead of the session (IDOR)

  7 files  ·  1 KiB  ·  412 files/s  ·  17 ms  ·  80 rules

  ⚠  3 critical findings — rotate any exposed credential before anything else.
  Fix it      npx -y @vibefoundry/vibe-shield scan --fix-prompt    # writes SECURITY_PATCH_PROMPT.md for your agent
  Explain     npx -y @vibefoundry/vibe-shield explain VSB-AUTH-001
  Gate CI     npx -y @vibefoundry/vibe-shield scan --fail-on critical --format github
```

Then hand the fix list to the agent that wrote the bug:

```bash
npx -y @vibefoundry/vibe-shield scan --fix-prompt   # → SECURITY_PATCH_PROMPT.md
```

That file contains, for every finding: the severity, the CWE id and link, the exact `file:line`, the vulnerable snippet, the ordered remediation steps, the target code shape, and a verification command. It is written for a machine to execute and a human to audit.

---

## ⚡ Quick start

```bash
# 1. Scan (npx may download the package; the scanner itself is offline)
npx -y @vibefoundry/vibe-shield scan

# 2. Give your agent the fix list
npx -y @vibefoundry/vibe-shield scan --fix-prompt

# 3. Install the gate permanently — skill + CI + ignore file
npx -y github:avivgerz-hue/vibe-shield#v2 init --agents all
```

> **Use the scoped name.** vibe-shield is published as
> [`@vibefoundry/vibe-shield`](https://www.npmjs.com/package/@vibefoundry/vibe-shield).
> The *unscoped* name `vibe-shield` on npm belongs to an unrelated project, so
> `npx vibe-shield` runs someone else's code. Always include the `@vibefoundry/`
> scope. The package ships a prebuilt `dist/`, needs **no TypeScript**, and
> starts in milliseconds.

## Supported Coding Agents (1-Command Setup)

Run this from the repository you want to protect (Node.js and Git required):

```bash
npx -y github:avivgerz-hue/vibe-shield#v2 init --agents all
```

To configure selected agents, substitute a comma-separated list such as `--agents claude,cursor,zed`:

| Agent | Selector | Native integration |
| --- | --- | --- |
| Claude Code | `claude` | `.mcp.json`, `CLAUDE.md`, `.claude/skills/vibe-shield/SKILL.md`, `.claude-plugin/plugin.json` |
| OpenCode | `opencode` | `opencode.json` MCP and `AGENTS.md` |
| OpenAI Codex CLI / universal agents | `codex` | `AGENTS.md` and `.agents/skills/vibe-shield/SKILL.md` |
| Cursor | `cursor` | `.cursor/mcp.json` and `.cursor/rules/vibe-shield.mdc` |
| Windsurf | `windsurf` | `.windsurfrules` |
| VS Code / GitHub Copilot
````
