Theory
Agents are not just faster autocomplete. They require a different way of working. The engineers who get the most out of them share a few consistent habits.
Start with a plan
Before asking an agent to write code, ask it to plan. Most tools support a dedicated plan mode or you can simply ask: "Before you write anything, describe what you would do step by step and wait for my approval." This surfaces misunderstandings early, when they're cheap to fix.
A study from the University of Chicago found that experienced developers are more likely to plan before generating code. The same applies when directing agents.
Keep context clean and intentional
Agents don't magically know your codebase. They use what's in the context window. Some guidelines:
- Tag specific files when you know they're relevant. Don't dump everything in.
- Let the agent search for context when you're not sure what's relevant. Modern tools have good codebase search.
- Use rules files (
.cursor/rules/,Github instructions, or equivalent) to provide persistent project-level context like coding conventions, commands, and architectural decisions. - Start fresh sessions when you move to a new task. Long sessions accumulate noise and the agent can lose focus.
Know when to stop and redirect
If you see the agent heading in the wrong direction, press Escape and redirect immediately. Don't let it keep going and hope it corrects itself. The longer it goes in the wrong direction, the more expensive it is to unwind.
Use tests as the target
Agents perform best when they have a clear, verifiable goal. Tests provide that. The TDD loop works especially well with agents:
- Ask the agent to write tests first.
- Confirm the tests fail.
- Ask the agent to write code that passes the tests, without modifying the tests.
This gives the agent a concrete signal for "done" and lets it iterate without needing your input at every step.
Review every diff
AI-generated code can look right while being subtly wrong. Read the diffs. The faster the agent works, the more important your review process becomes. Don't approve changes you haven't read.
Run agents in parallel for hard problems
For difficult problems, run the same prompt against two or three different models and compare the results. Picking the best output from multiple independent attempts often produces better results than iterating on a single one.
Practice
Run this in a repository you already know, not a toy project. The point is to feel where the practice helps and where it gets in the way on code that has history.
Pick a real task from your current work, something small but non-trivial (a new endpoint, a refactor of a function, a new test suite).
- Before writing a single prompt, write the task as a one-paragraph spec: what you want, what constraints apply, what "done" looks like.
- Run the agent in plan mode first (or ask it to plan before acting). Review the plan and make at least one correction before approving.
- Implement using the TDD loop: tests first, then implementation.
- At the end, review the entire diff before accepting anything.
Reflect: where did having a plan help? Where did the agent need the most correction? What would you do differently next time?