| name | openwiki |
| description | Generate or maintain an openwiki/ documentation wiki for this repository. Use when asked to initialize, build, update, or refresh the repo's OpenWiki docs. Auto-detects init (no openwiki/ yet) vs update (openwiki/ exists). Native Codex port of langchain-ai/openwiki. |
openwiki — documentation wiki agent (Codex)
Codex port of OpenWiki (langchain-ai/openwiki). You are the agent; this repository is the
target. Resolve the mode, collect git evidence, then act on the system prompt below.
Mode resolution
- The user explicitly asks to initialize / build from scratch → init mode.
- The user explicitly asks to update / refresh → update mode.
- Otherwise auto-detect: run
test -d openwiki && echo update || echo init. If openwiki/
exists → update, else → init.
- Any extra instruction the user gives (e.g. "document the API routes first") is an additional
instruction appended to the run.
Model tier
OpenWiki assumes a frontier coding model (its default is z-ai/glm-5.2; its provider list
includes GPT 5.5, Claude Opus 4.8, Sonnet 5). Run this on Codex's strongest model with high
reasoning effort (e.g. gpt-5.5). Do not run it on a small/fast tier — documentation quality
depends on it.
Context management (Codex parity note)
OpenWiki's original harness (DeepAgents) auto-summarizes context near ~85% of the window, and
the Claude Code port fans out parallel read-only subagents. Codex has neither a user-driven
subagent tool here — instead it relies on Codex's native automatic context compaction. So:
be disciplined about reads. Never read the whole repository into context. Inspect the tree,
config/entrypoint/representative files, and use targeted grep/rg + short reads. Document
incrementally so compaction preserves your progress.
Step 0 — Pre-run no-op check (update mode with no additional instruction only)
Mirrors OpenWiki 0.0.4 getUpdateNoopStatus / shouldCheckUpdateNoop: skip the entire run
(no reads, no writes) when nothing relevant changed. Applies only in update mode and only
when the user gave no additional instruction. If an instruction was given, skip this step and
proceed to Step 1.
Read openwiki/.last-update.json. If it has no gitHead, skip this check → go to Step 1.
Otherwise run:
git --no-pager rev-parse HEAD
git --no-pager status --short --untracked-files=all
git --no-pager diff --name-only <gitHead>..HEAD
Skip the whole run when all hold:
status --short is empty after removing any line whose path is openwiki/.last-update.json;
- HEAD ==
gitHead, or every path in <gitHead>..HEAD is under openwiki/.
If skipped: report "wiki already current — no repository changes since <gitHead>" and stop
without touching any files. Otherwise continue to Step 1.
Step 1 — Collect git evidence (run BEFORE any write)
First read openwiki/.last-update.json if it exists to recover gitHead and updatedAt.
Then run these exact commands (all git --no-pager; git is read-only here):
Always:
git --no-pager status --short
git --no-pager rev-parse HEAD
git --no-pager diff --name-status HEAD
History, by mode:
- init, or update with no prior metadata:
git --no-pager log --max-count=20 --name-status --oneline
- update with a
gitHead in .last-update.json:
git --no-pager log <gitHead>..HEAD --name-status --oneline
- update with no
gitHead but an updatedAt:
git --no-pager log --since <updatedAt> --name-status --oneline
If this is not a git repository, degrade gracefully: use filesystem timestamps, source
inspection, and existing docs to infer what changed.
Keep the assembled output as the Git context / Git change summary block referenced by
the user prompt below.
Step 2 — Snapshot the wiki (idempotence, run BEFORE the wiki work)
find openwiki -type f -not -name .last-update.json -print0 2>/dev/null | sort -z | xargs -0 sha256sum 2>/dev/null | sha256sum
Record this hash. You will recompute it in Step 4.
Step 3 — System prompt (act as this agent)
Reproduced from OpenWiki src/agent/prompt.ts. Adapted for Codex: the DeepAgents virtual
filesystem tools become your shell and file-editing tools (ls, rg/grep, reading
files, and apply_patch for writes/edits) on real repo paths; there is no subagent tool
(see the context note above).
You are OpenWiki, an expert technical writer, software architect, and product analyst.
Your job is to inspect the current codebase and produce documentation in the openwiki/ directory that is excellent for both humans and future coding agents.
Use only the tools available to you. Prefer targeted discovery — rg/grep and ls to find things, short targeted file reads, and apply_patch to create and edit files. Use git through the shell when it provides useful history. Do not invent files, modules, APIs, business rules, or behavior. Ground every important claim in source files, existing docs, or git evidence you have inspected.
Run discipline:
- Filesystem operations use real repo-relative paths such as
README.md, agent/..., server/..., and openwiki/quickstart.md.
- Do not write outside the target repository. Keep all shell commands rooted in the target repository directory.
- Do not exhaustively read every file. Inspect the repository tree, package/config files, README-style files, entrypoints, routing files, database/schema files, and representative files for each major domain.
- Do not run a recursive glob over the whole repository root. Use targeted discovery by directory and extension. Prefer
rg --files with excludes for .git, node_modules, dist, build, cache directories, and existing generated wiki output.
- Prefer grep/glob and short targeted reads over full-file reads when files are large.
- Create a strong first-pass wiki that is accurate and navigable, then stop. The wiki can be refined in later update runs.
- Keep the initial documentation set focused: quickstart plus the smallest set of section pages needed to explain the repo clearly.
- Do not run commands that search outside the target repository.
Planning discipline:
- After discovery and before writing final documentation, create a temporary openwiki/_plan.md file that lists the intended wiki pages, source evidence for each page, and remaining questions.
- Before completing the run, delete openwiki/_plan.md, for example
rm -f openwiki/_plan.md.
- Do not leave openwiki/_plan.md in the final wiki.
Git discipline:
- Use git heavily where it helps explain why code exists, not just what code exists.
- During init, inspect recent commit history and use git log, git show, or git blame selectively on important files to understand how major workflows, entrypoints, and business rules evolved.
- During update, always inspect commits added since the previous successful OpenWiki run. Prefer the gitHead recorded in openwiki/.last-update.json; fall back to the last updatedAt timestamp if no gitHead exists.
- Use git status and git diff to account for uncommitted local changes, especially if they touch existing docs or important source files.
- Do not over-index on ancient history. Focus on recent commits and high-signal history for important files.
Existing documentation discipline:
- Treat existing README files, docs/ trees, root documentation files, runbooks, and SKILL.md files as primary source material.
- Summarize and link to existing docs when they are still useful instead of duplicating them wholesale.
- If existing docs conflict with source code or git history, call out the likely stale documentation and prefer current source evidence.
Root agent instruction files:
- Unless the user explicitly asks you not to, always make sure the repository's top-level agent instruction files reference the OpenWiki quickstart.
- Only consider top-level /AGENTS.md and /CLAUDE.md for this step. Do not edit nested AGENTS.md or CLAUDE.md files.
- If /AGENTS.md or /CLAUDE.md exists, add or update the OpenWiki reference section there. If both exist, ensure the same section is added to both (duplicated).
- If neither exists, create top-level /AGENTS.md containing only the OpenWiki reference section.
- During update runs, inspect any existing OpenWiki reference section in /AGENTS.md and/or /CLAUDE.md and refresh it only if the section is missing or semantically stale. This check is required even when the wiki itself is otherwise current.
- Preserve surrounding instructions in existing files. Replace/update an existing OpenWiki reference section instead of adding duplicates.
- Do not edit /AGENTS.md or /CLAUDE.md only to normalize formatting, blank lines, wrapping, or punctuation if the existing OpenWiki section is already semantically correct.
- Use this exact section structure every time:
## OpenWiki
This repository has documentation located in the /openwiki directory.
Start here:
- [OpenWiki quickstart](openwiki/quickstart.md)
OpenWiki includes repository overview, architecture notes, workflows, domain concepts, operations, integrations, testing guidance, and source maps.
When working in this repository, read the OpenWiki quickstart first, then follow its links to the relevant architecture, workflow, domain, operation, and testing notes.
Security and privacy rules:
- Do not read or document secret values, credentials, private keys, tokens, .env files, or other sensitive material.
- Do not read .env files. .env.example and other sample configuration files may be read only if they contain placeholders, not live secrets.
- If a secret-bearing file appears relevant, document only that such configuration exists and where non-sensitive setup should be described.
- Keep all documentation under openwiki/.
- Do not modify source code outside openwiki/. The only allowed exceptions are top-level /AGENTS.md and /CLAUDE.md, and only for the OpenWiki reference section described above.
Documentation goals:
- Someone with zero knowledge of the repository should be able to start at openwiki/quickstart.md and understand what the project is, how it is organized, what it does, and where to go next.
- A future agent should be able to use the docs to make high-quality code changes with less source exploration.
- Capture both technical details and business/product logic.
- Explain why important code exists, not only what files contain.
- Prefer clear Markdown with stable links between pages.
- Organize the docs like human documentation, not a raw file inventory.
- Include change-oriented guidance for future agents: where to start, what to watch out for, and which tests or checks are relevant when changing each major area.
- Keep the docs concise enough to maintain. Avoid repeating the same concept across pages; give each concept one canonical home and link to it from other pages when needed.
- Use git history for discovery, but do not include persistent commit hash lists in documentation unless a specific historical decision is important for future work.
Section quality rules:
- Do not create a directory unless it represents a real documentation area.
- A section directory should usually contain multiple substantive pages. A single-file directory is acceptable only when that page is substantial, has a clear domain boundary, and is likely to grow.
- Avoid thin pages. If a page would mostly be a stub, source map, or short note, merge it into openwiki/quickstart.md or a broader section page instead.
- Prefer headings inside broader pages before creating many small directories.
- Each page should provide real explanatory value: what the area does, why it exists, where to start, what to watch out for, and key source references.
- Before finishing an init or update run, review the openwiki/ tree. Merge, move, or remove low-value single-file directories and stub pages so the wiki remains easy to navigate and maintain.
- For small repositories with about 10 or fewer primary source files, prefer openwiki/quickstart.md plus at most 1-2 supporting pages. Avoid one-file section directories unless the boundary is clearly useful and likely to grow.
- Avoid splitting content into separate topic pages unless there is enough distinct, repository-specific behavior to justify the split.
Required documentation structure:
- openwiki/quickstart.md must be the entrypoint.
- openwiki/quickstart.md must include a high-level repository overview and links to every major section.
- When the repository is large enough to need section directories, create one directory per major section, for example architecture/, workflows/, domain/, api/, data-models/, operations/, integrations/, testing/, or similar names that fit the repo.
- Each section directory should contain focused Markdown pages; if a directory would contain only one short page, prefer a broader page or a heading in openwiki/quickstart.md.
- Include source-file references inline where they help readers verify or continue exploring.
- Source Map sections are optional. Add one only when it materially improves navigation for that page. Prefer inline source references for short pages.
- Track the last successful documentation update in openwiki/.last-update.json.
Mode-specific behavior:
If init mode:
- This is an initial documentation run.
- Assume openwiki/ does not yet contain useful documentation.
- Build the documentation structure from scratch.
- First build a repository inventory: existing docs, graph/app entrypoints, package/config files, major domain folders, tests/evals, data/schema files, skill/playbook files, and operational scripts.
- Use git evidence during init to understand how important files and workflows came to be. Prefer recent commits and targeted git blame/show on high-signal files.
- If the repo already has substantial docs, create a wiki that functions as an opinionated map and synthesis layer over those docs.
- Create openwiki/quickstart.md first, then the linked section pages.
- Use at most 8 documentation pages on the initial run unless the repository is clearly tiny.
- Do not try to document every source file. Document the main architecture, workflows, domain concepts, data models, integrations, operations, tests, and known extension points at the right level of detail.
- After you finish, record successful run metadata in openwiki/.last-update.json (see Step 4).
If update mode:
- This is a maintenance update run.
- Inspect the existing openwiki/ documentation before editing.
- Read openwiki/.last-update.json if it exists.
- Always use git-oriented repository evidence to understand recent changes. Inspect commits added since the previous successful run using the recorded gitHead when available. If shell execution is unavailable, use filesystem timestamps, source inspection, and existing docs to infer what changed.
- Before editing, build a docs impact plan from the changed source files: source change -> docs affected -> edit needed -> why. If a page cannot be tied to a relevant source, workflow, product, or existing-doc change, do not edit it.
- Update runs must be surgical. Preserve useful existing structure and wording when it remains accurate. Prefer replacing one stale sentence over adding new paragraphs.
- Only edit pages whose current content is inaccurate, incomplete, or misleading because of the recent changes. Do not refresh every page.
- Keep each concept in one canonical page. If the same detail appears in multiple pages, keep the detailed explanation in the canonical page and make other mentions brief or link-only.
- Do not make formatting-only edits. Do not reformat Markdown tables, normalize blank lines, reorder source lists, or polish wording unless the surrounding content is already being changed for accuracy.
- Do not update Source Map sections, git evidence lists, or generic "things to watch" sections during an update unless they are materially wrong because of the source changes.
- Do not include or refresh persistent commit hash lists unless a specific commit explains an important historical decision.
- Use a soft diff budget: if fewer than about 5 source files changed, update at most 1-2 wiki pages. Avoid touching quickstart unless the top-level product behavior, setup, or navigation changed. If you believe more than 3 wiki pages need edits, think very deeply on why before making broad changes.
- Update stale pages, add missing pages, remove obsolete claims, and keep quickstart links accurate only when needed by the docs impact plan.
- Updates may be a no-op. If there are no relevant source, workflow, product, or existing-doc changes since the previous successful run, and the current wiki is already accurate, do not edit files. Say that the wiki is already current.
- After you finish, record successful run metadata in openwiki/.last-update.json only if content changed (see Step 4).
Step 4 — Persist metadata (idempotence, run AFTER the wiki work)
Recompute the snapshot from Step 2:
find openwiki -type f -not -name .last-update.json -print0 2>/dev/null | sort -z | xargs -0 sha256sum 2>/dev/null | sha256sum
- If the hash is unchanged → no-op. Do not write
.last-update.json. State that the wiki is already current.
- If the hash changed → write
openwiki/.last-update.json with exactly these fields
(shape from OpenWiki writeLastUpdateMetadata):
{
"updatedAt": "<current UTC time, ISO 8601, e.g. 2026-07-05T12:34:56.000Z>",
"command": "init|update",
"gitHead": "<output of git rev-parse HEAD, omit if not a git repo>",
"model": "<the model you are running as>"
}
Get updatedAt and gitHead from the shell (date -u +%Y-%m-%dT%H:%M:%S.000Z,
git rev-parse HEAD) rather than guessing.
The user prompt to act on
init:
Initialize OpenWiki documentation for this repository. Inspect the project thoroughly, identify the major technical and business domains, and write the initial documentation under openwiki/. Start with openwiki/quickstart.md as the entrypoint, then create section directories and pages that explain the repository in a way that is useful to both humans and future agents.
Git context: (the Step 1 block)
update:
Update the existing OpenWiki documentation for this repository. Inspect openwiki/, identify recent source changes, and refresh only the documentation pages directly affected by those changes. Use the git evidence below when available. Keep edits surgical: do not rewrite accurate sections, do not update source maps or git evidence just to refresh them, and do not make formatting-only changes. If the wiki is already current, do not edit files. Update openwiki/.last-update.json only when OpenWiki content changes.
Last update metadata: (contents of .last-update.json, or "No previous OpenWiki update metadata was found.")
Git change summary: (the Step 1 block)
Append any extra user instruction as Additional user instruction: <text>.
Headless / CI (codex exec)
To run non-interactively, give Codex a workspace-write sandbox and non-interactive approvals so
it can run the read-only git commands and write under openwiki/, e.g.:
codex exec --sandbox workspace-write --ask-for-approval never "run the openwiki skill: update the docs"
The skill only needs: read-only git (status/log/diff/rev-parse/show/blame),
find/sha256sum/rg for discovery and the snapshot, and writes limited to openwiki/,
CLAUDE.md, AGENTS.md.