← Back

Make Your AI Agent Cite the Code

August 20, 2026

We read code more than we write it.

That makes being good at understanding an existing codebase incredibly valuable. And AI agents are good tools for doing that.

People have been querying codebases with AI for quite a while now. One of the recurring concerns is hallucination: the agent gives you an explanation that sounds perfectly reasonable, but doesn't quite match what the code actually does.

Of course, that can happen.

But I realized that one small instruction in the skill I use for exploring the codebase makes a surprisingly big difference.

I have a simple explainer skill. It loads the relevant context about the system and then investigates whatever question I ask it.

The important part is how I ask it to answer.

I require it to:

That changes the quality of the answer significantly.

Instead of simply producing a plausible explanation, the agent has to connect its explanation back to the actual implementation.

And if it cannot find enough evidence for something, I would much rather see:

Could not verify

than a confident guess.

The citations are useful for another reason as well.

When I want to understand something in more detail, I can jump directly from the explanation into the relevant part of the code. The AI answer becomes a map of the implementation rather than a replacement for reading it.

This has made codebase Q&A much more useful for me.

The general principle is simple:

Make the agent separate what it can verify from what it is inferring.

For code, citations to the actual implementation are a very effective way of doing that.

It is a small addition to the prompt, but it makes the output feel much closer to the code - and much easier to trust.