<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Suraj Sahoo</title>
    <description>The latest articles on DEV Community by Suraj Sahoo (@suraj_sahoo_9945cc96926a1).</description>
    <link>https://dev.to/suraj_sahoo_9945cc96926a1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3926615%2F1d2ecfad-9af5-478a-99d7-679d0dd28a5b.jpg</url>
      <title>DEV Community: Suraj Sahoo</title>
      <link>https://dev.to/suraj_sahoo_9945cc96926a1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/suraj_sahoo_9945cc96926a1"/>
    <language>en</language>
    <item>
      <title>I built an AI that writes your docstrings — and catches when they lie</title>
      <dc:creator>Suraj Sahoo</dc:creator>
      <pubDate>Tue, 12 May 2026 17:26:09 +0000</pubDate>
      <link>https://dev.to/suraj_sahoo_9945cc96926a1/i-built-an-ai-that-writes-your-docstrings-and-catches-when-they-lie-5afm</link>
      <guid>https://dev.to/suraj_sahoo_9945cc96926a1/i-built-an-ai-that-writes-your-docstrings-and-catches-when-they-lie-5afm</guid>
      <description>&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;I built &lt;a href="https://wrightai-web.fly.dev" rel="noopener noreferrer"&gt;Wright AI&lt;/a&gt; to fix this. It does two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Generate&lt;/strong&gt; docstrings automatically, for your whole codebase&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Detect drift&lt;/strong&gt; — flag the docs that have become lies&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here's how both work.&lt;/p&gt;




&lt;h2&gt;
  
  
  The generation side
&lt;/h2&gt;

&lt;p&gt;Most docstring generators just describe the function body. Wright reads the &lt;br&gt;
&lt;strong&gt;call graph&lt;/strong&gt; first.&lt;/p&gt;

&lt;p&gt;It uses Tree-sitter to parse your AST, then builds a NetworkX dependency graph &lt;br&gt;
weighted by PageRank. When generating a docstring for &lt;code&gt;processPayment()&lt;/code&gt;, it &lt;br&gt;
doesn't just read that function — it reads what calls it, what it calls, and &lt;br&gt;
what those callees do. That context is what lets it write docs that describe &lt;br&gt;
&lt;em&gt;purpose&lt;/em&gt;, not just mechanics.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;wright
wright init &lt;span class="nb"&gt;.&lt;/span&gt;
wright generate src/
One command. Every undocumented &lt;span class="k"&gt;function in &lt;/span&gt;your repo gets a docstring.
You review a diff, accept or discard. Nothing is written &lt;span class="k"&gt;until &lt;/span&gt;you confirm.

Supported styles: Google, NumPy, Sphinx &lt;span class="o"&gt;(&lt;/span&gt;Python&lt;span class="o"&gt;)&lt;/span&gt;, JSDoc &lt;span class="o"&gt;(&lt;/span&gt;TypeScript/JavaScript&lt;span class="o"&gt;)&lt;/span&gt;,
godoc &lt;span class="o"&gt;(&lt;/span&gt;Go&lt;span class="o"&gt;)&lt;/span&gt;, rustdoc &lt;span class="o"&gt;(&lt;/span&gt;Rust&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;

The drift detection side — the interesting part
This is the part I haven&lt;span class="s1"&gt;'t seen elsewhere, and the part that motivated building
this at all.

What is drift? A function'&lt;/span&gt;s signature changes — a parameter is added,
renamed, or removed — but the docstring isn&lt;span class="s1"&gt;'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'&lt;/span&gt;s a drift hit.


&lt;span class="c"&gt;# Check the whole project&lt;/span&gt;
wright drift &lt;span class="nb"&gt;.&lt;/span&gt;

&lt;span class="c"&gt;# Output:&lt;/span&gt;
&lt;span class="c"&gt;# processPayment()   payments/core.ts:88   ⚠ param 'card' → 'paymentMethod'&lt;/span&gt;
&lt;span class="c"&gt;# validateToken()    auth/middleware.ts:14  ⚠ return type changed&lt;/span&gt;
You can run this &lt;span class="k"&gt;in &lt;/span&gt;CI to block PRs that introduce drift:


&lt;span class="c"&gt;# .github/workflows/wright.yml&lt;/span&gt;
- name: Check documentation drift
  uses: surajs1999/WrightAI@v1
  with:
    check_drift: &lt;span class="s2"&gt;"true"&lt;/span&gt;
    threshold: &lt;span class="s2"&gt;"0.8"&lt;/span&gt;
  &lt;span class="nb"&gt;env&lt;/span&gt;:
    WRIGHT_TOKEN: &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="p"&gt;{ secrets.WRIGHT_TOKEN &lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
And &lt;span class="k"&gt;in &lt;/span&gt;VS Code, drifted functions get a ⚠ gutter icon so you catch it
before you even push.

Bonus: MCP server &lt;span class="k"&gt;for &lt;/span&gt;Claude Code / Cursor
If you use Claude Code, Cursor, or GitHub Copilot, there&lt;span class="s1"&gt;'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'&lt;/span&gt;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&lt;span class="s1"&gt;'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
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What's next&lt;br&gt;
The drift detection is still maturing — right now it catches signature changes.&lt;br&gt;
Next up: detecting when the documented behavior contradicts how the function&lt;br&gt;
actually branches. That's a harder problem (requires symbolic execution or&lt;br&gt;
very careful static analysis), but the common cases are tractable.&lt;/p&gt;

&lt;p&gt;If you try it, I'd genuinely like to know what breaks. The GitHub issues page&lt;br&gt;
is the best place: github.com/surajs1999/WrightAI&lt;/p&gt;

</description>
      <category>python</category>
      <category>typescript</category>
      <category>ai</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
