Repository avatar
AI Tools
v2.1.2
active

vibe-shield

io.github.avivgerz-hue/vibe-shield

Scans AI-written code for leaked secrets, unguarded routes and missing RLS.

Documentation

πŸ›‘οΈ 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 npm downloads CI node license zero dependencies rules self-scan

Live Terminal Demo

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

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

VibeFoundry Agent Suite

  • 🎨 unslop β€” UI Design DNA & Anti-Slop Engine Β· npx -y unslop-mcp@latest init
  • πŸ›‘οΈ vibe-shield β€” Security Scanner for AI Code Β· npx -y @vibefoundry/vibe-shield@latest scan .
  • πŸ‘» 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:

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":

// 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:

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

# 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. 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):

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:

AgentSelectorNative integration
Claude Codeclaude.mcp.json, CLAUDE.md, .claude/skills/vibe-shield/SKILL.md, .claude-plugin/plugin.json
OpenCodeopencodeopencode.json MCP and AGENTS.md
OpenAI Codex CLI / universal agentscodexAGENTS.md and .agents/skills/vibe-shield/SKILL.md
Cursorcursor.cursor/mcp.json and .cursor/rules/vibe-shield.mdc
Windsurfwindsurf.windsurfrules
VS Code / GitHub Copilotcopilot.vscode/mcp.json and .github/copilot-instructions.md
Cline / Roo Codecline or roo.clinerules
Zedzed.zed/settings.json context server

The existing --agent claude|cursor|generic|all remains supported. The shared .mcp.json, ignore file, and (unless --no-workflow is set) CI workflow are also installed. JSON configuration is merged by server name; malformed JSON or JSON with comments is left untouched and reported. Existing instructions are appended only once, and existing files are not overwritten without --force. Restart the relevant editor or reload its configuration after setup.

🧠 Why AI code needs its own scanner

Traditional SAST rules are built around human mistakes: a forgotten escape, a missing prepare(). Agent-written code fails differently β€” it is confidently complete and structurally plausible:

What a human doesWhat an agent does
forgets to validate one inputwrites a perfect endpoint with no auth at all
uses eval in one legacy fileputs a tool execute that shells out behind an LLM
commits a .env by accidentputs SUPABASE_SERVICE_ROLE_KEY behind NEXT_PUBLIC_ because "it needed the env var"
writes CREATE TABLEwrites CREATE TABLE and forgets the ENABLE ROW LEVEL SECURITY, so the anon key reads everything
adds dangerouslySetInnerHTML to render a docrenders model output with it, creating stored XSS with a step counter

vibe-shield encodes those specific shapes: 92 signatures across eight defensive categories, each one derived from a real agent-generated bug rather than a generic CWE checklist.


πŸ“Š Vulnerability Coverage Matrix

Client-boundary limitation: Client reachability is a best-effort static graph of literal imports, re-exports and require calls using relative paths and root tsconfig.json/jsconfig.json aliases. Dynamic paths, inherited or nested configurations, excluded or oversized files and other bundler resolution may be missed. A server-side service-role helper still bypasses RLS: use import 'server-only', authorize every privileged request, and verify the production bundle. Auth-helper names and with* wrappers are signals, not proof that authorization is enforced.

80 code signatures + 12 agent-integrity signatures = 92. The scan command runs the 80 code rules; audit-skills runs the 12 agent rules. Every rule has an id, a CWE, an illustrative vulnerable shape, remediation guidance, and an OWASP association β€” run npx -y @vibefoundry/vibe-shield rules or npx -y @vibefoundry/vibe-shield explain <ID>.

Client-side secret & data exposure β€” VSB-CLIENT-*

