Vibe Check Your Vibe-Coded Repo Before It Bites

You shipped a weekend project with an AI pair — a dashboard, a scraper, a little SaaS. It works. Then your phone buzzes: someone found an admin route that answers to anyone with a browser. That is the moment every vibe-coded repo eventually reaches, and the only question is whether it happens before or after someone else finds it.

This is a stage-by-stage walkthrough of a Vibe Check you can run on a Node project: a small script that greps your repo for the patterns that tend to survive AI-assisted coding sessions — secrets in files, missing auth on routes, permissive CORS, debug flags left on, raw SQL built from strings. Each stage answers two things: what to look for, and how to tell the check is actually done.

Stage 1: Decide what "scary" means for your repo

Before you write a line of the script, you need a target list. A vibe-coded repo rarely fails in exotic ways. It fails in the same handful of spots, because the model does not know your threat model — it knows the pattern that compiled. More on the topic: “Advances in Vibe Coding: who the latest research and tools are actually for — and who should skip them”.

A workable first list for almost any Node app:

  • Secrets committed to disk — API keys, tokens, connection strings in .env files that got tracked, or hardcoded in a config module.
  • Routes without an auth check — especially anything under /admin, /internal, /api/private.
  • Wildcard CORS — origin: '*' on an API that also sends credentials.
  • Debug leftovers — console.log of tokens, debug: true, stack traces returned in responses.
  • String-built SQL — template literals glued into a query instead of parameterised calls.

Write this list down. It becomes your rule set, and the rule set is the whole value of the check — the script is just plumbing around it.

Start from your exposure, not from a checklist online If your app handles no money and no personal data, a leaked read-only token is a nuisance; if it holds session cookies, the same token is a breach. Rank the rules by what a hit would actually cost you.

Stage 2: Build the scanner as a single Node file

You do not need a dependency tree for this. Node's built-in fs and a regex per rule is enough, and keeping it dependency-free means the check itself never becomes the thing that breaks.

A minimal, working shape:

import { readdirSync, readFileSync, statSync } from 'node:fs';
import { join, extname } from 'node:path';

const SKIP = new Set(['node_modules', '.git', 'dist', 'build', 'coverage']);
const EXT = new Set(['.js', '.mjs', '.cjs', '.ts', '.json', '.env', '.yml', '.yaml']);

