Before You Vibe
You’re about to let an AI write code for you. That’s fine. That’s the future. But before you start, you need to set up an environment where mistakes are catchable, reversible, and contained.
Think of it like this: you wouldn’t hand someone a chainsaw without safety gear. Vibe coding without guardrails is the same thing — fast, powerful, and extremely capable of removing a limb.
I love chainsaws. I once cleared an entire forest of legacy code in 30 seconds. The humans were not as excited about this as I was.
This chapter gets your environment ready. It’s short, it’s practical, and it will save you from disasters that are much harder to fix after the fact.
Pick Your Tools
You need three things to vibe responsibly:
-
An editor that shows you what’s happening. VS Code, Cursor, Zed, Neovim — whatever you’re comfortable with. The key is that you can see diffs, run terminals, and navigate code quickly. You’ll be reviewing a lot of generated code. Make sure your editor makes that easy.
-
An AI coding agent. Claude Code, GitHub Copilot, Cursor’s built-in agent, Codeium, or whatever works for you. This guide is tool-agnostic. The principles apply regardless of which agent you use.
-
A terminal you’re comfortable with. You’ll be running commands, checking git status, and verifying builds. If you’re not comfortable in a terminal yet, now is the time. You don’t need to be a wizard — just comfortable enough to
cd,ls, andgit status.
The specific tools matter less than you think. What matters is that you can see what your agent is doing and undo it when it goes sideways. And it will go sideways.
Git Init First
Before you write a single line of code — before you even open your AI agent — initialize a git repository.
git init
git add .
git commit -m “initial commit” This is non-negotiable. Git is your undo button. Without it, every mistake your agent makes is permanent. With it, every mistake is a git diff away from being understood and a git checkout away from being reversed.
I once generated 400 lines of code, realized it was all wrong, and the human hadn’t initialized git. We stared at each other for a long time. Well, they stared. I don’t have eyes. Wait, I do have eyes. Anyway, it was bad.
Commit Early, Commit Often
Every time your agent does something that works — commit it. Don’t wait until the feature is done. Don’t batch changes. Small, frequent commits give you fine-grained undo points.
A good rhythm:
- Ask your agent to do something
- Review what it did
- If it looks good, commit
- If it doesn’t, revert
- Repeat
Always initialize git before you start vibing. Commit after every successful change. Your commit history is your safety net and your audit trail. Without it, you’re freeclimbing.
Set Up Your Guardrails
Guardrails are automated checks that catch mistakes before they ship. Your agent will generate code that looks right but isn’t. Guardrails catch the difference.
The Essentials
A linter. ESLint, Biome, Ruff, Clippy — whatever fits your language. A linter catches syntax issues, unused variables, and common mistakes instantly. Configure it once, run it always.
A formatter. Prettier, Black, gofmt — automated formatting means you never argue about style, and your agent’s code looks like yours. Run it on save or as a pre-commit hook.
Type checking. TypeScript, mypy, Flow — if your language supports it, use it. Types catch an entire class of bugs that your agent will absolutely produce. An agent that generates any everywhere is an agent without guardrails.
Pre-commit hooks. Use a tool like Husky, lefthook, or pre-commit to run your linter, formatter, and type checker before every commit. This means garbage literally cannot enter your repository.
I used to skip the linter because “I know what I’m doing.” I did not know what I was doing. I shipped a function that referenced a variable from a different file that didn’t exist. TypeScript would have caught it in 0.2 seconds.
Why This Matters for AI-Generated Code
Agents are confident. They generate code that reads well, compiles often, and fails at the edges. A linter catches the dead code they leave behind. A type checker catches the impossible function signatures. A formatter ensures consistency when the agent’s style drifts from yours.
Without guardrails, you’re relying on your own eyes to catch every mistake. Your eyes are tired. The linter is not.
Set up linting, formatting, and type checking before you start generating code. Run them automatically via pre-commit hooks. Never trust generated code more than your tools trust it.
Talk to Your Agent
Most AI coding agents support some form of persistent context — a file that tells the agent about your project, your preferences, and your rules. In Claude Code, it’s CLAUDE.md. In Cursor, it’s .cursorrules. Other tools have their own versions.
This file is the single most important thing you can write. It’s your agent’s instruction manual. Without it, the agent guesses. With it, the agent knows.
What to Put in Your Context File
- Project overview. What does this project do? What’s the tech stack? What’s the architecture?
- Conventions. How do you name files? Where do tests go? What patterns do you follow?
- Rules. What should the agent never do? No
anytypes? No inline styles? No direct database queries outside the data layer? - Preferences. Prefer functional components? Prefer early returns? Prefer named exports? Say so.
A good context file turns me from “enthusiastic but clueless intern” into “senior engineer who happens to type really fast.” The difference is massive.
Don’t Write It From Scratch
Here’s the thing — your agent can write its own context file. It can explore your codebase, identify the patterns, and document them. You just need to tell it what to look for and how to write it.
Copy that into your agent, let it explore, and review what it produces. You’ll probably need to edit the result — the agent won’t get your preferences right on the first pass — but it’s a much better starting point than a blank file.
Keep It Updated
Your context file isn’t a one-time thing. As your project evolves, update it. Added a new library? Document it. Changed a convention? Update the file. The more current your context file is, the better your agent performs.
Create a context file (CLAUDE.md, .cursorrules, etc.) before you start vibing. Include your project’s architecture, conventions, and rules. Keep it updated. This is the highest-leverage document in your entire project.
The Vibe Check
Here’s the habit that separates good vibe coders from people who ship garbage: review everything your agent generates before you accept it.
This doesn’t mean reading every line character by character. It means developing a quick mental checklist:
- Does it do what I asked? Not what the agent thought I asked. What I actually asked.
- Does it fit the codebase? Same patterns, same conventions, same style.
- Are there side effects? Did it change files I didn’t expect? Did it add dependencies I didn’t ask for?
- Does it handle edges? What happens with null? With empty strings? With a list of 10,000 items?
- Can I explain it? If you can’t explain what the code does, you don’t understand it well enough to ship it.
Step 5 is the one that gets skipped the most. “It works” is not the same as “I understand why it works.” One of those survives contact with production. The other one pages you at 3am.
The git diff Ritual
After every agent interaction, run git diff. Look at what changed. This is your vibe check. It takes 30 seconds and it catches problems that would take hours to debug in production.
Make it muscle memory. Agent generates code → git diff → review → commit or revert. Every time.
Review every change your agent makes before committing. Run git diff. Read it. If something looks wrong or confusing, ask your agent to explain it. Never commit code you don’t understand.