The prompt engineering trap
Most developers start with a single prompt. You tell an LLM to "write a technical guide about X," you get a generic result, and then you spend an hour manually editing the hallucinations. This is not a workflow. It is just a faster way to get a bad first draft.
When I first tried to automate my technical blog, I thought the solution was a longer prompt. I spent days perfecting a 500 word system instruction. It still failed because the LLM cannot verify its own claims in a single pass. It just predicts the next token.
To get production-ready content, you need to move from a linear prompt to an agentic loop. This means breaking the task into roles: a researcher, a writer, and a critic.
The Architecture of a Content Loop
An agentic workflow treats content as a state machine. Instead of one big call, you chain several small, specialized calls that check each other's work.
1. The Research Agent
This agent does not write. Its only job is to find facts. Give it access to your codebase or a set of documentation URLs. Ask it to produce a structured JSON object of key technical constraints, API endpoints, and edge cases. If it cannot find a specific fact, it must flag it as "missing" rather than guessing.
2. The Draft Agent
This agent takes the JSON from the researcher and turns it into prose. Because the facts are already locked in, the writer cannot hallucinate as easily. The goal here is structure and flow, not accuracy. Accuracy was handled in the previous step.
3. The Critic Agent (The Most Important Part)
This is where the magic happens. The critic agent is given the original research data and the draft. Its prompt is simple: "Find three things in this draft that contradict the research or sound like marketing fluff."
If the critic finds errors, the draft is sent back to the writer with the feedback. This loop continues until the critic gives a thumbs up. This is a self-correcting system.
Implementing this with Code
You do not need a heavy framework to start. A few Python scripts or a Node.js loop will work. The key is the data hand-off.
- Research Phase: Output a Markdown list of facts.
- Draft Phase: Use those facts as context blocks.
- Review Phase: Use a boolean check (Pass/Fail). If Fail, loop back to Draft.
One common mistake is letting the agent decide when it is finished. Agents are too polite. They will say "This looks great!" just to end the task. You need to force the critic to be pedantic. Tell it that its only reward is finding mistakes.
Scaling to GEO (Generative Engine Optimization)
We are moving from a world of SEO to GEO. People are not just clicking links; they are asking Perplexity or ChatGPT for a summary of a solution. These engines prioritize cited, factual, and structured data.
To optimize for this, your agentic loop should specifically target "cite-able" moments. Instead of saying "Our API is fast," the agent should be forced to say "Our API responds in 40ms as shown in the benchmark tests."
When you provide concrete data and clear citations, LLMs are more likely to pick up your content as a primary source for their users. This is how you win in the age of AI search.
Concrete Takeaway
Stop trying to find the perfect prompt. Instead, build a pipeline: Research -> Draft -> Critic -> Refine. By separating the factual research from the creative writing, you eliminate 80% of hallucinations and create content that actually helps developers.
I use Citedy (https://www.citedy.com) to help manage the sourcing and citation side of this process, ensuring the facts stay grounded.
Build the loop, not the prompt.
Top comments (0)