Machine Learning

How to Code AI Content

of your agent's AI code is critical to its performance. It is probably one of the most important factors that determine how many jobs you can do with a coding agent and your success rate in doing so.

In this article, I'll discuss some techniques I use to improve the context of my AI agents. I will explain exactly how I do it, and why. It's important to understand why I use these strategies, so you can start developing your strategies in the future, and really improve your agent writing.

This infographic highlights the main strategies I'll cover in this article, which you can use to make your writing agents more efficient. First, I'll discuss how you should review AGENTS.md with the context of the entire thread. In addition, I will discuss how you should provide links to documents and provide the IaC stack as context. Finally, I'll also cover why you should always start new threads whenever you're working on new situations. Photo by Gemini.

Content

Why configure the agent context

The context you give your coding agent is all the information it has to complete the job. Therefore, managing your context is very important if you want your coding agent to perform well.

Improving your core by just a few percent will have a huge impact on your efficiency as a developer if you spend hours programming each day. So I spend a lot of time, always trying to improve my programs with my coding agent.

The four strategies that I will present in the next section are the result of my exploration of a variety of different strategies and methods. In this article, I will only cover the four most important strategies and why they work so well. Next time, I might include some strategies that failed and think about why they didn't work

4 specific strategies

In this section, I'll cover four specific techniques I use to improve the context of my coding agents. I haven't written the strategies out of order, and I consider them important to me in my quest to become the best developer possible.

Always update AGENTS.md

Perhaps the most important method I use is to regularly update the AGENTS.md file. Continuous learning is still an unsolved problem in LLMs, so we need to come up with our own solutions to make coding agents remember our choices.

I wrote a rules file for my code agent, which specifies some preferences I have:

  • Always write Python 3.13 syntax when using Python
  • Never use Any type
  • Always use types and docstrings in functions

These are the favorites that I have from all the archives that I contact, and that I always want my agent to follow. I recommend that you spend some time thinking about your coding rules and clarifying them to your agent.


In addition, whenever my coding agent makes a mistake, I help him correct the mistake and tell the agent to remember the correction in AGENTS.md. This ensures that the agent avoids this error in the future, and simply makes the agent faster and more efficient.

If you continue to do this over time, you will notice that the agent gets better and better at doing the tasks you ask them to do. This could be:

  • Using new features
  • Fixing bugs
  • Inspects production logs

This works very well because you provide your coding agent with the necessary context that you have, but never written down. By introducing the code agent to AGENTS.md, you give the model an important context for solving problems.

Note that you can use any Markdown files you like. Claude's code uses CLAUDE.md, Warp uses WARP.md, and Cursor uses .cursorrules. However, I find that most coding agents always read AGENTS.md, which makes it a good filename to store the agent's memory in.

Another tip is to provide links to relevant documents in the model, or explicitly tell the model to find documents online by searching the web.

Sometimes I find that my coding agent uses primitive syntax, for example, when interacting with the OpenAI API. In these cases, I give the model a link to the latest OpenAI documentation and tell it to base its code on this.

The problem of coding agents using outdated code often arises because LLMs have an expiration date, which should be before the model is trained. The expiration date for any given model may be more than a year ago, when a lot of the API documentation has changed. Therefore, it is very important to make sure that the model uses the latest documentation available by providing it with links to these documents.

Coding agents often use out-of-date code due to deprecation of the information model. The fix for this problem is to provide agents with the latest API documentation

Provide the IaC stack as context

Another method I use is to provide information about my infrastructure as a code stack (IaC) as context to my coding agent. This is incredibly useful if you're using an agent to scan production logs (which you should).

I started using this technique after I noticed that my agent was spending a lot of time finding information, such as table names in my database. For example, if an agent wanted to find information in a table, it had to first list all the tables, guess which table is important, and then try. If it fails, it must try a different table.

This takes a lot of time and tokens, costs you both efficiency and money, and thus is something you need to avoid.

To give my agent all the IaC context, I had the agent go through all the relevant IaC repositories and create a single Markdown file containing all the relevant context, for example, the names of all the tables in my database. I then provide this file as context to my coding agent whenever it is relevant.

New threads in a new context

Another simple technique I use is to start a new thread whenever I am faced with new situations. For example, when I finish implementing a new feature, and now I want to fix a bug, I almost always start a new thread on Cursor.

The reason is that when a new feature is used, the model retains a lot of context that is completely unrelated to debugging. This not only fills the context of the model, but can also act as noise, distracting the model from the most relevant information.

So, whenever you can, you should make sure to start new threads whenever you change the content. This can happen after you use a new feature, and you want to fix the error. Or after debugging, and you want to check production logs with your agent.

This works well because the important context that needs to be stored for every thread is stored in AGENTS.md, as I discussed in the previous section.

The conclusion

In this article, I've covered four specific strategies I use to improve the content of my coding agents. Using these methods makes me a more efficient developer, because my coding agents can be more efficient. I recommend that you try these methods to see if they work well for you. In addition, I recommend that you try new techniques and methods yourself, which can help you be more successful. Whenever you see your code agents can't do something, you should immediately start thinking and thinking about how you can enable them to perform such tasks.

πŸ‘‰ My Free Resources

πŸš€ 10x Your Engineering with LLMs (Free 3-Day Email Course)

πŸ“š Get my free ebook Vision Language Models

πŸ’» My webinar on Vision Language Models

πŸ‘‰ Find me on social media:

πŸ“© Subscribe to my newsletter

πŸ§‘β€πŸ’» Contact

πŸ”— LinkedIn

🐦 X / Twitter

✍️ In the middle

Source link

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button