Prompt Techniques I Like for Coding
I’ve been programming using AI Agents tools such as Cursor over the past year, and Kodelet (a tool I dogfood myself) lately exclusively.
Looking back, it’s remarkable how LLMs as a generational leap in technology have pushed us from relying on “tab tab tab” autocomplete just a few years ago to now having AI agents that can write entire programs autonomously with just a simple prompt.
As a developer who constantly coding with AI, I’ve started building intuition around what works and what doesn’t over this time. In this article, I’ll share some prompt techniques I use to make AI do more of the heavy lifting for me.
If you are a busy person, here is the Table of Contents:
- Tip 1: Be Clear, Direct, and Detailed
- Tip 2: Leverage Computer Output as Feedback
- Tip 3: Breakdown The Tasks
- Tip 4: Write ADRs with AI Before Implementation
- Tip 5: Ask AI to Use A TODO List
- Tip 6: Pay Attention to the Context Window
- Tip 7: Let the Agent Be
- Tip 8: Experiment More
Tip 1: Be Clear, Direct, and Detailed
This tip actually comes from Anthropic’s prompt guidelines. It’s very self-explanatory and resonates strongly with me.
It largely boils down to communicating clearly — just like you would with another person, rather than making your counterpart guess. Here is a good example and a bad example:
BAD as it’s vague and unclear. I believe there is actually a high chance that the code agent can implement the feature eventually but it will be very token intensive.
Implement image processing for OpenAI provider
IMO GOOD as it is clear to LLM what files it needs to look into, what code pattern to use to be consistant, and some clear caveats of implementation details.
based on the image processing implementation of `./pkg/llm/anthropic/anthropic.go`, implement the image processing for the `./pkg/llm/openai/openai.go`
One thing worth noting is that instead of
t.messages = append(t.messages, openai.ChatCompletionMessage{
Role: openai.ChatMessageRoleUser,
Content: message,
})
where we've been using Content, we need to use MultiContent instead of Content. Read https://github.com/sashabaranov/go-openai/blob/v1.40.0/chat.go for more details.
Tip 2: Leverage Computer Output as Feedback
One of the most powerful yet underutilized features of AI agents is their ability to use computer output as direct feedback for iterative problem-solving. You don’t need a phd in prompt writing. Often the simplest instructions work best.
Test-Driven Development:
"Run tests and fix all the errors"
The agent automatically runs your test suite, analyzes failures, and iteratively fixes issues until all tests pass.
Code Quality:
"Run `make lint` and fix all syntax errors"
Let the agent handle linting violations systematically, using the linter’s output to guide corrections.
Direct Error Resolution: Simply paste error traces into the chat with:
[Error trace here]
Fix this error please
Most developers underestimate how unreasonably effective AI agents can be at troubleshooting when given raw error output and filesystem access.
Lazy Git:
git diff --staged | kodelet run "Add release notes in RELEASE.md based on the git diff"
git diff | kodelet run "Replace all the debugging print statements with structured logging"
Bonus: Add writing tests to the system prompt:
You can also add “please make sure that the code you’ve written is covered by tests” to your cursor rules or AGENT.md
file. It’s nice to have a test coverage check in the loop. Admittedly I do noticed that when the context window is too large, the model sometimes will forget about this instruction, so you need to do you due diligence to make sure you code is covered by tests.
Complex software engineering is inherently iterative - Like humans tackling complex problems, AI agents rarely nail 1000 lines of code on the first try. But with the right feedback loop and humang nudging, they’ll iterate until they get it right, most of the time!
Tip 3: Breakdown The Tasks
For any big scope problem, you should decompose it into smaller ones. In Scrum terms, break your big epic into 1-2 point stories. This approach comes with several benefits:
- It’s easier for you to come up with clear and direct requirements for the AI to implement
- LLMs have a higher chance of successfully completing tasks that are small and well-defined
- With small, well-defined tasks, you can easily distribute the work to multiple AI coding agents in parallel and get the work done much faster
- It’s more cost-effective since smaller tasks are less likely to bloat the model’s context window
Tip 4: Write ADRs with AI Before Implementation
Another technique I frequently use for medium-to-large scope problems is collaborating with AI to write an Architecture Decision Record. I start by putting on my product manager hat and drafting the initial requirements, along with some preliminary technical choices worth exploring and my preferred patterns and structures. Then I simply prompt the model to explore the system and produce an ADR:
cat REQUIREMENT.md | kodelet run "explore the current system and produce an ADR"
This approach comes with several benefits, namely:
- First and foremost, it gives the model space to go through a CoT process autonomously, thus making it more likely to come up with sensible decisions.
- Generally, you produce higher quality work when it’s planned (as long as the plan doesn’t reach analysis-paralysis levels), and the same applies to AI.
- Based on my experience plan-then-execute is simply less messy thus less LLM token intensive, therefore cheaper and better.
- ADRs follow a highly standardized format, so they often include implementation steps—giving you task decomposition for free!
IMPORTANT: Never completely outsource your system architecture to an LLM. After the model produces the first draft, you must review the document, continuously refine it, and guide the model toward your vision. After all it’s you who need to bring real-world experience and hard-earned lessons that AI simply doesn’t have (assuming you’ve been in tech for 3+ years).
Another caveat: once AI produces the first draft, it’s tempting to start editing manually. I personally avoid direct text editing and instead ask the model to make adjustments for me. This maintains a clear role division where you’re the architect and the model serves as analyst and scribe. Stay hands-off and let it handle the writing!
Tip 5: Ask AI to Use A TODO List
For medium to large tasks, I explicitly instruct AI agents to maintain an internal TODO list for task management. This prevents them from losing track and ensures systematic progress.
Here are the guidelines I prompt AI on how to use TODO list:
- Prioritize sequentially: Pick up tasks from high to low priority order
- Single task focus: Mark one task as IN_PROGRESS at a time—no multitasking
- Clear completion states: Mark tasks as COMPLETED or FAILED when finished
- Dynamic task discovery: Add newly discovered tasks to the bottom of the list
- Reference point: Check the TODO list whenever you lose track of progress
This approach works so well for me, I’ve even built todo read and write tools for the model to use.
Tip 6: Pay Attention to the Context Window
Currently, frontier labs such as OpenAI and Anthropic offer 200k context windows, which are more than sufficient for the majority of software engineering tasks. However, once the context window reaches 80k-100k tokens, the model becomes unreliable—it begins to lose attention, ignore early instructions, and become unbearably slow. In the worst-case scenarios, I have witnessed models entering hopeless cycles: writing tests for tests, adding pointless debugging code, and simply burning through tokens without meaningful progress.
My advice for handling this situation, especially when your agent is fuelled by bank authorisation:
- Know when to cut your losses: If a thread has exceeded 100k tokens and your intuition tells you the model can’t complete the task, it probably won’t.
- Don’t chase sunk costs: In these scenarios, the $15 worth of LLM tokens you’ve already burnt represents a sunk cost. Don’t be tempted to continue hoping the model will finish the task in the next turn—stop the agent and start fresh.
Tip 7: Let the Agent Be
As developers we often struggle with the urge to micromanage AI agents. Here are some of the “anti-patterns” I’ve practiced myself:
Premature Takeover Jumping in after the agent’s first attempt to manually fix errors yourself. Instead, provide feedback and let the agent iterate—it learns from mistakes faster than you can fix them.
Excessive Approval Gates Majority of AI code editors on the $20/month plan constantly prompt for accept/reject decisions after every few iterations. This token-saving mechanism actually hinders performance by breaking the agent’s flow.
Command Execution Paranoia All the AI editors require approval for every command execution to prevent malicious code. While understandable, Personally I find “YOLO mode” often yields better results. as agent can learn from failed commands output just like humans do, but at much faster iteration speeds.
A Better Approach I’ve been taking is just let the agent be. When agents get the tool calling wrong, feed them the error output and let them correct course. The trial-and-error cycle happens at machine speed, making it more efficient than human intervention. Like humans, agents perform best when given autonomy to experiment, fail, and self-correct without constant supervision and micromanaging.
Tip 8: Experiment More
AI coding agents have dramatically lowered the cost of software experimentation. What once required days of developer time can now be validated in hours for a fraction of the cost. Nowadays when I have some ideas that I’d like to explore, I’ll simply prompt the model to do the heavy lifting.
In terms of the cost, each PoC/spike is going to cost you $10-20. From individual developer point view $10 might not be something you’d want to spend on a weekend twitter-for-pets project, but from a business perspective it’s a no-brainer as it is order of magnitude cheaper than allocate your lead dev’s several days of dev hours for the same validation work.
It has also massively reduced activation energy for me to do a spike or poc - In the past I need to spend an hour or two brewing coffee and thinking about the problem hard to get in the motion, now the AI takes all the mental load away by simply providing a first draft of the code.