ee14c4f691f2f791c863770e5ab2ef4c247128f6
AI Codebase Doc Drift Detector
Auto-detect and document code drift before AI context loss.
Problem
As AI generates more code, the gap between what the code does and what the docs say grows. No automated documentation maintenance keeps pace with AI-generated changes. This tool bridges that gap.
What It Does
- Scans your TypeScript/JavaScript codebase for exported functions, classes, and interfaces
- Generates
API.mdandARCHITECTURE.mdautomatically - Detects drift — finds symbols in code that aren't documented (or documented symbols that no longer exist)
- Updates docs on demand to match current code
Install
npm install -g ai-codebase-doc-drift-detector
# or use npx
npx ai-codebase-doc-drift-detector init
Usage
# Initialize config in your project
ai-doc-drift init
# Generate initial docs
ai-doc-drift scan
# Check for drift between code and docs
ai-doc-drift check
# Regenerate docs from current code
ai-doc-drift update
Config (ai-doc-drift.json)
{
"docsDir": "./docs",
"include": ["./src"],
"exclude": ["./node_modules", "./dist", "./docs", "./.git"],
"extensions": [".ts", ".js", ".tsx", ".jsx"],
"projectName": "My Project"
}
How It Works
- Parses your source files with lightweight regex (no heavy AST dependencies)
- Extracts exports, classes, methods, interfaces
- Generates markdown documentation
- Compares code against existing docs to detect drift
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success / no drift |
| 1 | Error (no docs found, no config, etc.) |
| 2 | Drift detected |
License
MIT
Description
Languages
TypeScript
93.2%
JavaScript
6.8%