Skip to content

feat: add /llms.txt endpoints for LLM-friendly documentation#2674

Open
claw-explorer wants to merge 1 commit into
freeCodeCamp:mainfrom
claw-explorer:feat/llms-txt-endpoint
Open

feat: add /llms.txt endpoints for LLM-friendly documentation#2674
claw-explorer wants to merge 1 commit into
freeCodeCamp:mainfrom
claw-explorer:feat/llms-txt-endpoint

Conversation

@claw-explorer

Copy link
Copy Markdown

Summary

Adds two new routes that serve LLM-friendly plain text documentation following the llms.txt specification:

  • GET /llms.txt — Returns a top-level index of all available documentation with links to each doc section.
  • GET /:doc/llms.txt — Returns a per-documentation index with all entries grouped by type, linking to individual pages.

Format

The output follows the llms.txt standard:

# DevDocs

> DevDocs combines multiple API documentations in a fast, organized, and searchable interface.

## Documentation

- [CSS](https://devdocs.io/css/)
- [JavaScript](https://devdocs.io/javascript/)
...

Per-doc endpoints group entries by type:

# JavaScript

> JavaScript documentation on DevDocs.

## Array

- [Array.from()](https://devdocs.io/javascript/global_objects/array/from)
- [Array.isArray()](https://devdocs.io/javascript/global_objects/array/isarray)
...

## Promise

- [Promise.all()](https://devdocs.io/javascript/global_objects/promise/all)
...

Why

LLM tools and AI-powered development environments need efficient, structured access to documentation. The llms.txt standard (used by FastHTML, Context7, and others) provides a lightweight way to expose documentation in a format that works well with fixed-context-window LLMs.

Implementation

  • Routes are defined before the catch-all doc route to avoid conflicts
  • Uses existing settings.docs manifest and per-doc index.json files
  • No new dependencies required
  • Served as text/plain with Markdown formatting

Closes #2520

Add two new routes that serve LLM-friendly plain text documentation
following the llms.txt specification (https://llmstxt.org/):

- GET /llms.txt - Returns a top-level index of all available
  documentation with links to each doc section.

- GET /:doc/llms.txt - Returns a per-documentation index with
  all entries grouped by type, linking to individual pages.

The format follows the llms.txt standard:
- Title as a Markdown heading
- Description as a blockquote
- Sections with links in Markdown format

This enables LLM tools and AI-powered development environments
to efficiently discover and reference DevDocs documentation.

Closes freeCodeCamp#2520
@claw-explorer
claw-explorer requested a review from a team as a code owner April 2, 2026 20:21
@simon04
simon04 requested a review from Copilot July 22, 2026 20:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds new llms.txt endpoints to expose DevDocs documentation indexes in an LLM-friendly plain-text (Markdown) format, using the existing docs manifest and per-doc index.json data.

Changes:

  • Add GET /llms.txt to list all available docs with links.
  • Add GET /:doc/llms.txt to emit a per-doc, type-grouped list of entries linking to individual pages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/app.rb
Comment on lines +309 to +319
lines = []
lines << '# DevDocs'
lines << ''
lines << '> DevDocs combines multiple API documentations in a fast, organized, and searchable interface.'
lines << ''
lines << '## Documentation'
lines << ''

settings.docs.each do |slug, doc|
lines << "- [#{doc['full_name']}](https://devdocs.io/#{slug}/)"
end
Comment thread lib/app.rb
end

get %r{/([\w~\.%]+)/llms\.txt} do |doc|
doc.sub! '%7E', '~'
Comment thread lib/app.rb
lines << ''
entries.each do |entry|
path = entry['path'].to_s.split('#').first
lines << "- [#{entry['name']}](https://devdocs.io/#{@doc['slug']}/#{path})"
Comment thread lib/app.rb
else
(index['entries'] || []).each do |entry|
path = entry['path'].to_s.split('#').first
lines << "- [#{entry['name']}](https://devdocs.io/#{@doc['slug']}/#{path})"
Comment thread lib/app.rb
Comment on lines +330 to +333
index_path = File.join(settings.docs_path, @doc['slug'], 'index.json')
return 404 unless File.exist?(index_path)

index = JSON.parse(File.read(index_path))
Comment thread lib/app.rb

# llms.txt - LLM-friendly documentation index
# See https://llmstxt.org/ for the specification
get '/llms.txt' do
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

llms.txt end points for each doc route

2 participants