sphinx-llm
AGENTS.md44 starsChanged 4 months agoApache-2.0View on GitHub
sphinx-llm is a collection of Sphinx extensions for working with LLMs. It serves two purposes: 1. Enabling LLMs to consume documentation - Generates llms.txt, llms-full.txt, and per-page markdown files following the llms.txt standard 2. Leveraging LLMs to generate content - Uses LLMs to generate static content during builds (e.g., the docref directive for page summaries) Prefer using Git worktrees for development. **sphinx_llm.txt (src/sphinx_llm/txt.py)** - Hooks into Sphinx's builder-inited and build-finished events - Spawns a parallel subprocess running sphinx-build -b markdown…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,736 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- resolve-issueSkill
The file
We split this AGENTS.md into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Prefer using Git worktrees for development.
- Distinctive: line 115
All commits by contributors who are not employed by NVIDIA must be signed off using git commit -s (Developer Certificate of Origin).
≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
This file provides guidance to coding agents working with code in this repository.
Project Overview
sphinx-llm is a collection of Sphinx extensions for working with LLMs. It
serves two purposes:
- Enabling LLMs to consume documentation - Generates
llms.txt,llms-full.txt, and per-page markdown files following the llms.txt standard - Leveraging LLMs to generate content - Uses LLMs to generate static
content during builds (e.g., the
docrefdirective for page summaries)
Development Commands
Prefer using Git worktrees for development.
Setup
# Install dependencies with uv (recommended)
uv sync --dev --extra genTesting
# Run all tests
uv run pytest src/sphinx_llm/tests/
# Run tests with coverage
uv run pytest src/sphinx_llm/tests/ --cov=sphinx_llm --cov-report=xml
# Run tests against a specific Sphinx version
uv run --with "sphinx>=7,<8" pytest src/sphinx_llm/tests/Linting and Formatting
# Ensure pre-commit hooks are installed
uv run pre-commit install
# Run ruff linter with auto-fix
uv run pre-commit run ruff --all-files
# Run ruff formatter
uv run pre-commit run ruff-format --all-files
# Run all pre-commit hooks (includes ruff, prettier, markdownlint, codespell,
# license headers)
uv run pre-commit run --all-filesBuilding Documentation
# Build the example docs (recommended for development)
uv run --dev sphinx-autobuild docs/source docs/build/html
# Build docs once
uv run --dev sphinx-build docs/source docs/build/htmlArchitecture
Core Extensions
sphinx_llm.txt (src/sphinx_llm/txt.py)
- Hooks into Sphinx's
builder-initedandbuild-finishedevents - Spawns a parallel subprocess running
sphinx-build -b markdownto generate markdown files - The
MarkdownGeneratorclass orchestrates:- Parallel markdown build (can be disabled via
llms_txt_build_parallelconfig) - Merging markdown output with HTML output (each page gets
.html.mdextension) - Generating
llms-full.txt(concatenated markdown) - Generating
llms.txt(sitemap with descriptions)
- Parallel markdown build (can be disabled via
- Handles both
htmlanddirhtmlbuilders with different path structures - For
dirhtmlbuilder, supports three suffix modes viallms_txt_suffix_mode:"file-suffix": Only generatespage/index.html.mdfiles"url-suffix": Only generates URL-stylepage.mdfiles"both"(default): Generates both formats for maximum compatibility
sphinx_llm.docref (src/sphinx_llm/docref.py)
- Parses directives into pending nodes and collects unique requests in the Sphinx environment
- Applies authored directive and
html_metaoverrides before consulting the generated-summary cache - Generates missing summaries at
env-updatedthrough the shared OpenAI-compatible client andllms_txt_summary_*configuration without modifying source files - Stores requests and effective state in the Sphinx environment, persists generated records in the shared versioned page-summary cache, and supports purge/merge
- Writes
sphinx-llm-summaries.jsonwith effective summaries and provenance - Requires the
gendependencies and an explicitly configured model for cache misses
Test Structure
Tests live in src/sphinx_llm/tests/ (not a separate tests/ directory).
Tests use pytest fixtures that build the example docs in docs/source/ into
temporary directories with different builders and parallel settings.
Key test fixture: sphinx_build - parametrized fixture that tests both html
and dirhtml builders with parallel and sequential markdown building.
Commit Requirements
All commits by contributors who are not employed by NVIDIA must be signed off
using git commit -s (Developer Certificate of Origin).
Pre-commit hooks must be installed. They enforce:
- Ruff formatting and linting
- License header in all
.pyfiles (usingLICENSE_HEADERfile) - Prettier for YAML
- Markdownlint for Markdown
- Codespell for spelling
Version Management
Uses hatch-vcs for version management from git tags. Version is generated at
build time into src/sphinx_llm/_version.py.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

