Python companion CLI for bootstrapping the Node-based DocGuard tool in uv-managed projects.
Project description
DocGuard
Early beta — expect rough edges. Documentation-aware pre-commit guard for AI-assisted development.
DocGuard reads your project's markdown docs, looks at staged changes across any text-based language, and blocks commits that contradict the rules you've written down. It is not a linter. It enforces your project's documented intent.
BLOCK services/user_service.py:18 [architecture]
Direct database call from request handler
Cited: docs/architecture.md:23
"All database access must go through the repository layer"
Summary: 1 error(s), 0 warning(s).
Commit blocked. Bypass: git commit --no-verify or DOCGUARD_BYPASS=1 git commit
Install
npm install --save-dev @mobasshirkhan/docguard
npx docguard init
For uv-managed Python projects, you can bootstrap from this repo through uvx:
uvx --from git+https://github.com/mobi2400/DocsGuard-.git docguard install
That Python helper installs the npm package in the current repo and then runs docguard init. Use --package-manager if you want pnpm, yarn, or bun instead of auto-detecting.
docguard init will:
- write
.docguard.json - install a
pre-commithook (Husky-aware, falls back to.git/hooks/) - update
.gitignore - pre-warm the local embedding model (~25 MB one-time download)
You also need a Groq API key (free tier works). Three ways to set it:
.env file in your project root (easiest):
GROQ_API_KEY=gsk_...
DocGuard reads .env from the repo root automatically. Existing shell env vars are not overridden.
Or shell session:
export GROQ_API_KEY=gsk_...
Or system-wide (Windows):
setx GROQ_API_KEY "gsk_..."
Get a key at console.groq.com. Without one, DocGuard skips semantic checks and lets commits through.
Requirements
- Node
>= 18.17 - Disk:
@xenova/transformersadds ~70 MB tonode_modules(local embeddings, no per-commit API cost)
Usage
The hook runs automatically on every git commit. To run manually:
docguard check
Bypass:
git commit --no-verify # standard git escape hatch
DOCGUARD_BYPASS=1 git commit # explicit, logged to .docguard/bypass.log
Uninstall:
docguard uninstall # removes hook + cache
docguard uninstall --purge # also removes .docguard.json
Configuration
.docguard.json:
{
"docs": ["./docs/**/*.md"],
"ignore": [
"**/*.test.*",
"**/*.spec.*",
"**/__tests__/**",
"**/test/**",
"**/tests/**",
"**/__pycache__/**",
"**/.pytest_cache/**",
"**/node_modules/**",
"**/.venv/**",
"**/venv/**",
"**/vendor/**"
],
"severity": {
"security": "block",
"architecture": "warn",
"api-contract": "warn",
"naming": "warn",
"style": "warn"
},
"priority": {
"./docs/architecture.md": "critical"
},
"llm": {
"provider": "groq",
"model": "llama-3.3-70b-versatile"
},
"retrieval": {
"topK": 6,
"minScore": 0.15
},
"timeoutMs": 5000
}
- severity — per-category, never per-named-rule. Categories are fixed:
security,architecture,api-contract,naming,style. - priority — boost retrieval ranking for critical docs.
- timeoutMs — hard cap on the semantic check. On timeout, commit is allowed.
How it works
- Reads staged hunks via
git diff --cached. - Splits configured markdown into ≤1500-char chunks by heading.
- Embeds chunks locally with MiniLM (
@xenova/transformers), cached to.docguard/cache/. - Ranks chunks against the diff by cosine + path overlap + priority.
- Sends only the top-relevant chunks plus the diff to Groq for judgment.
- Validates the response: every violation must cite a
chunk_idwith a quote that is a real substring of the chunk. Otherwise it's downgraded to a warning.
DocGuard is language-agnostic at review time: if Git can stage it as text, DocGuard can compare that diff against your docs. The current package runtime is still Node-based, but the repository under review can be Python, Go, Java, Ruby, PHP, Rust, mixed-language monorepos, or anything similar.
For Python and uv users, the companion bootstrap CLI supports:
uvx --from git+https://github.com/mobi2400/DocsGuard-.git docguard install
uvx --from git+https://github.com/mobi2400/DocsGuard-.git docguard check
uvx --from git+https://github.com/mobi2400/DocsGuard-.git docguard uninstall
Trust guarantees
- No telemetry. Nothing leaves your machine except the redacted diff + relevant doc chunks going to Groq for the semantic check.
- Citation-or-downgrade. Every blocking violation must reference a real chunk and quote real text. Hallucinated citations are auto-downgraded to warn.
- DocGuard never blocks on its own bugs. Internal errors fail open (commit proceeds, error logged).
- Bypass is local, visible, and logged.
Project docs
- SPEC.md — locked v1 build spec
- docguard-v1-phases.md — phased build plan
- docs/explainer.md — long-form intro
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docguard-0.1.1b4.tar.gz.
File metadata
- Download URL: docguard-0.1.1b4.tar.gz
- Upload date:
- Size: 79.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e02cdb0ce7ef53d4e234bab92a07a4781cf1488eceaeff7b897842ee0077c37
|
|
| MD5 |
4c488d115e1d51c4d9b2abaa45dfaca0
|
|
| BLAKE2b-256 |
6145358c70fa36b19026ef3192d834d5075536eec81e7efc6ecdf08259600b07
|
Provenance
The following attestation bundles were made for docguard-0.1.1b4.tar.gz:
Publisher:
publish-pypi.yml on mobi2400/DocsGuard-
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
docguard-0.1.1b4.tar.gz -
Subject digest:
4e02cdb0ce7ef53d4e234bab92a07a4781cf1488eceaeff7b897842ee0077c37 - Sigstore transparency entry: 1854667668
- Sigstore integration time:
-
Permalink:
mobi2400/DocsGuard-@c41acbd05c2e0466b7d669b93d7bba941bb9d5f7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mobi2400
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@c41acbd05c2e0466b7d669b93d7bba941bb9d5f7 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file docguard-0.1.1b4-py3-none-any.whl.
File metadata
- Download URL: docguard-0.1.1b4-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96554303e2f1f94aaed454cc842e38f984e47881fb3a890a08fbe9028d6c546e
|
|
| MD5 |
c2bb36a60c2a0b523f8625ea2532ddc5
|
|
| BLAKE2b-256 |
feaa8616d4b4a4f6af6161ef482450d1cc66af26083760f9f6560069408966cf
|
Provenance
The following attestation bundles were made for docguard-0.1.1b4-py3-none-any.whl:
Publisher:
publish-pypi.yml on mobi2400/DocsGuard-
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
docguard-0.1.1b4-py3-none-any.whl -
Subject digest:
96554303e2f1f94aaed454cc842e38f984e47881fb3a890a08fbe9028d6c546e - Sigstore transparency entry: 1854667717
- Sigstore integration time:
-
Permalink:
mobi2400/DocsGuard-@c41acbd05c2e0466b7d669b93d7bba941bb9d5f7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/mobi2400
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@c41acbd05c2e0466b7d669b93d7bba941bb9d5f7 -
Trigger Event:
workflow_dispatch
-
Statement type: