of your AI coding agent is essential to its efficiency. It’s possible some of the important elements figuring out what number of duties you’ll be able to carry out with a coding agent and your success price in doing so.
On this article, I’ll focus on particular strategies I exploit to enhance the context of my AI brokers. I’ll clarify particularly how I do it, and why. It’s essential to know why I’m utilizing these strategies, so you can begin creating your individual strategies sooner or later, and actually optimize your agentic coding.
Desk of Contents
Why optimize agentic context
The context you present your coding agent is all the data it has to finish a process. Thus, correctly managing your context is extremely essential if you’d like your coding agent to work effectively.
Bettering your context by a couple of p.c can have a large influence in your effectivity as an engineer in the event you spend many hours every day programming. I thus spend plenty of time, continuously attempting to optimize my programming with my coding agent.
The 4 strategies I’ll current within the subsequent part are a results of my testing all kinds of various strategies and approaches. On this article, I’ll solely cowl 4 of an important strategies and why they work so effectively. Sooner or later, I may additionally cowl some failed strategies and mirror on why they didn’t work
4 particular strategies
On this part, I’ll cowl 4 particular strategies I make the most of to optimize the context for my coding brokers. I’ve written the strategies in no specific order, and I think about all of them essential to me in my quest to be as environment friendly an engineer as doable.
At all times replace AGENTS.md
In all probability an important method I exploit is to continuously replace the AGENTS.md file. Continuous studying remains to be an unsolved downside for LLMs, thus we have to provide you with our personal options to make coding brokers bear in mind our preferences.
I’ve written a guidelines file for my coding agent, which specifies some preferences I’ve:
- At all times write Python 3.13 syntax if utilizing Python
- By no means use the Any kind
- At all times use sorts and docstrings for features
These are preferences I’ve throughout all of the repositories I contact, and which I thus all the time need my agent to comply with. I like to recommend spending time reflecting by yourself coding guidelines and specifying them to your agent.
Moreover, every time my coding agent makes an error, I assist it right the error and inform the agent to recollect the repair in AGENTS.md. This makes certain the agent avoids this error sooner or later, and easily makes the agent sooner and extra environment friendly.
When you proceed doing this over time, you’ll discover the agent changing into considerably higher and more adept at performing the duties you ask it to carry out. This may very well be:
- Implementing new options
- Fixing bugs
- Checking manufacturing logs
This works so effectively since you’re offering your coding agent with the mandatory context that you simply possess, however you by no means wrote down. By informing the coding agent in AGENTS.md, you present the mannequin essential context for downside fixing.
Be aware that you should utilize any Markdown recordsdata that you simply choose. Claude Code makes use of CLAUDE.md, Warp makes use of WARP.md, and Cursor makes use of .cursorrules. Nonetheless, I discover that almost all coding brokers all the time learn AGENTS.md, which makes it a great file title to retailer agentic reminiscence in.
Present documentation hyperlinks
One other tip is to supply related documentation hyperlinks to the mannequin, or to explicitly inform the mannequin to search out documentation on-line by means of an internet search.
I generally discover that my coding agent is utilizing outdated syntax, for instance, when interacting with the OpenAI API. In these cases, I present the mannequin a hyperlink to the newest OpenAI documentation and inform it to base its code on this.
The issue of coding brokers utilizing outdated code sometimes happens as a result of LLMs have a deadline, which essentially should be earlier than the mannequin was carried out coaching. The cutoff date for any given mannequin may very well be over a yr in the past, during which plenty of API documentation has modified. Thus, it’s essential to verify the mannequin makes use of the newest obtainable documentation by offering it with hyperlinks to those docs.
Coding brokers typically makes use of outdated code due to the mannequin data cutoff. The repair to this downside is to supply the brokers with the newest API documentation
Present IaC stack as context
One other method I make the most of is to supply details about my infrastructure as code (IaC) stack as context to my coding agent. That is extremely helpful when utilizing an agent to take a look at manufacturing logs (which it is best to do).
I began utilizing this system after I observed my agent was spending plenty of time discovering info, such because the names of my database tables. For instance, if the agent needed to search out info from a desk, it first needed to checklist all tables, guess which desk is related, and check out it. If it failed, it must strive a unique desk.
This takes plenty of time and tokens, costing you each effectivity and cash, and is thus one thing it’s worthwhile to keep away from.
To offer my agent with all of the IaC context, I had an agent undergo the entire related IaC repositories and create a single Markdown file containing all related context, for instance, the names of all my database tables. I then present this file as context to my coding agent every time it’s related.
New threads on a brand new context
One other easy method I make the most of is to start out new threads every time I’m coping with new contexts. For instance ,if I simply completed implementing a brand new characteristic, and now need to repair a bug, I virtually all the time begin a brand new thread in Cursor.
The reason being that when implementing the brand new characteristic, the mannequin shops plenty of context that’s utterly irrelevant to fixing the bug. This not solely fills up the mannequin context, however may also act as noise, distracting the mannequin from extra related info.
Thus, every time you’ll be able to, it is best to ensure to start out new threads every time altering contexts. This may very well be after you carried out a brand new characteristic, and need to repair a bug. Or after you mounted a bug, and need to try manufacturing logs together with your agent.
This works effectively as a result of the essential context that ought to be saved throughout threads is saved in AGENTS.md, as I mentioned in an earlier part.
Conclusion
On this article, I’ve lined 4 particular strategies I make the most of to optimize the context of my coding brokers. Using these strategies makes me a considerably extra environment friendly engineer, as a result of my coding brokers can work rather more effectively. I like to recommend attempting out these strategies for your self to search out out in the event that they work effectively for you. Moreover, I like to recommend experimenting with new strategies and approaches your self, which may make you more practical. Everytime you discover your coding brokers are unable to do one thing, it is best to instantly begin ideating and occupied with the best way to make them in a position to carry out such duties.
👉 My Free Assets
🚀 10x Your Engineering with LLMs (Free 3-Day Email Course)
📚 Get my free Vision Language Models ebook
💻 My webinar on Vision Language Models
👉 Discover me on socials:
🧑💻 Get in touch
✍️ Medium

