Auto-Generate Documentation with AI Agents: JSDoc, README & API Docs
Auto-Generate Documentation with AI Agents: JSDoc, README & API Docs: Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.
- Generate JSDoc for every exported function and class
- Update README sections when APIs change
- Write OpenAPI/Swagger specs from Express or Fastify route handlers
- Create changelogs from git commit history automatically
Generating JSDoc for Your TypeScript Codebase
Run a documentation agent over your entire source tree to add missing JSDoc comments:
import { createAgent } from 'smoke-monkey-harness';const agent = createAgent({provider: 'anthropic',model: 'claude-3-7-sonnet',workspacePath: './src',autoApprove: true,});await agent.run(`Scan all .ts and .tsx files in src/.For every exported function, class, interface, and type that is missing JSDoc:1. Add a JSDoc comment describing its purpose, parameters, and return value.2. Include @example tags where the usage is non-obvious.3. Do not modify any existing JSDoc or source logic.4. Preserve all existing code formatting.`);
Keeping README in Sync with Code Changes
Add a post-merge CI step that runs a documentation sync agent. The agent reads the diff, identifies API changes, and updates the relevant README sections:
- New exported functions → added to the API reference table
- Removed or renamed exports → updated or removed from docs
- Changed configuration options → updated configuration section
- New CLI flags → added to usage examples
This prevents documentation drift without requiring developers to manually update docs on every PR.
Scope docs agents to changed files only
In CI, pass the git diff to the agent rather than the full codebase. This reduces token usage and focuses updates on actually changed APIs.
Frequently Asked Questions
Q:Can the agent generate OpenAPI specs from my Express routes?
Yes. Point the agent at your routes directory and ask it to generate a YAML or JSON OpenAPI 3.1 spec. It can read middleware, request validation schemas, and response types to produce accurate specs.
Q:How do I prevent the agent from hallucinating incorrect parameter descriptions?
Instruct the agent to only describe what is explicitly visible in the source code and to use phrases like "See source for details" when the behavior is complex or unclear. This prevents confident hallucination.
Related Alternatives & Comparisons
Build with Smoke Monkey Harness
Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.