Coding with AI: 7 rules to keep your sanity

How to brief an AI assistant, review its code and when to let it work on its own. Practical rules for juniors and seniors alike.

Tomáš Renčík5 min read
Illustration for the article: Coding with AI: 7 rules to keep your sanity
Contents
  1. 1. AI is a colleague, not an answer machine
  2. 2. Never accept code you haven't read
  3. 3. Tests and checks do the work for you
  4. 4. One task = one branch
  5. 5. Context is expensive — give it wisely
  6. 6. You make the important decisions
  7. 7. Let AI work on its own — but on a leash
  8. 8. Frequently asked questions
  9. 9. Final thoughts
  10. 10. Related articles

In short: AI will write code for you faster, but responsibility for it stays with you. Give it specific tasks (where, what exactly, how you will verify it), read all the code, work on separate branches and always leave dangerous steps — deleting data, production, payments — for a human to approve.

Today I write most of my code together with AI. Not because I can't program, but because one person with a good assistant can handle the work of a small team. But that only holds if you keep things in order. Without order, AI will produce chaos just as quickly.

This is a summary of what I would tell a junior on their first day, when I hand them an AI assistant.

1. AI is a colleague, not an answer machine

The most common mistake: someone types “build me a login” and waits for a miracle. They get something that looks good, but they don't know whether it works, whether it's secure or whether it fits with the rest of the code.

Assign work the way you would assign it to a person:

  • Where – which file, which function, which screen.
  • What exactly – what behaviour you want and what you don't.
  • How you will verify it – what must hold true after the change.

Compare:

Fix the login.

and

In server/api/login.post.ts, login returns a 500 when the e-mail contains uppercase letters. I want the e-mail converted to lowercase before the comparison. After the change, the login.test.ts test must pass and a new test for an e-mail with uppercase letters must be added.

The second brief is three lines longer and will save you an hour.

2. Never accept code you haven't read

It sounds obvious, but with AI everyone breaks this rule. The code arrived fast, it looks confident, the tests (also written by AI) passed — so you push it.

My rule: I read code from AI like a pull request from a new colleague. Above all, I look for:

  • Whether it does more than I asked for (it changed something else “along the way”).
  • Whether it made up a function or a library that doesn't exist.
  • Whether it handled errors, empty values and edge cases correctly.
  • Whether it touched security: permissions, user input, SQL.

If you don't understand a line, ask the AI why it's there. If it can't give you a sensible explanation, the line doesn't belong there.

3. Tests and checks do the work for you

AI is excellent at not forgetting to run a check — provided you have one. That's why it pays to have a few simple scripts in your project:

npm run build        # does it even build?
npm run lint         # style and obvious errors
npm test             # behaviour

And tell the AI: “After every change, run these three commands and show me the result.” Not “I think it should work”, but the command output. The difference between “should” and “works” is exactly the one that costs you your nerves on a Friday evening.

4. One task = one branch

When AI works on several things at once in a single folder, the changes get mixed up and you can't tell what belongs to what. So:

  • every task gets its own git branch,
  • larger tasks also get their own working folder (git worktree, which I cover in a separate article),
  • only what you have reviewed goes into the main branch.

Thanks to this, you can safely have three tasks in progress at once and throw any of them in the bin if it doesn't work out.

5. Context is expensive — give it wisely

AI works with what you give it. Give it the whole project and it gets overwhelmed, and you pay for it (literally, in tokens). Give it nothing and it will guess.

What helps:

  • A short file with the project's rules in the root of the repository: how to run it, what is forbidden, where things are. Not a novel — one screen.
  • Documentation alongside modules: what the module does, what tables it has, what to watch out for. The AI reads it when it gets to that module.
  • New topic = new conversation. A long conversation is sent again in full with every reply. When you move on to something else, start afresh.

6. You make the important decisions

AI will happily suggest that it “would be good” to rewrite half the application. Sometimes it's right. But whether it's worth it, when and at what cost — that's your call. The same goes for anything that can't be undone:

  • deleting data,
  • changes to the production database,
  • deployment, payments, access.

For these things, the AI should always ask. And you should read what you are saying yes to.

7. Let AI work on its own — but on a leash

Once you have order in place (branches, checks, rules), you can give AI a bigger task and go to sleep. In the morning you'll find a finished branch, check results and screenshots. That is enormous power.

There is one condition: none of it may reach a customer without you. Autonomy yes, deployment without review no.

Frequently asked questions

Can AI replace a programmer?

No. It makes you a faster programmer, provided you understand what you're doing. Leave decisions, review and responsibility for the result to a human.

How do I brief AI so the result is right?

The same way you would brief a colleague: in which file, what behaviour you want and how you will verify that it works. The more specific the brief, the fewer the fixes.

Is it safe to let AI work on its own?

Yes, if it has its own branch, checks and clear rules about what it must not do. But none of its work may reach a customer without your review.

Final thoughts

AI won't make you a programmer. It will make you a faster programmer — if you already understand what you're doing. That's why I tell juniors: use it, but every day keep at least one thing for yourself that you write on your own and understand completely. That one will teach you more than ten generated ones.

  • #AI
  • #programovanie
  • #code review
  • #juniori
  • #git