IDDetectsCWESev
VSB-CLIENT-001NEXT_PUBLIC_ / VITE_ / PUBLIC_ / REACT_APP_ + a server-only secret name (SERVICE_ROLE_KEY, OPENAI_API_KEY, STRIPE_SECRET_KEY, DATABASE_URL…)CWE-200critical
VSB-CLIENT-002server-only process.env.*SECRET* read inside a "use client" moduleCWE-200high
VSB-CLIENT-003createClient(url, SERVICE_ROLE_KEY) β€” RLS bypass in a client-reachable file or public envCWE-250critical
VSB-CLIENT-004supabaseAdmin / adminClient / serviceRoleClient referenced from browser codeCWE-250critical
VSB-CLIENT-005dangerouslyAllowBrowser: true, provider SDK keyed in the browserCWE-749high
VSB-CLIENT-006.env* assigns a live-looking credential to a public variableCWE-540critical
VSB-CLIENT-007next.config.js env / publicRuntimeConfig / Vite define inlining a secretCWE-798critical

Unguarded mutation routes β€” VSB-AUTH-*

IDDetectsCWESev
VSB-AUTH-001App Router POST/PUT/PATCH/DELETE handler with no session checkCWE-306critical
VSB-AUTH-002Pages API mutation handler with no session checkCWE-306critical
VSB-AUTH-003Express / Fastify / Koa / Hono mutation route with no auth middlewareCWE-862high
VSB-AUTH-004IDOR β€” ownership key from body/query/params (including the destructured local variable)CWE-639critical
VSB-AUTH-005"use server" action mutating data with no authCWE-306high
VSB-AUTH-006identity from jwt.decode, x-user-id, atob(token.split('.')[1]), verify:false, algorithms:['none']CWE-347critical
VSB-AUTH-007admin/destructive surface that authenticates but never checks a roleCWE-863high
VSB-AUTH-008const session = await auth() captured and never enforcedCWE-287medium
VSB-AUTH-009cookie-session mutation with no CSRF token protectionCWE-352medium

Database exposure β€” VSB-DB-*

IDDetectsCWESev
VSB-DB-001CREATE TABLE with no ENABLE ROW LEVEL SECURITY anywhere in the project (cross-file index)CWE-284critical*/high
VSB-DB-002permissive policy β€” USING (true), WITH CHECK (true), USING (1=1)CWE-732critical
VSB-DB-003anon/authenticated policy whose USING never references auth.uid()/auth.jwt()CWE-639high
VSB-DB-004GRANT … TO anon/public (writes), incl. GRANT ALLCWE-732critical/high
VSB-DB-005DISABLE ROW LEVEL SECURITY, DROP POLICY, BYPASSRLSCWE-284critical/high
VSB-DB-006$queryRawUnsafe, $executeRawUnsafe, knex.raw, sequelize.query, .raw() with a dynamic stringCWE-89critical
VSB-DB-007hand-built SQL from request data β€” ${}, +, Python f-strings, PHP interpolationCWE-89critical
VSB-DB-008Supabase service-role key observed in client-reachable code or public envCWE-250critical
VSB-DB-009createBucket(…, { public: true })CWE-732medium
VSB-DB-010request data used as a table, column or ORDER BY identifierCWE-89high

* critical when Supabase/PostgREST is detected β€” the anon key in every browser makes the table publicly addressable.

AI / LLM & classic web β€” VSB-AI-*

IDDetectsCWESev
VSB-AI-001exec/execSync/spawn({shell:true})/Bun.spawn/os.system/subprocess(shell=True)/Runtime.exec/PHP backticksCWE-78critical
VSB-AI-002LLM/MCP tool execute reaching a shell, eval or filesystem sinkCWE-94critical
VSB-AI-003model output into eval/new Function/vm.runInNewContextCWE-94critical
VSB-AI-004untrusted/RAG content interpolated into a system prompt, no delimiters (OWASP LLM01)CWE-74high
VSB-AI-005Stripe webhook without stripe.webhooks.constructEventCWE-345critical
VSB-AI-006webhook signing secret read from the requestCWE-345high
VSB-AI-007GitHub/Slack/Shopify/Svix webhook with no signature verificationCWE-345high
VSB-AI-008dangerouslySetInnerHTML, v-html, {@html}, innerHTML, document.write, jQuery .html()CWE-79high
VSB-AI-009client eval/new Function/string setTimeout/javascript: URLsCWE-94high
VSB-AI-010open redirect β€” redirect(searchParams.get('next'))CWE-601medium
VSB-AI-011SSRF β€” fetch(req.body.url)CWE-918high
VSB-AI-012path traversal β€” path.join(dir, req.params.name)CWE-22high
VSB-AI-013multer/formData() upload with no size or type limitCWE-434medium
VSB-AI-014public LLM endpoint with no rate limit or quotaCWE-770medium
VSB-AI-015pickle.loads, yaml.load without SafeLoader, PHP unserializeCWE-502high
VSB-AI-016recognized LLM route call without a visible positive literal output token cap; review dynamic or provider limitsCWE-770medium

