Describe the result, not the code
You don't need to know which files to change. You need to know what someone using your app will see when the work is finished. Write that.
"Improve the contact page" gives the agent nothing to aim at, so it guesses, and it usually guesses big. Compare it with this:
On the contact page, add a form with name, email and message.
When someone submits it, send the message to hello@myshop.com
and show "Thanks, we'll reply within a day" in place of the form.
Three lines, and every one of them is something you can check in a browser. If you catch yourself writing a technical instruction you're not sure about ("use a server action"), leave it out. The agent can read your code. It can't read your mind.
Say when it's done
This is the line most people skip, and it's the one that changes the result the most. Add a sentence that starts with "Done when" and lists conditions you or the agent can actually test.
Done when:
- submitting the form with all three fields sends the email
- submitting with an empty email shows an error and sends nothing
- the existing tests still pass
Anthropic's own advice for Claude Code makes the same point: give the agent a check it can run, such as tests, a build or a screenshot to compare, and ask it to run that check and keep going until it passes. Without one, the agent stops when the work looks finished to it, and you become the person who finds what's missing.
If your project has tests, ask for one that proves the new behavior. If it doesn't, a list of things to click through is still far better than nothing.
Say what's off limits
Agents tend to do a little more than you asked. Sometimes that's helpful. Often it's a new column in your database or a new package you now depend on. One line stops most of it:
Don't change the database, don't add packages,
and don't touch sign-in or payments.
Pick the limits that matter for this feature. A contact form has no reason to touch your customer table, so say so. If the agent decides it really needs to cross one of those lines, you want it to stop and ask, not to do it quietly. Write that too: "If you think you need to, ask me first."
Point to something that already works
Your app already has patterns: a button style, a way of calling the database, a form somewhere else. Name one and ask the agent to follow it. "Build it like the newsletter form in the footer" saves a lot of back and forth. In Claude Code you can type @ followed by a file path to hand it that file directly.
The same goes for problems. If something is broken, paste the exact error message and say where you saw it, rather than "the form doesn't work".
One feature per request
Keep each request to one thing you could explain to a friend in a sentence. "Contact form" is one request. "Contact form, new pricing page and order emails" is three, and mixing them makes the change harder to review and harder to undo.
For anything bigger, ask for a plan before any code. In Claude Code, press Shift+Tab until the status bar shows plan mode, or start with:
claude --permission-mode plan
In plan mode the agent reads your code and proposes what it will do, without editing your files until you approve. Read the plan the way you'd read a quote from a contractor: which files, which steps, anything you didn't expect. Ask for changes, then approve and let it build. For a one-line fix, skip this step: the plan would take longer than the change.
Keep standing rules in one file
Some things are true for every request: how to start the app, that prices are stored in cents, that nobody touches the payments folder without asking. Don't retype them. Put them in a file at the root of your project that the agent reads before it starts.
- Claude Code reads
CLAUDE.md. Run/initinside Claude Code and it writes a starting version from your project. To share rules kept inAGENTS.md, put the line@AGENTS.mdin yourCLAUDE.mdand Claude Code pulls that file in. - Codex reads
AGENTS.mdbefore it starts work, from the root of your repository down to the folder you're in. By default it stops reading after 32 KiB of instructions. - Mistral Vibe's configuration docs mention it loading
AGENTS.mdtoo, for example from extra folders you add to a session. Check them for your version.
If you switch between agents, keep the rules in one AGENTS.md and import it from CLAUDE.md. A short example:
# How to run
npm install, then npm run dev. Tests: npm test.
# Rules
- Prices are stored in cents.
- Reuse the Button and Field components in components/ui.
- Never edit files in supabase/migrations without asking.
- Never put a key or secret in the code. Use .env.
Keep it short. Anthropic suggests staying under 200 lines, because longer files take up more of the agent's context and get followed less reliably. If a line wouldn't prevent a real mistake, cut it.
When the agent goes off track
Stop it early. In Claude Code, Esc interrupts without losing the conversation, so you can redirect. If you've corrected the same thing twice and it's still wrong, run /clear and start again with a better request that includes what you learned. A fresh start with a clear request beats a long thread full of failed attempts. Claude Code's documentation gives the same advice after two failed corrections.
A template you can copy
Feature: [one sentence a user would understand]
What it should do:
- ...
Done when:
- ...
- the existing tests still pass
Don't:
- change the database / add packages / touch [area]
- If you think you need to, ask me first.
Follow the pattern in: [file or screen that already works]
Write it before you start the agent, keep it open while it works, and compare the result with it line by line when it's done. We cover that last step in how to check what your coding agent actually changed. If you're still moving your project off Lovable, start with moving your Lovable project to GitHub.