Add llms.txt for AI documentation discovery#408
Open
dariye wants to merge 7 commits intoruby-ui:mainfrom
Open
Conversation
Adds /llms.txt following the llms.txt specification (llmstxt.org) so that LLMs can discover and reference RubyUI component documentation at inference time. Includes a rake task (rake llms:generate) to regenerate the file from doc view sources when components are added or removed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Refactor generation logic from rake task into a standalone LlmsTxtGenerator class in lib/ for testability. The rake task now delegates to the class. Regenerate public/llms.txt from the generator (alphabetical sort within categories, exact descriptions from source). 31 tests covering: - Header extraction (string titles, variable titles, fixtures) - Component collection (categories, counts, structure) - Content generation (sections, URLs, sorting, spec compliance) - File writing (output, idempotency, sync check) - llms.txt spec compliance (H1, blockquote, H2 sections, link format) - Route cross-validation (all 52 URL slugs verified) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a /docs/llms_txt page explaining what llms.txt is, how to use it with AI tools, and how to regenerate it. Linked as the last item in the Getting Started sidebar section, similar to how shadcn/ui surfaces their AI documentation. - Route: GET /docs/llms_txt - View: app/views/docs/getting_started/llms_txt.rb - Controller action: docs#llms_txt - Sidebar: last entry in Getting Started links - Updated llms.txt generator and public/llms.txt to include the new page Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move llms.txt from a committed static file to build-time generation. The rake task hooks into assets:precompile so Heroku and Docker builds produce it automatically. No manual step needed on deploy. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Track component_count in generate instead of re-parsing all files - Replace hardcoded 45 with CATEGORIES.size so tests adapt to new components - Remove stale development comment Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The llms.txt page explains what llms.txt is — that's for humans, not LLMs consuming the file. Omit it to avoid the circular reference. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/llms.txtfollowing the llms.txt specification so LLMs can discover and reference RubyUI component documentation at inference timellms.txtduringassets:precompile— Heroku and Docker builds produce it automatically with no manual steprake llms:generatetask for local developmentWhat is llms.txt?
llms.txt is a proposed standard for providing LLM-friendly documentation at
/llms.txt. It uses Markdown to structure site content in a way that's easy for AI models to parse at inference time. Major projects like shadcn/ui, Anthropic, Stripe, and Cloudflare have adopted it.How it works
The
LlmsTxtGeneratorclass (lib/llms_txt_generator.rb) parsesDocs::Header.new(title:, description:)from view files inapp/views/docs/and produces the llms.txt content. The rake task inlib/tasks/llms_txt.rakehooks intoassets:precompileviaRake::Task["assets:precompile"].enhance, so every deploy generates a freshpublic/llms.txtautomatically.assets:precompiletriggersllms:generate— no manual steprake llms:generateto regeneratepublic/llms.txtis gitignored (generated artifact, not source)Preview of generated
llms.txtTest plan
rake llms:generate— generatespublic/llms.txtwith 45 componentsruby -Itest test/lib/llms_txt_generator_test.rb— 31 tests, 287 assertions, 0 failuresrake assets:precompileto confirm llms.txt is generated as part of the build/llms.txtis served in development after generation🤖 Generated with Claude Code