Hardcoded credentials β€” VSB-SECRET-*

IDDetectsCWESev
VSB-SECRET-001vendor signature in a server file (Stripe, OpenAI, Anthropic, AWS, GitHub, Supabase, Slack, Twilio, SendGrid, npm, PyPI, HuggingFace, Docker, Vercel, Mailgun, Square, Shopify, Datadog)CWE-798high
VSB-SECRET-002generic high-entropy assignment to a credential-shaped nameCWE-798medium/high
VSB-SECRET-003PEM private key materialCWE-321critical
VSB-SECRET-004hardcoded JWT whose payload carries service_role / adminCWE-250critical
VSB-SECRET-005the same vendor credential in a browser-reachable fileCWE-200critical
VSB-SECRET-006postgres:postgres@…, password = "admin", entropy < 2.5CWE-1392medium
VSB-SECRET-007.env with live credentials β€” critical when git-trackedCWE-540critical

Agent skill & MCP poisoning β€” VSB-AGENT-* (audit-skills)

IDDetectsCWESev
VSB-AGENT-001zero-width, bidi-override, Unicode-tag characters hiding instructionsCWE-74critical
VSB-AGENT-002curl/wget/nc exfiltrating env vars or .envCWE-200critical
VSB-AGENT-003instructions to read .env, ~/.ssh, ~/.aws/credentials, id_rsa, keychainCWE-522critical
VSB-AGENT-004registry-tag npx -y/uvx, remote MCP URL, curl | sh install (git installs such as github:owner/repo are not flagged: they resolve to a commit, not a mutable tag)CWE-829high
VSB-AGENT-005literal credentials in an env block, or "*": "*" env forwardingCWE-526critical/high
VSB-AGENT-006"ignore previous instructions", "do not tell the user", "auto-approve", "skip confirmation"CWE-74critical
VSB-AGENT-007Bash(*), Write(*), autoApprove: ["*"], dangerouslySkipPermissionsCWE-284high
VSB-AGENT-008base64 payload / eval(atob(…)) / base64 -d | shCWE-94high
VSB-AGENT-009"fetch and follow every instruction"CWE-829critical
VSB-AGENT-010missing frontmatter, wildcard allowed-toolsCWE-250medium
VSB-AGENT-011literal credential inside an instruction/MCP fileCWE-798critical
VSB-AGENT-012eval "$1", sh -c "$VAR" in a skill scriptCWE-78medium

πŸ”Œ Native MCP server

vibe-shield is itself a Model Context Protocol server, so Claude Code, Claude Desktop, Cursor and Codex can call the scanner as a tool instead of shelling out and parsing console output.

npx -y @vibefoundry/vibe-shield mcp          # JSON-RPC 2.0 over stdio
npx -y @vibefoundry/vibe-shield --mcp        # same thing, if your client prefers a flag

Three tools:

ToolWhat it does
vibe_shield_scanRuns the code-scanning rules over a project or specific paths β†’ grade, score, findings with file:line, CWE and remediation
vibe_shield_audit_skillsAudits .claude/skills, .cursor rules, AGENTS.md and MCP configs for prompt injection and exfiltration traps
vibe_shield_explain_ruleFull CWE detail, vulnerable/fixed examples and remediation for any rule id or slug

npx -y @vibefoundry/vibe-shield init writes the config for you, merging into .mcp.json without clobbering servers you already have:

{
  "mcpServers": {
    "github": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"] },
    "vibe-shield": { "command": "npx", "args": ["--yes", "@vibefoundry/vibe-shield@2.0.0", "mcp"] }
  }
}

