Convert your Retype documentation into a single, LLM-friendly file that AI assistants can actually understand.
Documentation is great for humans browsing your site, but terrible for AI assistants trying to help your users. This tool bridges that gap by compiling your Retype markdown files into llms.txt - a structured format that LLMs can parse and reference accurately.
The script respects your Retype configuration, preserves your routing structure, and converts relative links to absolute URLs so AI assistants can cite your docs properly.
- XML-structured output that LLMs parse reliably
- Accurate routing matching your Retype site (permalink, route, default files)
- Absolute URLs for all images and links when you set a base URL
- Clean content with front-matter stripped out
- Smart filtering that skips static assets, node_modules, and git files
The generated file lands in your static/ folder, ready to serve alongside your docs.
# Clone and install
git clone https://github.com/zakaria-chahboun/retype_llms.git
cd retype_llms
pip install pyyaml
# Run from your Retype project root
python llms.py
# Or specify your docs folder
python llms.py docsYou'll see output like this:
🔍 Checking for Retype project...
📂 Retype input directory from retype.yml: source
📚 Processing markdown files:
→ source/getting-started.md
→ source/api/authentication.md
→ source/guides/webhooks.md
✅ Done!
📖 Total files: 24
📝 Total words: 12,847
🤖 Estimated tokens: 16,701
🚀 Saved to: source/static/llms.txt
Drop this into .github/workflows/llms.yml:
name: Generate llms.txt
on:
push:
branches: [main]
workflow_dispatch:
jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate llms.txt
uses: zakaria-chahboun/retype_llms@v3.0.1
- name: Commit changes
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git add -A
git diff --quiet && git diff --staged --quiet || \
(git commit -m "Update llms.txt" && git push)The action runs on every push and keeps your llms.txt in sync automatically.
Combine it with your existing Retype workflow:
name: Publish Documentation
on:
push:
branches: [main]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate llms.txt
uses: zakaria-chahboun/retype_llms@v3.0.1
- name: Build Retype
uses: retypeapp/action-build@latest
- name: Deploy to GitHub Pages
uses: retypeapp/action-github-pages@latest
with:
update-branch: trueThe script reads your retype.yml to figure out where things are:
input: docs # Where your markdown lives
url: https://docs.example.com # Your site's base URL (optional but recommended)Base URL Benefits: When you provide a URL, the script converts all relative links and images to absolute ones. This means AI assistants can reference https://docs.example.com/static/diagram.png instead of just static/diagram.png.
Override the input directory if needed:
CLI:
python llms.py sourceGitHub Action:
- uses: zakaria-chahboun/retype_llms@v3.0.1
with:
source: docsPriority order: CLI/Action input → retype.yml → current directory
The generated llms.txt uses clean XML structure:
<document>
<title>Getting Started</title>
<url>https://docs.example.com/getting-started/</url>
<content>
# Getting Started
Your markdown content here, exactly as written.
Images and links are converted to absolute URLs.
</content>
</document>
<document>
<title>API Reference</title>
<url>https://docs.example.com/api/</url>
<content>
# API Reference
More content...
</content>
</document>What happens to your content:
- Front-matter (YAML between
---) gets stripped - Document title comes from front-matter
title:or filename - Relative links become absolute when base URL is set
- Everything else stays exactly as you wrote it
The script matches Retype's routing logic:
- Explicit routes win: Files with
permalinkorroutein front-matter use those values - Special files become indexes:
index.md,readme.md,welcome.mdmap to their directory (/docs/not/docs/readme/) - Everything else gets slugified: Spaces become dashes, special chars get stripped, just like Retype does it
Examples:
docs/Getting Started.md→/docs/getting-started/docs/api/index.md→/docs/api/docs/Advanced Topics.mdwithpermalink: /advanced/→/advanced/
- Python 3.6 or newer
- PyYAML (
pip install pyyaml) - A Retype project with
retype.yml
github.com/zakaria-chahboun/retype_llms
Found a bug? Have an idea? Open an issue or PR.
