Home / Blog / AI Agents

OpenWiki: the AI agent that writes your docs — and turns your Gmail into a second brain

Documentation rots the moment you write it. OpenWiki — an open-source CLI from the LangChain team — attacks the problem with an agent: point it at a repository and it writes the wiki; point it at your Gmail and it distills your inbox into a personal knowledge base you can chat with. I ran both for real. Here's the whole thing — the architecture, the guardrails, and the demos, screenshots included.

A friendly robot librarian writing on a large tabbed wiki book with a glowing pen, surrounded by a git branch icon, a terminal window and a gear
The pitch in one picture: an agent that reads your world and maintains the wiki for you

TL;DR

OpenWiki is a documentation agent in a CLI. In code mode, one command (openwiki --update) collects git evidence, explores your repo through a docs-only sandboxed backend, and writes a structured wiki into openwiki/ — then wires up a scheduled CI workflow so the docs keep refreshing themselves. In personal mode, connectors (Gmail, Notion, Slack, X, web search) feed the same agent, which distills your day into commitments, logistics and themes under ~/.openwiki/wiki.

I tested both against reality: 100 real emails became a second brain I could query from the terminal, and this very website got a four-page wiki from a single command. The design details — write guards that make the agent physically unable to touch source code, and a SHA-256 snapshot gate that keeps scheduled runs from looping — are the parts worth stealing.

The problem: docs rot, and now agents read them too

Every team knows the cycle. The code changes daily; the wiki doesn't. Onboarding takes weeks because the only accurate documentation is the code itself, and nobody ever volunteers to update the wiki. What's new is who suffers: it's no longer just humans. AI coding agents — Claude Code, Copilot, Cursor — are only as good as the context they can find, and a stale wiki misleads them exactly as it misleads a new hire.

The obvious fix is also the honest one: if writing documentation is the chore nobody wants, give the chore to an agent — but wrap it in guardrails so it can't do anything except documentation.

Meet OpenWiki: one agent, two brains

OpenWiki is an MIT-licensed CLI from the LangChain team, built on their DeepAgents framework. Install is one line — npm install -g openwiki — and the terminal UI is, delightfully, React: it's built with Ink, so the interactive chat, streaming tool calls and setup wizard all render in your console.

The same agent serves two very different masters:

Split diagram: code mode turns a git repository into an openwiki folder; personal mode feeds email, search, chat and social icons into a brain-shaped book at ~/.openwiki/wiki
Code mode documents a repository into openwiki/; personal mode builds a private knowledge brain in ~/.openwiki/wiki
  • Code mode (openwiki --update) — documents the current repository: quickstart, architecture, workflows, source maps. Recurrence comes from a scheduled GitHub Actions workflow it writes for you.
  • Personal mode (openwiki personal) — ingests configured connectors (Gmail, Notion, Slack, X, web search, Hacker News) and synthesizes a local wiki of commitments, logistics, themes and open questions.
OpenWiki's Ink terminal interface showing the version header, provider and model info, and a dry-run execution plan
The CLI is React-in-the-terminal (Ink). A dev dry-run prints the execution plan without touching anything

Under the hood: the two design decisions worth stealing

The architecture is small — a CLI, a credential store in ~/.openwiki/.env, a provider-agnostic model layer (OpenAI with an API key or your ChatGPT subscription, Anthropic, OpenRouter, Fireworks, Baseten, NVIDIA NIM, or any OpenAI-compatible gateway), and a SQLite checkpointer so conversations survive restarts. But two decisions elevate it from "neat demo" to "thing you can trust".

1. The agent physically cannot touch your code

OpenWiki extends DeepAgents' shell backend with explicit write guards: the agent may only write documentation files. It sees the repo through virtual paths, its output is capped, its commands are time-boxed. You don't have to trust the model's intentions — the backend enforces the contract.

A robot happily writing markdown documents on its side of a glass fence while source code files sit protected behind a shield labeled docs-only
Guardrails, not vibes: a docs-only write policy enforced by the backend, not by the prompt

2. A snapshot gate that keeps CI from looping

After every run, OpenWiki computes a SHA-256 snapshot of the whole wiki directory and writes its update metadata only if the content actually changed. A no-op update stays a true no-op — which is what stops a scheduled weekly run from committing metadata churn forever. It's a small idea that every "agent on a cron job" system should copy.

Flow diagram: a wiki folder goes through a SHA-256 snapshot machine into a changed? decision diamond, with yes leading to write metadata and no leading to skip
The content-snapshot gate: metadata is written only when the docs really changed

Demo: a second brain from 100 real emails