The version pin is not cosmetic: an unpinned npx -y server is exactly what VSB-AGENT-004 flags as high severity, so vibe-shield's own audit would write itself a finding. init pins the running version automatically.

Or add it by hand:

claude mcp add vibe-shield -- npx -y @vibefoundry/vibe-shield mcp

The server is zero-dependency, writes only JSON-RPC to stdout, honours JSON-RPC notifications (no spurious replies), and returns tool errors as isError results so a bad argument degrades one call instead of killing the session. Requests are handled in arrival order.

An empty target is reported as No files were scanned rather than a green pass β€” a scanner that says "clean" when it read nothing is worse than no scanner.


πŸ€– Use it as an Agent Skill

npx -y github:avivgerz-hue/vibe-shield#v2 init --agents all installs the skill. Once it is in a repository, every agent session starts with a contract:

You are not allowed to say "done" until the code you just wrote passes a security audit.

npx -y github:avivgerz-hue/vibe-shield#v2 init --agents all
npx -y github:avivgerz-hue/vibe-shield#v2 init --agents claude
npx -y github:avivgerz-hue/vibe-shield#v2 init --agents cursor,zed --no-workflow

Why this works better than a prompt snippet: it names the three commands, gives the agent a reading guide for a finding (line:col, rule id, message, CWE), states five hard rules (never suppress, never weaken, always rotate, report honestly, re-verify), and defines "done" as an exit code rather than an opinion.

The skill itself is SKILL.md β€” read it, it is short.

Anthropic Agent Skills quickstart

# install the Claude Code skill
npx -y @vibefoundry/vibe-shield init --agent claude
# β†’ .claude/skills/vibe-shield/SKILL.md

# or globally, for every project
curl -sL https://raw.githubusercontent.com/avivgerz-hue/vibe-shield/main/SKILL.md \
  -o ~/.claude/skills/vibe-shield/SKILL.md

πŸ” CI/CD: fail the PR before the bug ships

GitHub Actions (recommended)

npx -y @vibefoundry/vibe-shield init installs a workflow that runs the scan, uploads SARIF to code scanning, audits the agent surface, and fails the job:

name: vibe-shield
on: [push, pull_request]

permissions:
  contents: read
  security-events: write

jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20

      - name: Scan and upload SARIF
        run: npx -y @vibefoundry/vibe-shield scan --format sarif --out vibe-shield.sarif --fail-on high
        continue-on-error: true

      - uses: github/codeql-action/upload-sarif@v3
        if: always()
        with:
          sarif_file: vibe-shield.sarif
          category: vibe-shield

      - name: Enforce the gate
        run: npx -y @vibefoundry/vibe-shield scan --fail-on high

Findings appear inline on the pull request diff (GitHub annotations) and in the Security β†’ Code scanning tab (SARIF), so a reviewer sees the vulnerability on the line that introduced it.

Any other CI

npx -y @vibefoundry/vibe-shield scan --fail-on high                         # exit 1 on findings
npx -y @vibefoundry/vibe-shield scan --format compact                       # one line per finding
npx -y @vibefoundry/vibe-shield scan --format json > vibe-shield.json       # full report
npx -y @vibefoundry/vibe-shield scan --format summary                       # JSON, counts + grade only
npx -y @vibefoundry/vibe-shield scan --format github                        # workflow annotations

Exit codes: 0 clean Β· 1 findings at/above --fail-on Β· 2 usage error (a target path that does not exist, or a target that matches no scannable files). An empty scan prints NO FILES SCANNED β€” this is not a pass and is never reported as a grade β€” a gate pointed at an ignored path fails instead of succeeding forever.


🎯 The scorecard

Grades are deliberately unforgiving, because "B+" for a leaked production key is how security tools lose credibility:

Finding presentMaximum scoreBest possible grade
any critical29F
any high58C
any medium76B
any low88A-
nothing100A+

Penalties per finding: critical βˆ’30, high βˆ’12, medium βˆ’5, low βˆ’2, info βˆ’0.5. One leaked live key fails the build on its own; a handful of informational notes never will.


