Optimizing Documentation for AI Coding Agents
AI Engineergo watch the original →
the gist
To increase AI agent adoption of a library, move beyond standard SEO by providing hand-written llms.txt files and bundling markdown documentation directly inside the package node_modules.
Documentation Pipeline Strategy
Rather than relying on generic SEO, developers should treat documentation as an agent-facing interface. The most effective approach involves a framework-neutral pipeline that transforms MDX files into agent-optimized formats. Manually curating an llms.txt file is significantly more effective than automated generation, as 40 high-quality, hand-written lines outperform 1,000 lines of noisy, machine-generated content.
Agent-Specific Delivery Methods
Since agents fetch rather than browse, documentation must be accessible via multiple paths to accommodate different agent capabilities:
- Markdown Availability: Serve markdown versions of documentation alongside HTML. Use a
.mdsuffix, content negotiation via headers, or a?mode=agentquery parameter to ensure agents can retrieve the raw content. - In-Package Documentation: Coding agents often rely on local repository context rather than visiting documentation websites. Bundling an
AGENTS.mdfile within thenode_modulesdirectory provides agents with immediate, relevant context, which can reduce token usage by nearly 50% compared to web-based retrieval. - Web MCP Integration: Expose specific tools—such as
search_docs,get_pages, andask_docs—via the Model Context Protocol (MCP) to allow agents to query documentation programmatically.
Testing and Maintenance
Because the landscape of agent-readiness changes rapidly, developers should use testing harnesses like Aura AI to benchmark their documentation surface area. Perfection is unattainable due to the shifting nature of model training and agent behavior; therefore, focus on incremental improvements like providing llms.txt and llms-full.txt files as the baseline for any project.