When implementing software through Agents, I usually face two situations: one is the need to generate some temporary tools, and the other is the need to modify existing code.

For the first situation, my approach is to tell the Agent the requirements directly and let it build things for me from scratch, without caring about the code at all from beginning to end. I only focus on whether it gives me the result I want. The premise is that this kind of tool itself is not intended for long-term evolution.

The second situation is modifying an existing project, such as extending new features or doing optimization. In this case, especially when the project is relatively large, simply telling the Agent the task and letting it rely on context to search the codebase for knowledge can easily produce contextual hallucinations. For example:

The direction the Agent implements is different from the effect I want.
It does not fully consider software design principles and forcibly writes in its own set of code.
At this time, there is a very good approach, which is actually also often used in manual coding: write the interface first. Then tell the Agent through a prompt: help me implement the xxx function, at a specific file. At this point, AI will perceive the context very well, because we have already narrowed down the requirements in advance. If appropriate comments are added, the effect may be even better.