sphinx-llm
AGENTS.md49 starsChanged 21 days 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 code style.
Of the AGENTS.md files we read, the 31,700 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 repository2 other files it gives its agents.
- making-a-prSkill
- resolve-issueSkill
The file
We split this AGENTS.md into the rules it gives an agent
11 rules. About 0 are common, 10 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
1
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.
- Very specific: line 116
When adding or changing tests, reuse or extend shared fixtures in src/sphinx_llm/tests/conftest.py before duplicating setup.
- Distinctive: line 123
Prefer lightweight fixtures for unit tests and real builds for integration tests.
- Distinctive: line 127
Treat the configuration options table as the canonical documentation for each setting's name, purpose, type, default value, and basic …
- Distinctive: line 131
When adding or changing a configuration option:
- Distinctive: line 133
Update its entry in the configuration table.
- Distinctive: line 134
Keep the option's name, purpose, type, default value, and basic behavior in the table as their single source of truth.
- Distinctive: line 136
Add prose outside the table only when it provides distinct information that does not fit concisely in the table, such as a workflow, an …
- Distinctive: line 139
When additional prose is necessary, refer readers to the configuration table instead of restating the option's description or default value.
- Distinctive: line 142
Before submitting a documentation change, compare all newly added prose against the configuration table and remove duplicated explanations.
- Distinctive: line 147
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 40,246 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 primary site (Python >=3.10)
uv run --dev --group docs sphinx-autobuild docs/source docs/build/html
# Build docs once
uv run --group docs 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 build src/sphinx_llm/tests/fixtures/integration_docs/ into temporary
directories with different builders and parallel settings. Keep that corpus and
its unthemed configuration independent of the primary site in docs/source/.
The opt-in docs dependency group is for the primary site, not compatibility
tests; its theme has a higher Python/Sphinx floor than the library.
Key test fixture: sphinx_build - parametrized fixture that tests both html
and dirhtml builders with parallel and sequential markdown building.
When adding or changing tests, reuse or extend shared fixtures in
src/sphinx_llm/tests/conftest.py before duplicating setup. Share project/build
mechanics, provider stubs, and cleanup where the duplication removed outweighs
the added indirection; keep scenario-specific configuration and assertions in each
test. For documentation build coverage, prefer adding examples to the fixture
docs in src/sphinx_llm/tests/fixtures/integration_docs/ and asserting against
their built output over inlining documentation source within tests.
Prefer lightweight fixtures for unit tests and real builds for integration tests.
Documentation Guidelines
Treat the configuration options table as the canonical documentation for each setting's name, purpose, type, default value, and basic behavior, including enable/disable behavior when applicable.
When adding or changing a configuration option:
- Update its entry in the configuration table.
- Keep the option's name, purpose, type, default value, and basic behavior in the table as their single source of truth.
- Add prose outside the table only when it provides distinct information that does not fit concisely in the table, such as a workflow, an interaction between multiple settings, migration guidance, or a substantial usage example.
- When additional prose is necessary, refer readers to the configuration table instead of restating the option's description or default value.
Before submitting a documentation change, compare all newly added prose against the configuration table and remove duplicated explanations.
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.

