The End of the Stale README: Inside theDakshJaitly/mex
How a zero-token drift detector turns AI context files into a deterministic database, giving coding agents a flawless long-term memory.

I finally built a better version of NGL, in 9 days with no code experience No bots. No cringe. Just real anonymous questions. It’s called Ask To Know —and MVP is live now. 🔗asktoknow.vercel.app Here’s what it does 🧵
- Current AI coding workflows rely on context files that quickly drift from codebase reality, leading to hallucinations.
- mex solves this by treating documentation as a testable build artifact, using deterministic AST parsing instead of expensive LLMs to detect drift.
- A gamified scoring system enforces documentation health by penalizing broken paths, missing dependencies, and stale files.
- When drift occurs, mex generates a targeted brief for surgical LLM edits, preserving structure and saving tokens.
The Context Rot Epidemic
In the era of AI-assisted development, your coding agent is only as good as its context window. We feed Claude and Cursor detailed .cursorrules and architecture documents, expecting them to act as a flawless co-pilot. But codebase reality moves faster than documentation. Files are renamed, dependencies are swapped, and architectural decisions pivot.
The result is context rot. The AI confidently writes deprecated patterns because its instructions are three months out of date. The very tools meant to accelerate development end up causing friction when their foundational knowledge is stale.
The Zero-Token Philosophy
The naive solution to context rot is to throw more AI at the problem: ask an LLM to read the codebase and update the docs. This is slow, expensive, and prone to hallucinations. mex takes a radically different approach. It skips the AI entirely for the detection phase.
Instead, mex uses deterministic Abstract Syntax Tree (AST) parsing. It treats markdown not as a loose text file, but as a structured database of "claims" about the codebase. This makes drift detection fast enough to run as a pre-commit hook, bringing milliseconds-fast verification to AI memory.
| Feature | Naïve AI Doc Sync | mex Deterministic Sync |
|---|---|---|
| Detection Phase | LLM Context Window (Slow, expensive) | AST Claim Extraction (Milliseconds, zero-token) |
| Verification | Semantic search and "vibes" | <code>fs.existsSync</code> and <code>simple-git</code> history |
| Fix Phase | Rewrite entire file | Targeted surgical brief prompting |
Extracting Claims from the AST
The core engine lives in src/drift/claims.ts. mex uses remark to parse Markdown into an AST, systematically hunting for structured information. When it finds an inline code block like `src/api/auth.ts`, it registers a "Path Claim." When it finds bold text in a tech stack section, it registers a "Dependency Claim."
To avoid false positives, mex employs sophisticated filtering. URL routes or random code snippets that resemble file paths are ignored. It even detects if a claim exists within a "negated section" (e.g., "What we don't use"), demonstrating an understanding of how developers actually structure documentation.
Gamifying the Hippocampus
Documentation is only maintained if there are consequences for neglecting it. mex introduces a gamified scoring system in src/drift/scoring.ts. The documentation health starts at a perfect 100/100.
Eight distinct checkers enforce this score. A broken file path or missing dependency results in a severe 10-point deduction. Stale files—detected via simple-git commit analysis—trigger a 3-point penalty. This transforms doc maintenance from a chore into a passing or failing CI build.
The Surgical Sync
When the score drops and drift is detected, mex finally engages the LLM—but not with a blind "fix this" prompt. Instead, it builds a highly specific Targeted Brief.
By passing only the exact broken claims to the AI, mex instructs it to perform surgical edits. This preserves crucial YAML frontmatter, saves tokens, and prevents the LLM from hallucinating unnecessary changes. It's a precise, efficient mechanism that ensures your AI agent always operates with a flawless, up-to-date memory.