llms.txt Generator
Produces a single self-contained Markdown doc following the llms.txt convention: H2 per concept, 1-3 sentence explanation + one annotated code example, token-budgeted, ending with a Summary. Each H2 is an independent retrieval unit — usable as RAG source (NotebookLM, vector DBs, agent context) or standalone reference.
Execution Flow
| Signal |
Mode |
Source |
GitHub URL or org/repo |
Remote |
Fetch via GitHub raw |
| No URL, agent in codebase |
Local |
Scan cwd for docs |
If ambiguous, ask.
PHASE 1 — Source Discovery
Find docs describing the library/codebase concepts, API surface, usage patterns.
Remote mode
- Determine org, repo, optional version tag.
- Sparse-clone docs:
git clone --depth 1 --filter=blob:none --sparse https://github.com/{org}/{repo}.git /tmp/llms-gen-{repo}
cd /tmp/llms-gen-{repo}
git sparse-checkout set docs/ README.md CHANGELOG.md
# For specific tag: git fetch --depth 1 origin tag {version} && git checkout {version}
- If no
docs/, fall back to: README.md, wiki/, pages/, content/, src/ (inline JSDoc/docstrings), or any doc-like dir.
- List all
.md, .mdx, .rst, .txt. Discard changelogs, contribution guides, CI docs unless requested.
Local mode
- Scan cwd:
find . -type f \( -name "*.md" -o -name "*.mdx" -o -name "*.rst" \) \
! -path "*/node_modules/*" ! -path "*/vendor/*" ! -path "*/.git/*" \
! -path "*/dist/*" ! -path "*/build/*" | head -100
- Also scan: README at any depth, inline source docs (JSDoc, docstrings),
docs/ or documentation/ dirs.
- Identify project name from
package.json, pyproject.toml, Cargo.toml, go.mod, or root dir name.
- Identify version from same manifest or git tags.
Output: doc file paths ranked by relevance (README → guides → API reference → examples).
PHASE 2 — Topic Extraction
Build the concept list — the H2 sections.
How to extract
- Doc structure: Each top-level doc file or major H2 is a candidate. Sidebar/nav files (
_sidebar.md, _meta.json, mkdocs.yml, docusaurus.config.js) give author's intended hierarchy — gold.
- README structure: H2s often map to core concepts.
- Source code (when docs thin): exported modules, classes, CLI commands, route definitions.
Selection criteria
- Core concept user hits in week one → Include
- Advanced/niche → Include only if budget allows
- Installation/setup → Include only if non-trivial
- Deprecated → Exclude
- Internal/implementation → Exclude
Ordering
- What it IS (overview)
- Getting started / installation (if non-trivial)
- Core concepts in dependency order (routing before middleware)
- Data flow / state
- Integration points
- Advanced patterns
- Configuration reference
Output: ordered list of 8-25 topics, each with pointer to source chunk(s).
PHASE 3 — Per-Section Synthesis
For each topic, produce one Markdown section.
Section format (strict)
## {Topic Name}
{1-3 sentences: what it is, when to use it, one key thing to know.}
```{language}
// Annotated code — complete enough to copy-paste
// Inline comments only for non-obvious lines
// OPTIONAL second block — only when concept genuinely spans two
// languages or distinct contexts (.env file + tsx usage; reading
// vs. writing cookies in separate server contexts)
### Synthesis rules
1. **Explanation**: 1-3 sentences. First says what it is. Following say when/why or key gotcha. No "In this section we'll explore..."
2. **Code example**: One primary fenced block. Optional second only when concept genuinely spans two languages or contexts.
- **Complete**: copy-pastable, not cryptic, no boilerplate
- **Annotated**: inline comments only on non-obvious lines (don't comment `import React from 'react'`)
- **Runnable** where possible
- **Current**: pinned-version APIs, no deprecated
- **Idiomatic**: follow library's own conventions
3. **Exclude per section**:
- Installation steps (unless topic IS setup)
- More than two code blocks
- Prose beyond 3 sentences
- External links
- Deprecated APIs
- Type definitions unless they ARE the concept
### Token budget per section
Given total `T` and `N` sections:
- Header + overview: ~300 tokens (two paragraphs for complex frameworks)
- Summary: ~200 tokens
- Each topic: ~`(T - 500) / N`
- Code-heavy sections borrow from prose-light
- If a section can't be meaningful in budget, combine or drop
---
## PHASE 4 — Assembly
### Document structure
```markdown
# {Library/Project Name}
{Overview para 1: what it is, core paradigm/architecture, most important thing about current version.}
{Overview para 2 (optional, complex frameworks): capabilities, rendering model, or DX context.}
## {Topic 1}
{explanation + code}
## {Topic 2}
{explanation + code}
...
## Summary
{1-2 paragraphs tying concepts: how pieces compose into typical architecture, which APIs for common scenarios, key integration patterns. RAG anchor — gives retriever a "how pieces fit" chunk.}
Assembly rules
- H1 = library/project name, nothing else.
- Overview = 2-3 sentences for simple libs, two short paragraphs for complex frameworks. Answers: "What is it and why does it matter?"
- Sections separated by single blank line. No HRs, no extra spacing.
- No TOC — H2s ARE the TOC for RAG chunking.
- No metadata, frontmatter, preamble. Doc starts with
# Name.
- Final
## Summary required. 1-2 paragraphs.
- Should feel written by a senior dev who uses the library daily.
Budget enforcement
Estimate tokens (word_count * 1.3). If over:
- Trim obvious code comments
- Shorten explanations to 1 sentence
- Drop lowest-priority sections from bottom
- Last resort: merge related sections
PHASE 5 — Output
File naming
- User-specified: use it
- Library default:
{library-name}.llms.txt (e.g., next-js.llms.txt)
- Local codebase default:
llms.txt at repo root
- Alt:
{name}.context.md if user prefers .md
Save location
- In a codebase: repo root (or
docs/ if exists)
- External use: save to
/home/claude/ and present to user
- Always copy final to
/mnt/user-data/outputs/ for download
Parameters
| Parameter |
Default |
Description |
| Token budget |
10,000 |
5K focused / 10K standard / 20K comprehensive |
| Version |
latest |
Git tag, branch, or latest |
| Language |
auto-detect |
Primary code language |
| Topic filter |
all |
Comma-separated topics (e.g., "routing, data-fetching, auth") |
| Code density |
balanced |
code-heavy / info-heavy |
"make it short" → 5K. "Give me everything" → 20K. "Focus on routing and auth" → topic filter.
Quality Checklist
Examples
GitHub URL: "Generate an llms.txt for https://github.com/supabase/supabase"
→ Remote → sparse clone → docs in apps/docs/ → topics (Auth, Database, Storage, Realtime, Edge Functions) → synthesize → 10K → supabase.llms.txt
Inside codebase: "Create an LLM-friendly reference for this project"
→ Local → scan docs + source → project name from package.json → topics from README H2s + source modules → synthesize → llms.txt at repo root
Focused output: "Generate context docs for Next.js, just routing and data fetching, under 5K"
→ Remote → fetch Next.js docs → filter → 5K budget → next-js.llms.txt
Edge Cases
- No docs: Fall back to README + source. Generate sections from exported APIs, CLI commands, classes. Warn user about source-comment dependence.
- Auto-generated API reference only: Group related endpoints/methods into conceptual sections rather than listing every method.
- Monorepo: Ask which package, or generate one doc per package.
- Non-English docs: Generate in source language unless user specifies.
- Budget too small for topic count: Prioritize core, drop advanced, tell user what was excluded.
1---2name: llms-txt-generator3description: Generate llms.txt-style context documents — token-budgeted, section-per-concept Markdown optimized for LLM and RAG consumption. Use this skill whenever someone asks to generate an llms.txt, create LLM-friendly documentation, produce a context document for a library or codebase, build a RAG-ready reference, make docs 'agent-readable', create a developer quick-reference, or says anything like 'generate context for X', 'make an llms.txt for this repo', 'create a reference doc for NotebookLM', 'turn these docs into something an LLM can use', 'context document', 'developer cheatsheet from docs'. Also trigger when someone provides a GitHub repo URL and asks for documentation synthesis, or when working inside a codebase and asked to produce a self-contained reference of how it works. This is the context engineer's doc generation tool — it turns sprawling documentation into precise, structured, token-efficient context.4---56# llms.txt Generator78Produces a single self-contained Markdown doc following the `llms.txt` convention: H2 per concept, 1-3 sentence explanation + one annotated code example, token-budgeted, ending with a Summary. Each H2 is an independent retrieval unit — usable as RAG source (NotebookLM, vector DBs, agent context) or standalone reference.910---1112## Execution Flow1314| Signal | Mode | Source |15|--------|------|--------|16| GitHub URL or `org/repo` | **Remote** | Fetch via GitHub raw |17| No URL, agent in codebase | **Local** | Scan cwd for docs |1819If ambiguous, ask.2021---2223## PHASE 1 — Source Discovery2425Find docs describing the library/codebase concepts, API surface, usage patterns.2627### Remote mode28291. Determine org, repo, optional version tag.302. Sparse-clone docs:3132```bash33git clone --depth 1 --filter=blob:none --sparse https://github.com/{org}/{repo}.git /tmp/llms-gen-{repo}34cd /tmp/llms-gen-{repo}35git sparse-checkout set docs/ README.md CHANGELOG.md36# For specific tag: git fetch --depth 1 origin tag {version} && git checkout {version}37```38393. If no `docs/`, fall back to: `README.md`, `wiki/`, `pages/`, `content/`, `src/` (inline JSDoc/docstrings), or any doc-like dir.404. List all `.md`, `.mdx`, `.rst`, `.txt`. Discard changelogs, contribution guides, CI docs unless requested.4142### Local mode43441. Scan cwd:4546```bash47find . -type f \( -name "*.md" -o -name "*.mdx" -o -name "*.rst" \) \48 ! -path "*/node_modules/*" ! -path "*/vendor/*" ! -path "*/.git/*" \49 ! -path "*/dist/*" ! -path "*/build/*" | head -10050```51522. Also scan: README at any depth, inline source docs (JSDoc, docstrings), `docs/` or `documentation/` dirs.533. Identify project name from `package.json`, `pyproject.toml`, `Cargo.toml`, `go.mod`, or root dir name.544. Identify version from same manifest or git tags.5556**Output**: doc file paths ranked by relevance (README → guides → API reference → examples).5758---5960## PHASE 2 — Topic Extraction6162Build the concept list — the H2 sections.6364### How to extract65661. **Doc structure**: Each top-level doc file or major H2 is a candidate. Sidebar/nav files (`_sidebar.md`, `_meta.json`, `mkdocs.yml`, `docusaurus.config.js`) give author's intended hierarchy — gold.672. **README structure**: H2s often map to core concepts.683. **Source code** (when docs thin): exported modules, classes, CLI commands, route definitions.6970### Selection criteria7172- Core concept user hits in week one → Include73- Advanced/niche → Include only if budget allows74- Installation/setup → Include only if non-trivial75- Deprecated → Exclude76- Internal/implementation → Exclude7778### Ordering79801. What it IS (overview)812. Getting started / installation (if non-trivial)823. Core concepts in dependency order (routing before middleware)834. Data flow / state845. Integration points856. Advanced patterns867. Configuration reference8788**Output**: ordered list of 8-25 topics, each with pointer to source chunk(s).8990---9192## PHASE 3 — Per-Section Synthesis9394For each topic, produce one Markdown section.9596### Section format (strict)9798```markdown99## {Topic Name}100101{1-3 sentences: what it is, when to use it, one key thing to know.}102103```{language}104// Annotated code — complete enough to copy-paste105// Inline comments only for non-obvious lines106```107108```{language}109// OPTIONAL second block — only when concept genuinely spans two110// languages or distinct contexts (.env file + tsx usage; reading111// vs. writing cookies in separate server contexts)112```113```114115### Synthesis rules1161171. **Explanation**: 1-3 sentences. First says what it is. Following say when/why or key gotcha. No "In this section we'll explore..."1182. **Code example**: One primary fenced block. Optional second only when concept genuinely spans two languages or contexts.119 - **Complete**: copy-pastable, not cryptic, no boilerplate120 - **Annotated**: inline comments only on non-obvious lines (don't comment `import React from 'react'`)121 - **Runnable** where possible122 - **Current**: pinned-version APIs, no deprecated123 - **Idiomatic**: follow library's own conventions1243. **Exclude per section**:125 - Installation steps (unless topic IS setup)126 - More than two code blocks127 - Prose beyond 3 sentences128 - External links129 - Deprecated APIs130 - Type definitions unless they ARE the concept131132### Token budget per section133134Given total `T` and `N` sections:135- Header + overview: ~300 tokens (two paragraphs for complex frameworks)136- Summary: ~200 tokens137- Each topic: ~`(T - 500) / N`138- Code-heavy sections borrow from prose-light139- If a section can't be meaningful in budget, combine or drop140141---142143## PHASE 4 — Assembly144145### Document structure146147```markdown148# {Library/Project Name}149150{Overview para 1: what it is, core paradigm/architecture, most important thing about current version.}151152{Overview para 2 (optional, complex frameworks): capabilities, rendering model, or DX context.}153154## {Topic 1}155156{explanation + code}157158## {Topic 2}159160{explanation + code}161162...163164## Summary165166{1-2 paragraphs tying concepts: how pieces compose into typical architecture, which APIs for common scenarios, key integration patterns. RAG anchor — gives retriever a "how pieces fit" chunk.}167```168169### Assembly rules1701711. H1 = library/project name, nothing else.1722. Overview = 2-3 sentences for simple libs, two short paragraphs for complex frameworks. Answers: "What is it and why does it matter?"1733. Sections separated by single blank line. No HRs, no extra spacing.1744. No TOC — H2s ARE the TOC for RAG chunking.1755. No metadata, frontmatter, preamble. Doc starts with `# Name`.1766. Final `## Summary` required. 1-2 paragraphs.1777. Should feel written by a senior dev who uses the library daily.178179### Budget enforcement180181Estimate tokens (`word_count * 1.3`). If over:1821. Trim obvious code comments1832. Shorten explanations to 1 sentence1843. Drop lowest-priority sections from bottom1854. Last resort: merge related sections186187---188189## PHASE 5 — Output190191### File naming192193- User-specified: use it194- Library default: `{library-name}.llms.txt` (e.g., `next-js.llms.txt`)195- Local codebase default: `llms.txt` at repo root196- Alt: `{name}.context.md` if user prefers `.md`197198### Save location199200- In a codebase: repo root (or `docs/` if exists)201- External use: save to `/home/claude/` and present to user202- Always copy final to `/mnt/user-data/outputs/` for download203204---205206## Parameters207208| Parameter | Default | Description |209|-----------|---------|-------------|210| Token budget | 10,000 | 5K focused / 10K standard / 20K comprehensive |211| Version | latest | Git tag, branch, or `latest` |212| Language | auto-detect | Primary code language |213| Topic filter | all | Comma-separated topics (e.g., "routing, data-fetching, auth") |214| Code density | balanced | `code-heavy` / `info-heavy` |215216"make it short" → 5K. "Give me everything" → 20K. "Focus on routing and auth" → topic filter.217218---219220## Quality Checklist221222- [ ] Every H2 has one primary code block (and at most one justified second)223- [ ] No explanation > 3 sentences224- [ ] Code uses current APIs in correct language225- [ ] Code is copy-pastable — not cryptic226- [ ] No deprecated patterns227- [ ] Overview accurately describes the project (2-3 sentences or two short paragraphs)228- [ ] `## Summary` present, ties to architecture229- [ ] Total tokens within ±10% of budget230- [ ] Sections in dependency order (no forward references)231- [ ] Self-contained — no broken cross-references232- [ ] No installation unless setup IS the concept233- [ ] Each section independently useful as retrieval unit234235---236237## Examples238239**GitHub URL**: "Generate an llms.txt for https://github.com/supabase/supabase"240→ Remote → sparse clone → docs in `apps/docs/` → topics (Auth, Database, Storage, Realtime, Edge Functions) → synthesize → 10K → `supabase.llms.txt`241242**Inside codebase**: "Create an LLM-friendly reference for this project"243→ Local → scan docs + source → project name from `package.json` → topics from README H2s + source modules → synthesize → `llms.txt` at repo root244245**Focused output**: "Generate context docs for Next.js, just routing and data fetching, under 5K"246→ Remote → fetch Next.js docs → filter → 5K budget → `next-js.llms.txt`247248---249250## Edge Cases251252- **No docs**: Fall back to README + source. Generate sections from exported APIs, CLI commands, classes. Warn user about source-comment dependence.253- **Auto-generated API reference only**: Group related endpoints/methods into conceptual sections rather than listing every method.254- **Monorepo**: Ask which package, or generate one doc per package.255- **Non-English docs**: Generate in source language unless user specifies.256- **Budget too small for topic count**: Prioritize core, drop advanced, tell user what was excluded.