DEV Community

Francesco Marconi
Francesco Marconi

Posted on

It's Time to Write Docs for Machines First, Then for Humans.

The Architectural Problem: The Limit of Prose in RAG

Traditional technical documentation, optimized for human narrative with its long sentences and articulated paragraphs, represents a structural bottleneck for modern RAG (Retrieval-Augmented Generation) and LLM systems.
When a Large Language Model needs to draw from an extensive knowledge base, it must perform costly semantic inference —a complex reconstruction process— to decipher relationships, hierarchies, and conditional logic hidden within the prose. This effort reduces the consistency of its responses and introduces an avoidable risk of inaccuracies.

The LLM-First Framework: An Action-Compatible Knowledge Base

The LLM-First Documentation framework inverts this priority, focusing on the structural optimization of content. The goal is to transform the knowledge base from narrative text into an action-compatible asset that the LLM can load as a specialized extension.
This approach is built on five principles of context engineering:

  1. Explicit Hierarchical Structure: Rigorous use of headings (H1-H3) as strong signals for conceptual mapping.
  2. Semantic Anchor Terms: Repeating specific keywords to create semantic redundancy and ensure terminological consistency.
  3. Structured Formats: Replacing prose with tables, bullet points, and lists to explicitly encode parameters, dependencies, and constraints.
  4. Explicit Usage Constraints: Mandatory sections like "Use when / Don't use when" to provide clear, actionable decision-making logic.
  5. Context Isolation: Self-contained and clearly-defined code blocks with language tags and scenario labels.

The Strategic Advantage: Deterministic Lookup

The crucial benefit lies in eliminating inference in favor of deterministic information retrieval.
When an LLM encounters a text formatted with LLM-First principles, it doesn't need to spend tokens and processing time deducing knowledge. Instead, the consistent use of tables, lists, and headers prompts the model to interpret the structure as an implicit schema (similar to JSON or YAML) within its context window.
This allows the model to perform a pattern-matching and direct lookup operation, rather than a complex semantic analysis. The resulting output is faster, more consistent, and less prone to the model's random variations.

Empirical Evidence: A Concrete Increase in Accuracy

We conducted a controlled benchmark, codenamed the "Lyra Saga," comparing a complex narrative text ("Human-First") with its structured version based on LLM-First principles. The test protocol measured the accuracy of responses on tasks involving detail recall and conditional logic.
The results show a concrete increase in response accuracy. Our analysis demonstrated that the LLM-First format boosts performance by eliminating the omissions and ambiguities typical of narrative prose.

Benchmark Results

The analysis shows that the LLM-First format increases performance, eliminating the omissions and ambiguities typical of narrative prose.

Cross-Model Validation and Trade-offs

Tests were conducted on three high-end models:

Gemini 2.5 Flash / 2.5 Pro

  • Human-First: 94.2% | LLM-First: 100%
  • Δ Accuracy: +5.8% | Δ Efficiency: +40%

Claude 4.5 Sonnet

  • Human-First: 98.8% | LLM-First: 94.9%
  • Δ Accuracy: -3.9% | Δ Efficiency: +40%

Key Insights:

For mid-range models (Gemini, Llama, GPT-3.5):
✅ HUGE benefit in accuracy (+5-8%)
✅ HUGE benefit in efficiency (-40% tokens/cost)

For top-tier models (Claude Opus, GPT-4):
⚠️ Accuracy is already near-ceiling (98%+)
✅ PRIMARY benefit is in efficiency (-40% tokens/cost)
✅ More deterministic responses

For technical documentation (vs. narrative):
✅ ALWAYS a positive benefit (no trade-off)
✅ Omitted narrative details are irrelevant for technical tasks

Cross-Model Analysis

The results show the primary benefit shifts from accuracy (for mid-range models) to efficiency and determinism (for top-tier models), but the advantage remains significant across the board for technical content.

Future Perspectives: Tool-as-Prompt and Automated Validation

The framework's manifesto itself can be used as a self-referential Tool-as-Prompt: instruct the LLM to read the LLM-First principles and immediately apply them to convert your existing documentation.

  # Analyze the documentation from the repo
  https://github.com/fra00/llm-first-documentation
  # Now, apply these principles to convert the following documentation:
  [insert your existing documentation here]
  # // The LLM "learns" the framework and immediately applies it to your knowledge base.
Enter fullscreen mode Exit fullscreen mode

This self-conversion concept is the first step toward adoption.
The framework is formalized in the "LLM-First Documentation Specification v0.2," which includes compliance levels (L1-L3) and objective validation metrics (Coverage and Consistency).

Top comments (0)