Docs Agent
AI-assisted documentation quality tool for Python projects.
Scans codebases for docstring coverage, classifies documentation files using the DIATAXIS framework, and generates missing docstrings via LLM.
Features
- Docstring Coverage Audit — AST-based scanning of Python files with per-module reporting
- DIATAXIS Classification — Heuristic + LLM-powered classification of docs into tutorial/guide/reference/explanation
- LLM Docstring Generation — Batch generation of Google-style docstrings via llm_mcp gateway or OpenAI API
- Non-Destructive Code Insertion — Insert generated docstrings using libcst while preserving all formatting
- Pre-Commit Hooks — Enforce coverage thresholds in CI/CD pipelines
- CI Integration — GitHub Actions workflow for automated testing
Installation
# From platform monorepo (editable, recommended)
pip install -e packages/docs-agent
# With LLM support (httpx, openai, libcst)
pip install -e "packages/docs-agent[llm]"
# With dev tools (pytest, coverage)
pip install -e "packages/docs-agent[dev]"
# From GitHub (in requirements.txt)
docs-agent @ git+https://github.com/achimdehnert/platform.git@main#subdirectory=packages/docs-agent
Quick Start
# Audit docstring coverage
docs-agent audit /path/to/repo
# Audit only apps/ directory
docs-agent audit /path/to/repo --apps-only
# JSON output for CI
docs-agent audit /path/to/repo --output json
# Fail if coverage < 60%
docs-agent audit /path/to/repo --min-coverage 60
# DIATAXIS only
docs-agent audit /path/to/repo --scope diataxis
# Refine low-confidence classifications via LLM
docs-agent audit /path/to/repo --scope diataxis --refine
CLI Reference
docs-agent audit
Audit a repository for documentation quality.
Usage: docs-agent audit [OPTIONS] REPO_PATH
Arguments:
REPO_PATH Path to the repository root [required]
Options:
--scope TEXT Audit scope: docstrings, diataxis, or all [default: all]
--apps-only Only scan apps/ directory for docstrings
--min-coverage FLOAT Fail if docstring coverage is below this %
--output TEXT Output format: table or json [default: table]
--refine Use LLM to refine low-confidence DIATAXIS classifications
--llm-url TEXT URL of the llm_mcp HTTP gateway [default: http://localhost:8100]
docs-agent generate
Generate docstrings for undocumented code items via LLM.
Usage: docs-agent generate [OPTIONS] REPO_PATH
Arguments:
REPO_PATH Path to the repository root [required]
Options:
--apps-only Only scan apps/ directory
--dry-run / --apply Preview changes (default) or apply them
--max-items INTEGER Maximum items to generate docstrings for [default: 20]
--llm-url TEXT URL of the llm_mcp HTTP gateway [default: http://localhost:8100]
--model TEXT LLM model name [default: gpt-4o-mini]
Example Output
Docstring Coverage Table
Module Coverage
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Module ┃ Items ┃ Documented ┃ Coverage ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╉━━━━━━━╉━━━━━━━━━━━━╉━━━━━━━━━━┩
│ apps/core/models.py │ 12 │ 8 │ 67% │
│ apps/core/services.py │ 6 │ 6 │ 100% │
│ apps/core/views.py │ 9 │ 3 │ 33% │
└───────────────────────────────┴───────┴────────────┴──────────┘
Total: 17/27 items documented (63.0%)
DIATAXIS Classification
DIATAXIS Classification
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Document ┃ Quadrant ┃ Confidence ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╉━━━━━━━━━━━━━╉━━━━━━━━━━━━┩
│ docs/getting-started.md │ tutorial │ 85% │
│ docs/deploy-guide.md │ guide │ 72% │
│ docs/api-reference.md │ reference │ 90% │
│ docs/adr/ADR-001.md │ explanation │ 78% │
└─────────────────────────────┴─────────────┴────────────┘
Pre-Commit Integration
Add to your .pre-commit-config.yaml:
repos:
- repo: https://github.com/achimdehnert/platform
rev: main
hooks:
- id: docs-agent-coverage
args: ["--scope", "docstrings", "--min-coverage", "50"]
Architecture
docs_agent/
├── analyzer/
│ ├── ast_scanner.py # AST-based docstring coverage scanning
│ ├── diataxis_classifier.py # Heuristic DIATAXIS classification
│ └── llm_classifier.py # LLM fallback for low-confidence docs
├── generator/
│ ├── docstring_gen.py # Batch LLM docstring generation
│ └── code_inserter.py # Non-destructive libcst insertion
├── cli.py # Typer CLI (audit + generate commands)
├── llm_client.py # HTTP gateway + OpenAI fallback
├── models.py # Data models (CodeItem, Coverage, etc.)
└── prompts.py # LLM prompt templates
Configuration
Environment Variables
| Variable | Default | Description |
|---|---|---|
DOCS_AGENT_LLM_URL |
http://localhost:8100 |
llm_mcp gateway URL |
DOCS_AGENT_LLM_MODEL |
gpt-4o-mini |
LLM model name |
OPENAI_API_KEY |
— | Direct OpenAI fallback (optional) |
LLM Backend
The docs-agent tries backends in this order:
- llm_mcp HTTP gateway (default,
http://localhost:8100) — production setup - Direct OpenAI API — fallback if gateway is down and
OPENAI_API_KEYis set
Development
cd packages/docs-agent
# Install with dev + LLM extras
pip install -e ".[dev,llm]"
# Run tests
pytest tests/ -v
# Run with coverage
pytest tests/ --cov=docs_agent --cov-report=term-missing
Related
- ADR-046: Documentation Quality Standards (defines the docs-agent specification)
- DIATAXIS: https://diataxis.fr/ — Documentation framework
- Platform: https://github.com/achimdehnert/platform — Monorepo
License
MIT
Metadata
Release files for iil-docs-agent 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| iil_docs_agent-0.2.0.tar.gz | 26.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| iil_docs_agent-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 48.0 kB
Release files / iil_docs_agent-0.2.0.tar.gz
| Download URL | iil_docs_agent-0.2.0.tar.gz |
|---|---|
| Size | 26.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1d930d69ff3a610b11523fa9950285d605306ea8424bffcfc17de75bbff9a7bd
|
|
BLAKE2b-256 checksum How to use checksums |
1d2777424829d71ee5e0308af97449c306e476afae84b17f508388398cc49a56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Release files / iil_docs_agent-0.2.0-py3-none-any.whl
| Download URL | iil_docs_agent-0.2.0-py3-none-any.whl |
|---|---|
| Size | 21.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e953ba3368f65abad773e5410cebb7d5c318ee763b74fb28729c58cb2d66ee56
|
|
BLAKE2b-256 checksum How to use checksums |
d577de26c6e1ab124e9d8d016dce408541e0ff47f85635f23198b963ffd19bad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Security for iil-docs-agent 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.