Theory is cheap, so I connected my actual Gmail. Authorization is a single command — openwiki auth gmail — which opens a Google consent screen with a read-only scope: the agent can read mail, never send or delete it. Tokens land in ~/.openwiki/.env, and only the variable names are ever printed, never the secrets.

Terminal output of openwiki auth gmail showing the browser consent step and the saved token variable names
openwiki auth gmail: browser consent in, read-only tokens out — printed by name only

Ingestion is a two-stage rocket, and the separation matters:

A two-stage rocket: the booster stage is the deterministic API pull producing raw JSON, the upper stage is the LLM synthesis filtering many gray dots into a few golden documents
Stage 1 is a deterministic API pull (reproducible, no model). Stage 2 is the LLM synthesis that filters signal from noise

The pull fetched 100 messages from the last 24 hours into raw JSON. Then the agent — treating raw email as untrusted evidence, not instructions — classified every message by type, priority and durability, and wrote six cross-linked pages: commitments, personal logistics, themes, open questions, a source evidence table, and a quickstart. Receipts, promotions and newsletters didn't make the cut. That's the point.

And then the fun part — you can just ask it things:

A terminal chat where openwiki personal is asked what bills and commitments are due this week and answers with a short grounded list, sensitive details blurred
One question, answers grounded in the wiki: a bill due today, a coaching call, a delivery failure to chase. (Sensitive details blurred)

Because the wiki is plain markdown, a tiny docsify server also turns it into a local website — sidebar, full-text search, and evidence-linked tables:

The personal wiki rendered as a website showing a Personal Logistics page with tables of items, due dates, status and evidence links, account numbers blurred
The same markdown, browsed at localhost:3054: dates, statuses, and evidence links per row. (Account details blurred)

Field note

The classification policy is the underrated feature. Every item gets a priority and a durability (ephemeral / durable / recurring), and only high-signal durable items reach the canonical pages. My inbox's thirty-plus newsletters and receipts were read, weighed, and correctly ignored. A second brain that hoards everything is just a second inbox.

Demo: documenting this very website with one command

For the finale I pointed OpenWiki at the repository you're reading right now — omkamal.github.io, 420 files of articles and cheatsheets with zero documentation — and ran code mode:

$ cd ~/omkamal.github.io
$ openwiki --update --print

Created the initial generated wiki entrypoint at openwiki/quickstart.md

$ git status --short
 M CLAUDE.md        # OPENWIKI block appended
?? .github/         # scheduled openwiki-update.yml workflow
?? AGENTS.md        # agent guidance, created
?? openwiki/        # the generated wiki

One command produced the wiki and the recurrence machinery: an AGENTS.md, a CLAUDE.md block that tells coding agents to read the wiki first, and a scheduled GitHub Actions workflow that will keep refreshing it. A follow-up prompt expanded the wiki to four cross-linked pages — quickstart, site architecture, publishing workflow, and a source map:

The generated repository wiki rendered in a browser: quickstart page describing the site, with sidebar entries for site architecture, publishing an article, and source map
The wiki OpenWiki wrote for this site — quickstart, architecture, publishing workflow, source map — rendered with docsify
Full circle: the article you are reading was added to this site by following the publishing-workflow page that OpenWiki itself generated. The agent documented how to publish an article; the article about the agent was published by following its documentation.

Watch the full walkthrough

The complete 13-minute video covers everything in motion — the animated pipeline, the install from a fresh clone, the live Gmail demos, and the repo run — with every diagram synced to the narration:

YouTube thumbnail: OpenWiki, the AI agent that writes your docs — full demo
OpenWiki: AI Agent That Auto-Writes Your Docs & Turns Gmail Into a Second Brain (Full Demo) — 12:49

Why it matters

Four takeaways survived contact with reality:

  • Agent-written documentation is practical today — not a research demo. The output above is real, and it was cheap.
  • Guardrails are the product. A docs-only write policy enforced by the backend is what makes it safe to run an agent on a schedule, unattended.
  • Recurrence beats heroics. The scheduled workflow plus the snapshot gate means the wiki stays fresh without anyone remembering to run anything.
  • Your knowledge stays local. Both brains are plain markdown on your machine — chat with them, browse them, grep them, back them up.
Honest caveats: ingestion runs consume model quota (a ChatGPT subscription via the openai-chatgpt provider avoids per-token billing); connector auth setup has a few sharp edges; and as with any young project, expect the occasional rough patch — I hit a test-isolation bug and sent the fix upstream (PR #334).

References

Illustrations generated with Google's Nano Banana image model; diagrams use Font Awesome Free icons (CC BY 4.0, Fonticons, Inc.). Personal details in demo screenshots are blurred.