Documentation is a promise. A docstring says: "This function takes these inputs, does this thing, and returns this." The problem is that promises are easy to break — and nobody enforces them.
I've been on teams where the docs were accurate on day one and completely wrong six months later. Not because engineers are careless. Just because there's no system that notices when code and docs diverge.
I built Wright AI to fix this. It does two things:
- Generate docstrings automatically, for your whole codebase
- Detect drift — flag the docs that have become lies
Here's how both work.
The generation side
Most docstring generators just describe the function body. Wright reads the
call graph first.
It uses Tree-sitter to parse your AST, then builds a NetworkX dependency graph
weighted by PageRank. When generating a docstring for processPayment(), it
doesn't just read that function — it reads what calls it, what it calls, and
what those callees do. That context is what lets it write docs that describe
purpose, not just mechanics.
pip install wright
wright init .
wright generate src/
One command. Every undocumented function in your repo gets a docstring.
You review a diff, accept or discard. Nothing is written until you confirm.
Supported styles: Google, NumPy, Sphinx (Python), JSDoc (TypeScript/JavaScript),
godoc (Go), rustdoc (Rust).
The drift detection side — the interesting part
This is the part I haven't seen elsewhere, and the part that motivated building
this at all.
What is drift? A function's signature changes — a parameter is added,
renamed, or removed — but the docstring isn't updated. The code says one thing.
The docs say another.
Wright catches this by diffing the AST at each commit, not the text. Text diffs
miss subtle changes like a renamed parameter that still looks similar. AST diffs
are precise: if the signature structure changed and the docstring references the
old parameter name, that's a drift hit.
# Check the whole project
wright drift .
# Output:
# processPayment() payments/core.ts:88 ⚠ param 'card' → 'paymentMethod'
# validateToken() auth/middleware.ts:14 ⚠ return type changed
You can run this in CI to block PRs that introduce drift:
# .github/workflows/wright.yml
- name: Check documentation drift
uses: surajs1999/WrightAI@v1
with:
check_drift: "true"
threshold: "0.8"
env:
WRIGHT_TOKEN: ${{ secrets.WRIGHT_TOKEN }}
And in VS Code, drifted functions get a ⚠ gutter icon so you catch it
before you even push.
Bonus: MCP server for Claude Code / Cursor
If you use Claude Code, Cursor, or GitHub Copilot, there's one more piece.
wright-mcp
# ✓ Indexed 847 functions across 12 files
# → Tools ready: search_docs, get_function_doc, list_undocumented
This starts a local MCP server. Add it to your editor's config once, and your
AI assistant can query your documented functions directly — instead of you
pasting code into every new session. It re-indexes on file save, so it's always
current.
Quick start
VS Code (easiest):
Install [Wright AI](https://marketplace.visualstudio.com/items?itemName=WrightAI.wrightai) from the Marketplace
Sign in at [wrightai-web.fly.dev](wrightai-web.fly.dev)
Open any file — click "Generate Docs" above any function
CLI:
pip install wright
wright init .
wright generate .
wright drift .
wright chat . # Ask questions, get file:line citations
What's next
The drift detection is still maturing — right now it catches signature changes.
Next up: detecting when the documented behavior contradicts how the function
actually branches. That's a harder problem (requires symbolic execution or
very careful static analysis), but the common cases are tractable.
If you try it, I'd genuinely like to know what breaks. The GitHub issues page
is the best place: github.com/surajs1999/WrightAI
Top comments (0)