Prevent documentation rot before code merges. DocGuard detects the exact sentences in your docs that a pull request or code change invalidated, pinpoints the responsible code diff, and opens a fix pull request in one click.
π Live Demo Website: docguard-org.vercel.app
Sign in on the website and click Add to GitHub Actions on a repository. DocGuard opens a setup pull request, and once you merge it, every pull request gets checked. You can also add .github/workflows/docguard.yml yourself:
name: DocGuard
# Runs on pull requests from forks too, so outside contributors see the report.
# DocGuard only reads the pull request's code. It never runs it.
on:
pull_request_target:
permissions:
contents: read
pull-requests: write
jobs:
docguard:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: Nobody-KnowsBetter/ooli@mainEvery pull request now gets a comment naming the exact doc sentences it made wrong, the code change responsible, a suggested fix and a link to fix it in that pull request. There's no comment when nothing drifted. Everything runs inside your own GitHub Actions: no account, no API key, and your code stays there.
| Input | Default | What it does |
|---|---|---|
use-model |
true |
Runs Qwen for ambiguous sentences rules can't decide. Model is downloaded only when needed. |
model |
qwen2.5-coder:3b |
The Ollama model to use. |
comment |
true |
Posts the report on the pull request. It always appears in the job summary too. |
fail-on-drift |
false |
Fails the check when it confirms drift. |
Outputs: drift-count, confirmed-count, possible-count.
Developers constantly modify code without updating documentation:
# In src/config.py
TIMEOUT_SECONDS = 13456 # Changed from 30While documentation quietly rots:
# In docs/configuration.md
The request timeout is 30 seconds.Traditional CI/CD linters test code execution and syntax, but fail to detect when ordinary English prose, parameter tables, tutorials, or API guides contradict code reality.
These silent documentation drifts lead to:
- Broken onboarding instructions and developer confusion.
- Inaccurate parameter references and invalid CLI flag examples.
- Time wasted debugging discrepancies between code reality and written documentation.
DocGuard solves this through a hybrid pipeline: combining deterministic Python AST analysis for zero-hallucination code extraction with lightweight, local LLM reasoning (Qwen 2.5 Coder) to verify contextual prose.
- π Deterministic AST Diffing: Tracks changes to CLI flags (
argparse), function parameters, constants, route paths, configuration defaults, and environment variables. Skips tests and private symbols to minimize noise. - π Smart Doc Chunking: Parses Markdown files into addressable semantic sentences and sections with exact line numbers, automatically filtering out changelogs and release notes.
- π§ Hybrid Verification Engine:
- Deterministic Rules: Instantly verifies exact symbol and value collisions.
- Local LLM Reasoning (Qwen 2.5 Coder 3B via Ollama): Analyzes ambiguous sentences that mention outdated values without explicitly naming the variable (e.g., "Requests give up after 30 seconds" when default timeout changed to
60). - Zero Cost / Offline Capable: Runs locally using ~2 GB RAM without mandatory cloud API keys. No closed-model APIs are used.
- π οΈ Automated Patch Proposals: Generates precise, line-by-line documentation diffs ready to be applied with a single click.
- π Interactive Web Dashboard: Modern Next.js UI providing repository health scores, drift histories, findings breakdown, and repository configuration.
- π Maintainer Portal & GitHub OAuth: Sign in with GitHub to automatically sync your repositories (private repositories only when run locally) and poll PRs in real time.
DocGuard avoids generic LLM hallucination by employing a structured analysis funnel:
flowchart TD
PR["Git Pull Request / Commit Diff"] --> AST["Python AST Analyzer"]
PR --> Chunker["Markdown Doc Chunker"]
AST -->|"Extracted Symbols, Defaults & Flags"| Matcher["Semantic Candidate Mapper"]
Chunker -->|"Sentences with File & Line Locations"| Matcher
Matcher --> Heuristic{"Rule Engine (Exact Match?)"}
Heuristic -->|"Exact Match (Deterministic)"| Report["Drift Finding & Score"]
Heuristic -->|"Ambiguous Prose Match"| LLM["Qwen 2.5 Coder (Ollama)"]
LLM --> Report
Report --> Dashboard["Interactive Next.js Dashboard"]
Report --> Autofix["Automated Markdown Patch (.patch)"]
- Python 3.11+
- Node.js 18+
- (Optional, recommended for AI reasoning) Ollama with the app running.
Start the backend API, Ollama model check, and Next.js dashboard with a single command:
./scripts/dev.sh- Landing Page: http://localhost:3000
- Maintainer Dashboard: http://localhost:3000/dashboard
- API Docs (Swagger UI): http://localhost:8000/docs
- Health Check: http://localhost:8000/api/health
Note: On the first run with Ollama running, the script pulls qwen2.5-coder:3b (~2 GB). If Ollama is not running, scans gracefully fall back to deterministic rules.
Login is optional. Without it, you can explore the dashboard and add public repositories by name.
To enable GitHub sign-in and auto-sync for your personal/organization repos:
- Create an OAuth App at github.com/settings/developers with the callback URL:
http://localhost:3000/api/auth/callback - Run the helper script and paste the client ID and secret:
./scripts/setup-github-login.sh
You can also run DocGuard directly via CLI to inspect git commits or local branches:
# Run analysis between two git references
python3 backend/src/docguard.py --base HEAD~1 --head HEAD
# Run analysis and automatically apply suggested fixes
python3 backend/src/docguard.py --base HEAD~1 --head HEAD --autofixWe include real-world reproduction cases in the examples/ directory. Run a sample scan on a CLI flag change:
python3 examples/run_example.py## π‘οΈ DocGuard Documentation Intelligence Report
β οΈ Documentation drift detected! (3 issues found)
Repository Documentation Health: 46%
### Issue #1: `--timeout` in `README.md`
Verdict: π΄ CONFIRMED DRIFT | Confidence: 97%
- Source File: cli.py
- Documentation File: README.md (Line 3)
Outdated Statement in Documentation:
> Use --timeout to stop slow jobs.
Why this is incorrect:
Flag '--timeout' was renamed to '--deadline' in cli.py:4, but this sentence still says '--timeout'.
Related Code Diff:
- add_argument("--timeout")
+ add_argument("--deadline")
Suggested Correction:
> Use --deadline to stop slow jobs.DocGuard/
βββ .github/workflows/ # CI workflow and DocGuard PR drift detection action
βββ action.yml # Official reusable GitHub Action (Nobody-KnowsBetter/ooli@main)
βββ backend/
β βββ app/
β β βββ ai/ # Qwen / Ollama and LLM provider interfaces & prompts
β β βββ analyzer/ # AST comparative parser, doc chunker, and mapper
β β βββ autofix/ # Patch generator and automated fixer
β β βββ database/ # SQLite schema and scan persistence
β β βββ github_auth.py # GitHub OAuth session handler
β β βββ sync.py # Background repo sync and PR scanning
β β βββ main.py # FastAPI routes, healthcheck, and webhook receiver
β βββ src/ # DocGuard CLI entrypoint (docguard.py)
β βββ Dockerfile # Production Docker container definition
β βββ requirements.txt # Python backend dependencies
βββ frontend/
β βββ public/ # Static high-performance marketing landing site
β βββ src/app/dashboard/ # Next.js Maintainer Dashboard (Issues, Autofix, Repositories)
β βββ next.config.js # API proxy rewrites to backend service
βββ examples/ # Sample CLI and config drift test cases
βββ scripts/
β βββ dev.sh # Unified one-command development launcher
β βββ setup-github-login.sh
βββ render.yaml # Render Blueprint deployment definition
βββ tests/ # Unit and end-to-end drift detection tests
To run the complete test suite locally:
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]" -r backend/requirements.txt
pytest- Branch Protection: All changes must go through a feature branch and pull request. Direct pushes to
mainare blocked. - CI Verification: PRs can only be merged when automated CI tests pass.
- Commit Metadata: Every commit message must name the coding agent and models used:
Add tests for URL parser
Coding agent: Claude Code
Models used in project: Qwen 2.5 Coder 3B
- Nitanshu Goyal
- Mausam Kumar Dwivedi
- Himank Kaushik
- Krish Garg
This project is licensed under the MIT License.