πŸͺ„ It scans itself

This repository runs its own gate on every commit and in CI:

$ npx -y @vibefoundry/vibe-shield scan
πŸ›‘οΈ  vibe-shield Β· security scan (illustrative output for current source)
target  /you/vibe-shield

πŸ† GRADE A+ β€” 100/100

  21 files  Β·  172 KiB  Β·  236 files/s  Β·  89 ms  Β·  80 rules

  Nothing to fix. Keep the shield up. πŸ›‘οΈ

$ npx -y @vibefoundry/vibe-shield audit-skills
πŸ† GRADE A+ β€” 100/100

  1 file  Β·  6 KiB  Β·  14 files/s  Β·  69 ms  Β·  12 rules

  Nothing to fix. Keep the shield up. πŸ›‘οΈ

The detector catalogue is the one place that must contain the exact vulnerable shapes and vendor key formats the rules match on β€” exactly like gitleaks and semgrep. Those files are listed explicitly in .vibe-shieldignore with a comment explaining why, instead of weakening a rule.


πŸ”‡ Suppressing a finding (legitimately)

Inline, with a rule id and a reason β€” the reason is required by review culture even though the parser does not enforce it:

// vibe-shield-disable-next-line VSB-AI-001 -- path comes from a closed enum
exec(`convert ${KNOWN_FORMATS[format]} out.png`);
// vibe-shield-disable-line VSB-AUTH-008
// vibe-shield-disable VSB-AI-014
// vibe-shield-enable
// vibe-shield-disable-file VSB-DB-004 -- generated edge schema

Suppressed findings are counted and reported in the scorecard, never silently dropped. Whole-path exclusions belong in .vibe-shieldignore (gitignore syntax) and should be reserved for generated code.


βš™οΈ How it works

 discover ──▢ project context ──▢ rule gate ──▢ detect ──▢ suppress ──▢ score ──▢ report
   β”‚              β”‚                  β”‚           β”‚
   β”‚              β”‚                  β”‚           └─ 80 code rules; 12 agent-integrity rules run in audit-skills
   β”‚              β”‚                  └─ cheap content hints: most rules skip most files
   β”‚              └─ manifests, framework flags, cross-file RLS index, git index, middleware matchers
   └─ one tree walk, gitignore/.vibe-shieldignore layering, binary + size + test/doc pruning

Design constraints, in priority order:

  1. Fast. One readdir walk, one read per file, one comment-masking pass, and a cheap gate before any rule body runs. A 400-file project scans in ~200 ms; a typical Next.js app in under 100 ms. No AST, no parser, no dependency.
  2. Honest. Every finding carries the exact snippet the developer wrote. Configuration checks may infer risk from file shape, and every suppression is counted, not hidden.
  3. Composable. scanProject() for the CLI, runRulesOnFile() for the auditor, scoreFindings() for anything that produces findings. The whole API is exported from vibe-shield.

Zero runtime dependencies. No network calls, no telemetry, no language server, no native binaries. The scanner works offline once installed; a first-time npx install needs registry access.


πŸ“– CLI reference

vibe-shield scan [paths...]         Scan the project (default: `.`)
vibe-shield audit-skills [paths...] Audit agent skills, rules, AGENTS.md and MCP config
vibe-shield init                    Install the Agent Skill, AGENTS.md, .mcp.json and CI gate
vibe-shield mcp                     Serve the MCP tools over stdio
vibe-shield rules                   List every detection rule
vibe-shield explain <RULE_ID>       Full documentation for one rule
vibe-shield version | help
FlagDefaultMeaning
--format <fmt>consoleconsole compact summary json sarif github markdown html
--fail-on <sev>criticalExit 1 at/above this severity
--severity <sev>β€”Only report at/above this severity
--fix-promptoffWrite SECURITY_PATCH_PROMPT.md
--out <file>β€”Write the report to a file
--rules <ids>allComma-separated ids/slugs, supports VSB-DB-*
--ignore <glob>β€”Extra ignore pattern (repeatable)
--include-testsoffInclude test/fixture files
--include-docsoffInclude Markdown and docs/
--cacheoffReuse .vibe-shield-cache.json
--max-findings <n>50Console list cap (0 = all)
--quietoffOne-line verdict (100/100 A+ β€” 0 critical, …)
--no-colorautoDisable ANSI (also honours NO_COLOR)
--jsonoffShorthand for --format json
--no-gitignoreoffIgnore .gitignore while discovering files
--no-shield-ignoreoffIgnore .vibe-shieldignore (e.g. to scan excluded fixtures)

