6 min read

Vibe Coding to Production: A Practical Playbook for Shipping AI-Written Code Safely

Vibe coding is great for prototypes, but production needs guardrails. Here's the 10-step process I follow (specs, tests, CI, reviews, gradual rollout, monitoring) and the checklist I run before every merge.

Vibe Coding

"Vibe coding" started as a half-joke. You describe what you want, the AI writes it, you accept the diff and keep going on feel. For a Saturday afternoon prototype, it works surprisingly well. For a payment service, not so much.

The distance between the two is smaller than people think, though. Plenty of teams already ship AI-generated code to production. The ones who do it without drama didn't stop vibe coding; they put a few guardrails around it. This is the setup I use to keep the speed while still being able to sleep when I'm on call.

The idea in one sentence

The AI is good at writing code quickly. It's not the one who gets the phone call when it breaks. So:

Let the AI go fast inside a box. You build the box, and you own it.

The box is specs, tests, CI, code review and monitoring. Nothing new here, it's the same engineering discipline we've always (sort of) practiced. What changes is that when the AI writes most of the code, these things stop being optional. They're what stands between your users and a bug that looks perfectly sure of itself.

pipeline

Step 1: Write down what you want before you prompt

Before I open the chat, I write a short SPEC.md (or a ticket) with:

  • What the feature does, in plain words
  • Acceptance criteria: concrete statements you can test
  • Constraints: stack, allowed libraries, performance budget, data that must never leave a given boundary
  • Out of scope: what the AI should leave alone

Then I give it to the agent as context. A vague prompt gets you code that looks right. A clear spec gets you code that is right, or at least a lot closer. It's also what the reviewer will check against later.

Step 2: Give the AI your project's rules

Most coding agents read a project-level instructions file (CLAUDE.md, AGENTS.md, .cursorrules, etc.). Put in it:

  • Architecture conventions (where things go, naming, layers)
  • The commands to build, lint and test
  • What's forbidden (concatenated SQL strings, any types, disabling lint rules, adding dependencies without asking)
  • Security expectations (validate input, use the existing auth middleware, never log secrets)

All the stuff that usually lives in people's heads ends up written somewhere the AI actually reads. Bonus: the whole team gets more consistent output.

Step 3: Keep the slices small

The classic vibe coding disaster is the 2,000-line diff that nobody really reads. What works better:

  1. Ask for a plan first, and read it before any code gets written.
  2. Build one slice at a time: the migration, then the service, then the endpoint, then the UI.
  3. Commit every time a slice is green, so going back is cheap when the AI wanders off.

My rule of thumb: if I can't explain a diff in two sentences, it's too big.

Step 4: Let the tests decide

Tests are how you check code you didn't write yourself.

  • Write or approve the tests first. Have the AI generate cases from the acceptance criteria, read them, and only then let it implement until they pass.
  • Watch for tampered tests. Agents love to "fix" a failing test by loosening the assertion. Any change to an existing test deserves a human look.
  • Cover the cases the AI tends to forget: empty inputs, nulls, timezones, concurrency, permissions, big payloads.
  • Keep integration and E2E tests on the critical paths (auth, checkout, writes). Unit tests won't tell you that the glue code is plugged in the wrong way.

Step 5: Let CI be the gatekeeper

Don't count on remembering. Every pull request, written by an AI or not, has to pass:

  • Lint, formatting and type checks (strict mode)
  • The full test suite, with a minimum coverage on changed lines
  • SAST (Semgrep, CodeQL...) for injection, XSS, weak crypto
  • Secret scanning (gitleaks or whatever your platform provides)
  • Dependency checks: known CVEs, licenses, and whether the package even exists. Models sometimes invent package names, and attackers register those names to catch people out ("slopsquatting"). Pin your versions and check every new dependency yourself.
  • A reproducible build: a clean build from scratch, not "it works on my machine"

Make these checks required with branch protection. If it's not green, it doesn't get merged.

Step 6: A human reads every diff

AI code reads nicely, and that's the problem. It's easy to skim and nod along. When I review, I focus on the things AI gets wrong most often:

  • Does it do what the spec says, or something close to it?
  • Security boundaries: authorization on every route, input validation, no data leaking between tenants
  • Error handling: swallowed exceptions, retries without backoff, missing timeouts
  • Hidden complexity: duplicated logic, helpers rewritten when they already exist in the codebase, dead code
  • Performance: N+1 queries, unbounded loops, whole tables loaded into memory

One habit that helps: ask the AI to review its own diff against the spec and list the risks. Then go through that list yourself. It's a useful second opinion, but it shouldn't be the only one.

Step 7: Keep secrets and data out of it

  • Never paste production credentials, customer data or private keys into a prompt.
  • Give agents the minimum access they need: no production database, no deploy keys, sandboxed shells when you can.
  • Use git-ignored .env files locally and a real secret manager once deployed.
  • Read your AI tool's data retention and training policies, and check they fit your company's and your clients' requirements.

Step 8: Roll out gradually

Even with all of that, assume something got through and keep the damage small:

  • Feature flags, so you can switch new behavior off without redeploying
  • A staging environment that looks like production (same config, realistic data volumes)
  • Canary or percentage rollouts before going to 100%
  • Backward-compatible migrations (expand → migrate → contract), so you can roll back the code without rolling back the data
  • A written rollback plan, done before the deploy, not in the middle of the incident

Step 9: Monitor everything

When AI-written code misbehaves, you want to know fast:

  • Structured logs with request IDs
  • Metrics on error rate, latency and saturation for the new code paths
  • Alerts based on SLOs, not just "the server is up"
  • Error tracking (Sentry or similar) tagged by release, so you can see which deploy brought the regression

Step 10: Keep the codebase livable

The cost nobody talks about with vibe coding is drift: you end up with ten slightly different ways of doing the same thing. To fight it:

  • Regularly ask the AI to refactor toward the patterns you already have, not new ones
  • Update the instructions file as soon as you correct the same mistake twice
  • Write short ADRs for decisions you don't want the AI to reopen
  • Make sure at least one person understands each module. Code nobody can explain is a liability.

My checklist before merging

Before merging a vibe-coded feature, I want to be able to tick every box:

  • There's a spec with acceptance criteria, and the code matches it
  • The diff is small enough that a human read all of it
  • Tests cover the happy path, edge cases and failures, and no existing test was weakened
  • Lint, types, SAST, secret scan and dependency checks pass
  • Every new dependency is real, pinned and justified
  • No secrets, personal data or production data were shared with the AI
  • Authn/authz and input validation are in place
  • It's behind a feature flag, with a rollback plan that has been tested
  • Logs, metrics and alerts cover the new code path
  • Someone on the team can explain how it works

Last word

For me, vibe coding is mostly a faster way to type. The thinking, the checking and the responsibility haven't moved: they're still on you. Get the box right and you keep the speed of a prototype without losing sleep over what's running in production.