Home / Companies / Fern / Blog / Post Details
Content Deep Dive

How to write LLM-friendly documentation in March 2026

Blog post from Fern

Post Details
Company
Date Published
Author
Nathan Lian @ Maintouch
Word Count
1,974
Language
English
Hacker News Points
-
Summary

Documentation optimized for AI agents significantly enhances the efficiency and accuracy of AI coding assistants like GitHub Copilot and Cursor by serving markdown directly, rather than HTML, which reduces token consumption by over 90%. This approach not only supports AI agents by maintaining structured, machine-readable formats but also retains the full HTML browsing experience for human users. The use of llms.txt files provides a structured index for AI tools, facilitating the automatic retrieval of documentation content, while techniques like content negotiation ensure markdown is served to AI agents without any configuration changes. Implementing controlled visibility with tags like <llms-only> and <llms-ignore>, along with maintaining consistent heading hierarchies, helps AI agents accurately parse and retrieve necessary information, thereby preventing errors like "hallucinations" in generated code. Additionally, the use of machine-readable API specifications ensures type safety and accuracy, with version control systems like Git maintaining synchronization between documentation and API changes, eliminating the risk of AI agents generating outdated or incorrect code.