const RULES = [
  { id: 'secret', re: /(api[_-]?key|secret|token)\s*[:=]\s*['"][A-Za-z0-9_\-]{16,}['"]/i, why: 'hardcoded credential' },
  { id: 'cors', re: /origin\s*:\s*['"]\*['"]/, why: 'wildcard CORS' },
  { id: 'debug', re: /debug\s*:\s*true|NODE_ENV\s*!==\s*['"]production['"]/, why: 'debug left on' },
  { id: 'sql', re: /(query|execute)\s*\(\s*`[^`]*\$\{/, why: 'SQL built from a template literal' },
];

function walk(dir, out = []) {
  for (const name of readdirSync(dir)) {
    if (SKIP.has(name)) continue;
    const p = join(dir, name);
    if (statSync(p).isDirectory()) walk(p, out);
    else if (EXT.has(extname(p)) || name.startsWith('.env')) out.push(p);
  }
  return out;
}

let hits = 0;
for (const file of walk('.')) {
  const lines = readFileSync(file, 'utf8').split('\n');
  lines.forEach((line, i) => {
    for (const r of RULES) {
      if (r.re.test(line)) {
        hits++;
        console.log(`${file}:${i + 1}  [${r.id}] ${r.why}\n    ${line.trim().slice(0, 120)}`);
      }
    }
  });
}
console.log(hits ? `\n${hits} finding(s).` : '\nClean.');
process.exit(hits ? 1 : 0);

Two details matter more than they look. process.exit(1) on a hit turns the script into a gate you can wire into a pre-commit hook or CI step later. And the SKIP set keeps the run under a second on a normal project — a check that takes ten seconds is a check nobody runs.

Done when: running node vibe-check.mjs on a known-bad test file prints the line and the reason, and exits non-zero. More on the topic: “Advances in Vibe Coding: What Latest Research and Tools Actually Change in AI-Driven Development”.

Stage 3: Read the noise honestly — regexes lie in both directions

Here is where most people stop trusting the tool. Run the scanner on a real repo and you will get hits that are not problems: a test fixture with a fake key, a console.log in a CLI script where stdout is the interface, a template literal that builds a message, not a query.

That noise is not a bug in the script — it is the reason a vibe check is a triage tool, not a verdict. The rule that keeps it useful: every hit gets one of three labels, and you write the label down. More on the topic: “Vibe Coding: Learn to Create Code with AI — Without Programming Skills”.

Hit Label Action
Real key in config.js True positive Rotate the key, move to env, purge from git history
Fake key in test/fixtures Accepted Add the path to an allowlist
console.log in a CLI Accepted Allowlist the file
${userId} inside db.query True positive Convert to a parameterised query
Wildcard CORS on a public read-only endpoint Needs a decision Keep it, but document why

The allowlist is the part people skip, and it is the part that decides whether the check survives month two. A flat file of paths, checked in the same script, takes ten minutes to add:

const ALLOW = new Set(['test/fixtures/fake-key.js', 'scripts/cli.mjs']);
// inside the loop: if (ALLOW.has(file)) continue;
A finding you have not labelled is a finding you will ignore next time The scan is only as good as the triage after it. If a hit stays unlabelled, the next run shows the same line, and by the third run you scroll past all of them — including the one that matters.

Done when: every hit from the first full run has a label, and the allowlist contains only paths you have consciously accepted.

Stage 4: Go past grep — the things a regex cannot see

The scanner catches patterns in text. It cannot see a route that exists but has no middleware, because the absence of a line is not a line. That is the most common real hole in AI-assisted code: the model adds app.get('/api/admin/users', handler) and simply never adds the guard, because nobody asked it to.

For this stage you list your routes and check each one by eye — it is fast, because a small app has maybe twenty. Look for:

  1. Routes with no auth middleware in the chain, especially anything returning more than the current user's own data.
  2. Auth checked in the handler body but not before the database call — an early return after the query is too late.
  3. Trust in client-supplied fields — req.body.role, req.body.isAdmin, req.query.userId used to decide what to return.
  4. File paths from user input passed straight to readFile or sendFile.

A quick way to make this visible: print a route table at boot and mark which ones have a guard. If you use Express, walking app._router.stack gives you the registered layers; the exact internals shift between versions, so treat the printed table as a prompt for review rather than an authoritative audit.

This is also the stage where a second pair of eyes — human or otherwise — earns its keep. An agent that can read the whole repo and cross-check a diff against your rules catches the missing-middleware case that grep structurally cannot. ASI Biont supports connecting to GitHub via API — learn more at asibiont.com

Done when: you can point at every route in the table and say who is allowed to call it.

Stage 5: Turn the one-off run into a habit

The first run is a cleanup. The value is in the second, fifth and twentieth run — on the diff, not the whole repo.

Three cheap moves, in order of effort:

  • Pre-commit hook. Run the script on staged files only. A hit blocks the commit, which is exactly the moment the secret is still easy to remove.
  • CI step. The same exit code fails the build. This catches the case where someone commits with --no-verify.
  • A short note in the repo. One paragraph in the README saying what the check covers and what it deliberately does not. Future-you will not remember why the wildcard CORS was accepted.
Each stage narrows what is left to review by hand
1
Rule list
decide what counts as scary
2
Scanner
one Node file, no dependencies
3
Triage
label every hit, build an allowlist
4
Route review
catch the missing middleware grep cannot see
5
Habit
pre-commit hook and CI gate

One caution about secrets specifically: deleting the line is not enough. If a key was ever committed, it lives in git history, and anyone who cloned the repo has it. The fix is to rotate the key first, then clean history — in that order, because cleanup without rotation leaves a live credential in old clones.

What the check will never tell you

A vibe check finds the scary stuff that is written down. It will not find the logic bug that lets a user read someone else's invoice through a perfectly guarded endpoint — that is an authorisation flaw inside a correct-looking handler, and no regex sees it. It will not find a dependency with a known vulnerability; that is a different tool and a different job.

So treat the script as the first ten minutes of a review, not the review. The ten minutes it buys you are the ones where the obvious things get caught — and obvious things are, in practice, most of what ships broken in a fast AI-assisted build.

Run it today on the project you are proudest of. If it comes back clean, you have earned the right to be proud; if it does not, you found it before someone else did, which is the whole point of checking your vibe before it checks you.

← All posts

Ask AI about this article

Ask a question about this article — ASI Biont will answer based on its text.