OpenWiki: Auto-Generate & Maintain Agent Documentation for Your Codebase
OpenWiki: Auto-Generate & Maintain Agent Documentation for Your Codebase
Every developer using AI coding agents has run into the same problem: agents lack context about your codebase. They don't know the architecture, the naming conventions, the testing patterns, or the deployment workflow. You end up repeating yourself in every prompt, or worse — the agent generates code that doesn't fit your project's patterns.
OpenWiki by LangChain solves this. It's a CLI tool that reads your codebase, generates comprehensive documentation, and writes it into AGENTS.md or CLAUDE.md files — exactly where your coding agent looks for context. And with its GitHub Actions integration, it keeps that documentation up-to-date automatically.
Why OpenWiki Is Trending
OpenWiki hit 3,500+ GitHub stars within two weeks of its release in June 2026. Several factors explain its rapid adoption:
- Agent-first documentation — Instead of writing docs for humans, OpenWiki writes docs for agents. The output is structured for how Claude Code, Codex, Cursor, and other coding agents consume context.
- Zero-config CI/CD — A one-file GitHub Actions workflow keeps documentation fresh daily, opening PRs with updates. No manual maintenance.
- Multi-provider support — Works with OpenAI, Anthropic, OpenRouter, Fireworks, and Baseten. Bring your own model.
- LangChain pedigree — Built by the team behind the most popular LLM framework, giving it instant credibility and a mature toolchain (LangGraph, LangSmith).
Architecture Overview
OpenWiki's architecture follows a simple but effective pipeline:
- CLI Entry Point — The
openwikicommand (TypeScript, built with Ink/React for interactive TUI) accepts--init,--update,--print, or free-form prompts - Agent Engine — Powered by LangChain + LangGraph, it uses a structured agent that reads repository files, analyzes code structure, and generates documentation
- LLM Integration — Supports OpenAI, Anthropic, OpenRouter, Fireworks, and Baseten models. Configurable model ID via
OPENWIKI_MODEL_IDenv var - Documentation Output — Writes to
openwiki/directory by default, injects references intoAGENTS.md/CLAUDE.mdfor automatic agent context - CI/CD Integration — A scheduled GitHub Actions workflow runs
openwiki --updatedaily and opens a PR with documentation changes
Prerequisites
- Node.js 18+ (recommended: 22)
- npm or pnpm
- An API key for any supported LLM provider (OpenAI, Anthropic, OpenRouter, etc.)
- A Git repository (local or hosted on GitHub for CI/CD)
Installation
Install OpenWiki globally via npm:
npm install -g openwiki
Verify the installation:
openwiki --help
Quick Start: Generate Documentation
Navigate to your project repository and initialize OpenWiki:
cd /path/to/your/project
openwiki --init
The first run will prompt you to:
- Select an inference provider (OpenAI, Anthropic, OpenRouter, Fireworks, or Baseten)
- Enter your API key
- Choose a model (or specify a custom model ID)
- Optionally set up LangSmith tracing
After configuration, OpenWiki scans your codebase and generates documentation in the openwiki/ directory. It also creates or updates AGENTS.md (or CLAUDE.md) with a reference line like:
For comprehensive documentation about this codebase, check the openwiki/ directory.
One-Shot Mode
For non-interactive use (e.g., scripts), use the --print flag:
openwiki -p "Summarize the architecture of this project"
Update Existing Documentation
When your codebase changes, refresh the wiki:
openwiki --update
This re-scans the repository and updates only the changed sections.
CI/CD: Automatic Documentation Updates
To keep documentation fresh without manual work, add the OpenWiki GitHub Action to your repository.
Create .github/workflows/openwiki-update.yml:
name: OpenWiki Update
on:
workflow_dispatch:
schedule:
- cron: "0 8 * * *"
permissions:
contents: write
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
persist-credentials: true
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install OpenWiki
run: npm install --global openwiki
- name: Run OpenWiki
run: openwiki --update --print
env:
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
OPENWIKI_MODEL_ID: z-ai/glm-5.2
LANGSMITH_API_KEY: ${{ secrets.LANGSMITH_API_KEY }}
- name: Create OpenWiki update pull request
uses: peter-evans/create-pull-request@v7
with:
add-paths: openwiki
branch: openwiki/update
commit-message: "docs: update OpenWiki"
title: "docs: update OpenWiki"
body: |
Automated OpenWiki documentation update.
This PR was generated by the scheduled OpenWiki workflow.
Then add your API key as a repository secret (OPENROUTER_API_KEY in this example). The workflow runs daily at 08:00 UTC and opens a PR with any documentation changes.
Configuration Options
OpenWiki stores its configuration in ~/.openwiki/.env:
| Variable | Description | Example |
|---|---|---|
OPENWIKI_MODEL_ID |
Model identifier | anthropic/claude-sonnet-4-20250514 |
LANGSMITH_API_KEY |
LangSmith tracing key (optional) | lsv2_... |
Supported providers: OpenRouter, Fireworks, Baseten, OpenAI, Anthropic
You can override the model per-run via environment variable:
OPENWIKI_MODEL_ID="openai/gpt-5.1" openwiki --update --print
Comparison: OpenWiki vs Other Doc Tools
- OpenWiki — Agent-first. Output is structured for Claude Code, Codex, and Cursor. Injects into
AGENTS.md/CLAUDE.md. Daily CI/CD updates. - Mintlify / ReadMe — Human-first documentation portals. Requires manual updates or API pushes. No agent context integration.
- Docusaurus / Nextra — Static site generators for docs. Great for human readers but agents can't consume them without crawling.
- Sphinx / JSDoc — Language-specific API doc generators. Produce reference docs, not architectural overviews or conventions.
- AI context files (hand-written
CLAUDE.md) — Manual. Gets stale. OpenWiki automates this exact pattern.
Verification Checklist
After running OpenWiki, confirm:
openwiki/directory exists with generated documentation filesAGENTS.md(orCLAUDE.md) contains a reference toopenwiki/- Documentation accurately describes the project's architecture (read a few files to validate)
- The GitHub Action workflow file is committed and the first run succeeds
- Generated docs are markdown-formatted and readable
Resources
- GitHub Repository: github.com/langchain-ai/openwiki
- Official LangChain Docs: docs.langchain.com
- LangSmith: smith.langchain.com
- npm Package: npmjs.com/package/openwiki
- OpenRouter Models: openrouter.ai/models