Vibe coding is the practice of describing software in plain language and letting an AI model write, run, and revise the code while you steer by feel. Computer scientist Andrej Karpathy popularized the term in early 2025 to describe a mode where you “forget that the code even exists.” It has since split into two camps: weekend builders shipping prototypes in hours, and engineers warning about unreviewed code reaching production. Both are right. This guide covers the mechanics, the trade-offs, and a repeatable workflow that keeps the speed without the security debt.
Quick Takeaways
- Vibe coding = prompt-driven development where you accept AI output with minimal line-by-line review.
- Best for: prototypes, internal tools, throwaway scripts, and learning. Worst for: auth, payments, and anything handling sensitive data.
- Biggest risks: hardcoded secrets, missing input validation, hallucinated packages, and unmaintainable code nobody understands.
- Safe approach: spec first, small diffs, automated tests, secret scanning, and human review on every security-relevant path.
Vibe Coding vs. Traditional Coding vs. AI-Assisted Coding
The term gets stretched. Precision matters, because the risk profile differs sharply across modes.
| Dimension | Traditional Coding | AI-Assisted Coding | Vibe Coding |
|---|---|---|---|
| Who writes code | Human | Human + AI autocomplete | AI (human prompts) |
| Code review | Full | Full, line by line | Minimal or none |
| Required skill | High | Medium-high | Low-medium |
| Speed to prototype | Slow | Fast | Fastest |
| Maintainability | Depends on team | Good | Often poor |
| Typical tools | IDE, Git | Copilot-style completion | Chat agents, Claude Code, Cursor-style editors |
| Security risk | Baseline | Baseline + moderate | Elevated without guardrails |
The key distinction: in vibe coding, you judge the behavior of the running app, not the source. In AI-assisted coding, you still read what ships.
How Vibe Coding Works Under the Hood
Modern vibe coding runs on agentic loops, not single prompts. The cycle looks like this:
- Intent: You describe a feature in natural language.
- Planning: The model breaks it into file-level tasks.
- Generation: It writes or edits code across multiple files.
- Execution: It runs the app, tests, or linters via tool calls.
- Self-correction: It reads errors and patches them.
- Human check: You test the behavior and send the next prompt.
Why Context Windows Matter
Agent quality depends on how much of your codebase fits in the context window. Models in the 200K to 1M token range can hold mid-sized repositories in memory. Beyond that, tools rely on retrieval (embedding-based search over files) to pull relevant chunks. When retrieval misses a file, the model invents an interface that doesn’t exist. That is the root of many “it worked, then broke everything” moments.
Temperature and Determinism
Most coding agents run at low temperature (0 to 0.3) for consistent output. Higher values (0.7+) add variety but increase syntax errors and API hallucinations. If you call a model directly for code generation, keep temperature low.
The Real Advantages
- Speed: A working prototype in hours instead of days. Founders validate ideas before hiring.
- Lower barrier to entry: Designers, analysts, and domain experts can build tools without learning a framework first.
- Reduced boilerplate: CRUD scaffolding, config files, and test stubs get generated instantly.
- Faster learning: Reading generated code (when you do read it) exposes patterns you might not have found alone.
- Cheap experimentation: Discarding a failed prototype costs minutes, not sprints.
The Real Pitfalls
1. Security Vulnerabilities
Generated code often skips input sanitization, uses weak auth patterns, or exposes API keys in client-side bundles. Common offenders include SQL injection, missing rate limits, and permissive CORS settings.
2. Hallucinated Dependencies
Models sometimes import packages that don’t exist. Attackers register those names with malicious code, a technique called slopsquatting. Always verify every new dependency.
3. Technical Debt You Can’t Read
If nobody understands the code, nobody can debug it. Debugging by re-prompting often adds layers of patches over the original flaw.
4. Silent Logic Errors
The app runs. The numbers are wrong. Edge cases like time zones, rounding, and empty states pass a casual demo but fail in production.
5. Context Drift
Long sessions degrade. The model forgets earlier decisions, duplicates functions, or reverts a fix. Restart sessions with a fresh summary.
When to Vibe Code (and When Not To)
| Use Case | Vibe Code? | Reason |
|---|---|---|
| Landing page prototype | ✅ Yes | Low stakes, easy to rewrite |
| Internal dashboard (no PII) | ✅ Yes | Contained blast radius |
| Data cleanup script | ✅ Yes | Verify output on a sample |
| Hackathon MVP | ✅ Yes | Speed beats polish |
| Authentication system | ❌ No | Subtle flaws are catastrophic |
| Payment processing | ❌ No | Compliance and financial risk |
| Medical or legal software | ❌ No | Regulated, high consequence |
| Infrastructure-as-code for production | ⚠️ With review | Misconfigurations expose data |
How to Vibe Code Safely: A Step-by-Step Workflow
Step 1: Write a Spec Before Prompting
Vague prompts produce vague software. Draft a short spec covering users, data models, constraints, and non-goals.
Project: Invoice tracker (internal use only)
Stack: Python 3.12, FastAPI, SQLite, pytest
Data: invoices(id, client, amount_cents, due_date, status)
Rules:
- Store money as integer cents, never floats
- Validate all inputs with Pydantic
- No external network calls
- Every endpoint needs a pytest test
Non-goals: authentication, multi-user support
Paste this at the start of every session. It acts as a persistent constraint set.
Step 2: Prompt in Small Increments
Request one feature per prompt. Review the diff. Commit. Repeat.
Add a POST /invoices endpoint that creates an invoice.
Validate that amount_cents > 0 and due_date is not in the past.
Return 422 on invalid input. Add pytest tests for valid and invalid cases.
Do not modify any other files.
The line “Do not modify any other files” prevents scope creep, a frequent cause of regressions.
Step 3: Make the Model Write Tests First
# tests/test_invoices.py
from fastapi.testclient import TestClient
from app.main import app
client = TestClient(app)
def test_rejects_negative_amount():
r = client.post("/invoices", json={
"client": "Acme", "amount_cents": -500, "due_date": "2027-01-01"
})
assert r.status_code == 422
def test_creates_valid_invoice():
r = client.post("/invoices", json={
"client": "Acme", "amount_cents": 125000, "due_date": "2027-01-01"
})
assert r.status_code == 201
Tests give you an objective pass/fail signal, which replaces the code review you’re skipping.
Step 4: Automate Security Checks
Run these in CI or a pre-commit hook:
# Secret scanning
pip install detect-secrets
detect-secrets scan > .secrets.baseline
# Dependency vulnerability audit
pip install pip-audit
pip-audit
# Static analysis for common Python security flaws
pip install bandit
bandit -r app/ -ll
# Lint and type-check
pip install ruff mypy
ruff check . && mypy app/
Step 5: Verify Every Dependency
Before installing any package the AI suggests:
pip index versions <package-name> # confirm it exists
pip show <package-name> # check author, homepage, version
Check download counts and the repository. A package with a week-old upload and 12 downloads is a red flag.
Step 6: Use Version Control as Your Undo Button
Commit after every working increment. Use branches for experiments. When the agent goes sideways, git reset --hard is faster than arguing with it.
Step 7: Human-Review the Dangerous Paths
Even in a vibe-coded project, manually read code that touches:
- Authentication and sessions
- Database queries with user input
- File uploads and path handling
- Secrets, tokens, and environment variables
- Anything calling
eval,exec, or shell commands
Advanced Prompt Templates for Safer Output
Security-first constraint prompt:
You are a security-conscious senior engineer. Before writing code,
list the top 3 security risks of this feature. Then implement it
with mitigations for each. Use parameterized queries only.
Never log secrets or personal data. Flag any assumption you make.
Self-audit prompt (run after generation):
Review the code you just wrote as an adversarial penetration tester.
List vulnerabilities by severity (critical/high/medium/low) with the
exact file and line. Then propose fixes as a minimal diff.
Context reset prompt (for long sessions):
Summarize the current architecture, key decisions, open bugs, and
coding conventions in under 400 words. I will paste this into a
fresh session.
Tool Landscape Comparison
| Tool Type | Examples | Strength | Trade-off |
|---|---|---|---|
| Terminal agents | Claude Code | Full repo access, runs commands | Needs comfort with CLI |
| AI-native editors | Cursor-style IDEs | Inline diffs, fast iteration | Subscription cost |
| Browser app builders | Lovable, Bolt-style tools | Zero setup, instant deploy | Less control, harder to export |
| Chat-only | Any LLM chat window | Flexible, cheap | Manual copy-paste, no execution |
Pricing and features shift quickly, so verify current plans on each vendor’s site before committing.
Real-World Scenarios
Startup validation: A solo founder builds a booking tool in a weekend, tests it with 20 users, and learns the idea needs a pivot. Total sunk cost: minimal. Production rewrite happens only after validation.
Enterprise internal tools: A finance analyst vibe codes a reconciliation script. IT reviews the final output, runs it in a sandbox with read-only database credentials, and deploys it behind SSO. The guardrails, not the code quality, make it safe.
Developer productivity: A senior engineer uses vibe coding for throwaway migration scripts and test fixtures, but hand-reviews core services. This hybrid approach captures most of the speed gain with little of the risk.
Safety Checklist
- [ ] Written spec with explicit constraints
- [ ] Small, reviewable commits
- [ ] Automated tests for every feature
- [ ] Secret scanning enabled
- [ ] Dependencies verified manually
- [ ] No production credentials in the dev environment
- [ ] Human review of auth, data access, and payment code
- [ ] Staging environment before production
Frequently Asked Questions
What is vibe coding in simple terms?
Vibe coding means building software by describing what you want in plain English and letting an AI write the code. You evaluate the result by running it, not by reading every line.
Is vibe coding safe for production apps?
Not by default. Unreviewed AI code can contain security flaws, hallucinated dependencies, and logic errors. It becomes safer with tests, automated security scans, and human review of sensitive code paths.
Can beginners learn to code with vibe coding?
Yes, with a caveat. It lowers the barrier to building, but skipping fundamentals leaves you unable to debug failures. Pair it with reading the generated code and asking the AI to explain it.
Will vibe coding replace software engineers?
Unlikely in the near term. It shifts engineering toward specification, architecture, testing, and review. Teams still need people who can judge whether code is correct, secure, and maintainable.




