The short version
Give your AI a short context file. Work in a loop: one task, review, check, commit. Keep files small and checks automatic. Keep secrets out of git and out of the AI’s reach. Each of those has its own guide below.
You built something with an AI coding tool and it mostly works. Or the codebase is starting to feel like it has a life of its own. Or you’re new and want good habits from the start.
This is the map. Each practice gets one line here, and the four guides linked under each group go into the detail.
The loop everything hangs on
Every practice below is either a step in this loop or a guard rail that keeps you on it:
Context: what the AI knows
- Give your AI a context file.
CLAUDE.md,.cursor/rules/orAGENTS.md: a short brief it reads every session. Keep it under 200 lines and commit it. - Document as you build. The context file,
plan.mdand your commit messages are the documentation. Build that layer on purpose. - Define your conventions. Write down folders and naming in
conventions.md, or the AI invents its own dialect.
The session: how you work
- Plan before you prompt. Write what you’re building, find a working example, and define the smallest version that works.
- Ask for options, not just answers. Two or three approaches with trade-offs, before any code.
- Be a student of your own code. Never accept what you don’t understand. You don’t need to rewrite it; you need to be able to steer the fix.
- Manage the conversation. When the AI starts repeating itself, start fresh with a handoff note.
- Iterate fast first, then carefully. Move fast to find the shape. Once you’d be upset if a feature broke, slow down to one feature at a time.
Hygiene: keeping it from rotting
- Keep files small. Flag at 400 lines, split before 500. Big files are where AI loses track.
- Run lint and typecheck automatically. A pre-commit hook means nothing gets committed without passing.
- Use strict TypeScript.
anyhides the bug TypeScript was warning you about. - Document your data. A short description of your tables and access rules stops the AI guessing every session.
Safety: the mistakes that end projects
- Keep secrets sacred.
.envin.gitignorefrom day one, and blocked from your AI. - Commit before every session. And push. Your laptop is not a backup.
- Test after every change. As much as it would hurt if that part broke quietly.
Anti-patterns to avoid
- Accept everything: the AI generates, you accept, fifty times over. Now you can’t debug it.
- The giant file: 1,200 lines doing five things. The AI can’t hold it.
- The uncommitted session: three hours of work, the AI goes off the rails, nowhere to go back to.
- The naked
.env: secrets the AI can read, or that git can see. - The
anyescape hatch: the bug goes invisible and turns up in production. - The context death spiral: an hour of debugging, with the AI suggesting fixes it already tried.
- The bloated context file: 400 lines. Half get ignored, including the ones that matter.
Want the checklist?
The start, during and end-of-session checklist is in The Vibe Coding Session Loop. Tick it off each time until it’s habit.
