Dark terminal-style cover with the title Prompt patterns for reliable coding agents and a code window showing an agent brief with goal, scope, plan and done-when checks

Prompt Patterns That Make Coding Agents Reliable

by Evgenii Studitskikh
0 comments 24 views 5 minutes read

Coding agents have become part of how I build. My side project Geo Factbook was mostly written in a loop with them, and in my newer projects coding agents work directly against tracked issues, with every commit linking back to the issue it came from.

The biggest lesson from that work: an agent’s reliability depends much less on the model than on how you brief it. The same agent that produces a clean, tested change from one prompt will wander off and rewrite half a module from another. Here are the prompt patterns that made the difference for me.

1. Give it a goal, not just a task

“Add a loading state to the rankings table” is a task. “Users think the rankings page is broken because it shows an empty table for a second while data loads; add a loading state so it’s obvious something is happening” is a goal.

With the goal, the agent can make sensible small decisions on its own: whether a skeleton or a spinner fits better, whether the empty state needs its own message, which other tables have the same problem. Without it, you get exactly what you asked for and nothing that you meant.

2. Point at the files and the patterns to copy

Agents are good at search, but every minute spent exploring is a chance to latch onto the wrong example. I name the files that matter and, more importantly, an existing piece of code that already does something similar: “follow the pattern in the country summary component”. Consistency with the codebase is one of the hardest things to get from an agent by accident, and one of the easiest to get on purpose.

3. Say what “done” looks like

The most reliable prompts end with acceptance criteria an agent can check itself:

  • the existing tests pass, plus a new test for the edge case,
  • the type check and linter are clean,
  • the page renders with an empty dataset without errors.

If the agent can run the check, it will iterate until the check passes. If “done” only lives in my head, it will stop when the code looks plausible, which is not the same thing.

4. Draw the boundaries explicitly

Agents are eager. Ask for a bug fix and you may get a refactor, a dependency upgrade and renamed variables as a bonus. Now the diff is three times bigger and much harder to review.

So I state the scope: “only change files under the rankings feature”, “don’t add dependencies”, “don’t touch the public API of this module”. Stating what’s out of scope is as useful as stating what’s in it.

5. Ask for a plan before code on anything non-trivial

For changes that touch more than a couple of files, I ask the agent to propose a plan first: which files it will change, in what order, and why. Reading a ten-line plan takes a minute. Reading a wrong 400-line diff takes much longer, and then you still have to explain what you actually wanted.

The plan is also where most misunderstandings surface. If the agent’s plan includes a migration I didn’t expect, that’s a conversation to have before any code exists.

6. Make it show its work

I ask agents to end each run with a short summary: what changed, what they verified and how, and anything they weren’t sure about. The last part matters most. An agent that writes “I wasn’t able to run the end-to-end tests” has just told me exactly where to look. An agent that silently skips them hasn’t.

7. Keep the context small and current

Long sessions drift. Early instructions get diluted, stale assumptions linger, and the agent starts solving yesterday’s version of the problem. I prefer short, focused sessions with one goal each, and I keep durable project knowledge (conventions, commands, gotchas) in a file the agent reads at the start, rather than repeating it in every prompt.

8. Tie the work to a ticket

In my projects every agent session starts from an issue in the tracker, and every commit references it. That one habit fixes several problems at once: the issue is the brief, it holds the acceptance criteria, and the history explains why each change exists. When something breaks a week later, I can trace it back to the exact request that produced it.

9. Prefer many small changes over one big one

An agent can produce a huge change in one go, and that’s exactly the trap. Big diffs are hard to review, hard to test and hard to roll back. I break work into steps that each leave the project in a working state: first the data layer, then the component, then the page. Each step gets its own short session and its own commit. If one step goes wrong, I throw away a small change instead of untangling a large one, and the agent starts the next step from a codebase that already works.

The pattern behind the patterns

All of these come down to the same idea: brief an agent the way you’d brief a capable new teammate who has never seen your codebase. Give them the why, point them at examples, tell them how you’ll judge the result, and ask them to flag what they’re unsure about. Agents aren’t magic, but with a good brief they’re remarkably consistent, and consistency is what lets one person ship real products with them.

I’m always comparing notes with other engineers building with AI agents. If that’s you, connect with me on LinkedIn.

You may also like