Back to Research

Docs That Return Markdown

Why docs return markdown for agents, and how to do it without hurting human readers.

Hero image for Docs That Return Markdown
Rogier MullerMarch 27, 20266 min read

Agentic tools are changing how documentation gets consumed. A useful pattern is showing up: when an agent requests a doc, the system returns markdown instead of a rendered page or a long prose blob. The aim is straightforward. Cut tokens. Cut parsing work. Make the content easier to scan and reuse.

This is not a new document format. It is a delivery choice. The same content can be served in different shapes depending on whether the reader is a person in a browser or an agent in a loop.

That matters because agents do not read like humans. They do better when the structure is explicit, the hierarchy is shallow, and the content avoids visual noise. Markdown is not magic, but it is a practical compromise: readable enough for humans, compact enough for many agent workflows.

Why this pattern is showing up

The main reason is token efficiency. Rendered HTML often carries extra material: navigation, repeated chrome, hidden accessibility text, scripts, and layout scaffolding. Agents usually do not need any of that. They need the answer, the steps, the constraints, and maybe a few examples.

Markdown also makes extraction easier. Headings, lists, code blocks, and links are explicit. A model can often identify the useful parts without stripping presentation layers first. That can help with retrieval, summarization, and task planning.

There is also a maintenance angle. If your docs pipeline already has a structured source, generating a markdown view for agents is often simpler than trying to optimize a full web page for machine consumption.

What to return in markdown

Not every page should be flattened the same way. The useful pattern is to keep the agent view focused on task-relevant content.

  • Keep the main answer first.
  • Preserve headings that reflect the real structure.
  • Keep code blocks intact.
  • Remove navigation, promos, and repeated boilerplate.
  • Keep links if they matter to the task.
  • Avoid decorative callouts that do not change the action.

If the doc is procedural, the agent version should read like a compact runbook. If it is reference material, it should read like a clean spec. If it is a troubleshooting page, the likely failure modes and fixes should be easy to scan.

Implementation patterns that hold up

A practical implementation usually starts with content negotiation or a dedicated agent endpoint. The exact mechanism depends on your stack, but the workflow is similar.

First, detect the request context. That can be a header, a query parameter, a route, or an explicit agent mode in the client. Then serve a markdown representation from the same source of truth.

Second, keep the markdown generated from structured content, not from scraped HTML if you can avoid it. Scraping rendered pages tends to preserve noise and can break when layout changes. A source-driven pipeline is more stable.

Third, test the output against real tasks. Ask an agent to answer a question, follow a setup step, or extract a config example. If the markdown version is shorter but less usable, the token savings may not be worth it.

A simple rollout can look like this:

  • Start with one doc section or one doc family.
  • Add an agent-readable route or format flag.
  • Compare token counts and task success.
  • Keep the human page unchanged.
  • Expand only where the agent version clearly helps.

Tradeoffs and limits

The obvious tradeoff is duplication risk. If you maintain separate human and agent views by hand, they will drift. The safer pattern is one source with two render targets.

Another limit is loss of visual context. Some docs rely on tables, diagrams, or page structure that markdown cannot express well. In those cases, a markdown view may need short textual summaries or links back to the richer page.

There is also a danger of over-optimizing for the model. If the agent view becomes too terse, it can remove the nuance a human reviewer would want later. That is especially true for policy docs, edge cases, and safety constraints.

Finally, markdown is not always the best machine format. For some tasks, JSON or another structured representation may be better. Markdown is a good default when you want a format that both humans and agents can inspect without special tooling.

A practical adoption checklist

If you want to try this pattern, start small and measure it.

  1. Pick one high-traffic doc or one agent-heavy workflow.
  2. Define what the agent actually needs from that page.
  3. Generate a markdown view from the same source content.
  4. Remove navigation, repeated headers, and decorative text.
  5. Test with a real agent task, not a synthetic benchmark only.
  6. Compare token usage, answer quality, and failure rate.
  7. Keep a fallback to the full page when the markdown view is insufficient.

That last step matters. The point is not to replace human documentation. It is to make the same documentation easier to consume in a machine loop.

A small methodology note

This is a good place to Build before you generalize. A narrow implementation on one doc set will show whether markdown delivery actually improves task completion. See our methodology for how we approach that kind of incremental change.

What to watch next

The broader signal here is the move toward docs that adapt to the reader. Agents need compact, structured, low-noise content. Humans still need context, examples, and a page that is easy to navigate.

The teams that do well will probably keep one source of truth and expose different views for different readers. Markdown is just the first practical step many teams are taking because it is simple, familiar, and good enough for a lot of agent workflows.

If you are already seeing agents read your docs, this is worth testing now. The gains are modest but real when the content is repetitive, structured, and frequently queried. The limits show up fast too, which is useful. It keeps the pattern honest.

Want to learn more about Cursor?

We offer enterprise training and workshops to help your team become more productive with AI-assisted development.

Contact Us