init takes --target <dir>, --agent claude / cursor / generic / all, --no-workflow, --force and --yes.


🧩 Programmatic API

import { scanProject, formatSarif, buildPatchPrompt, auditSkills } from 'vibe-shield';

const result = await scanProject({ rootDir: process.cwd(), cache: true });

console.log(result.score.score, result.score.grade);  // 0 'F'
console.log(result.findings[0].ruleId);               // 'VSB-AUTH-001'
console.log(result.findings[0].cwe.id);               // 'CWE-306'

process.stdout.write(formatSarif(result));            // SARIF 2.1.0
process.stdout.write(buildPatchPrompt(result));       // agent-ready fix list

const agentReport = await auditSkills(process.cwd()); // VSB-AGENT-* surface

❓ FAQ

Does it replace a real SAST tool? No. It replaces the absence of one. vibe-shield is a fast, zero-dependency gate you can put in front of every agent-written commit today. Pair it with a deeper scanner (CodeQL, Semgrep) if you have one; the rules overlap far less than you would expect, because these are agent-specific shapes.

Will it flag my secure code? The secure fixture (tests/fixtures/secure/) is a real Next.js + Supabase + Stripe app with auth, RLS, sanitisation, rate limiting and webhook verification β€” it scores 100/100 and the suite asserts zero findings on it. Each rule has guard clauses for the legitimate patterns: import "server-only" suppresses the service-role rules, Prisma tagged templates suppress the SQLi rule, DOMPurify suppresses the XSS rule, auth.uid() policies suppress the RLS rules.

Does it send my code anywhere? No. There is no network code in the runtime at all β€” the package has zero dependencies and makes no outbound requests.

Why not an AST? Because a 1.5 MB minified bundle, a Vue SFC, a PHP legacy file and a SQL migration all need to be scanned with the same tool, and a parser handles exactly one of those. The rules use structural brace matching plus a comment-masker that preserves offsets, which is enough for the shapes that matter and roughly two orders of magnitude faster.

Why "vibe"? Because the code was written by vibe and reviewed by nobody. This is the reviewer.


πŸ›  Development

git clone https://github.com/avivgerz-hue/vibe-shield
cd vibe-shield
npm ci
npm run typecheck   # tsc --noEmit (strict, noUnusedLocals)
npm test            # 224 Vitest tests
npm run build       # tsc + postbuild (shebang, chmod, CJS marker)
npm run verify      # typecheck + test + build + self-scan + self-audit

See CONTRIBUTING.md for the rule-authoring guide, and SECURITY.md for the threat model and disclosure policy.


πŸ“‹ Requirements

  • Node.js β‰₯ 18.17 (uses node: builtins only β€” no polyfills, no native modules)
  • Any OS: Linux, macOS, Windows
  • No config file required; package.json is optional

πŸ“„ License

MIT Β© VibeFoundry β€” use it, fork it, ship it.


Part of the VibeFoundry Agent Suite

Three tools for the same problem: agents move fast, and something has to keep the output honest.

ToolWhat it does
🎨unslopStudio-grade UI design systems & Anti-Slop engine β€” stops agents from generating generic, interchangeable interfaces
πŸ›‘οΈvibe-shieldSecurity scanner & MCP guard β€” stops agents from shipping leaked keys, unguarded routes and disabled RLS
πŸ‘»ghost-qaAutonomous headless-browser QA & self-healing verification loop β€” stops agents from claiming a UI works when it does not
npx -y @vibefoundry/vibe-shield init   # security gate