/llm-wiki:bootstrapfrom llm-wiki
Bootstrap an LLM-maintained wiki for the current project. Use when a user asks to create, initialize, or refresh a project wiki, LLM wiki, QMD wiki, or codebase knowledge base for Claude Code, Codex, Pi, or OpenClaw.
Ships in llm-wiki. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Create a self-maintaining project wiki under wiki/ for the current repository. Ground every page in actual source files and git history. Do not invent architecture, data models, routes, or decisions.
rg.~/wikis/master/wiki/, ~/wikis/main/wiki/, <parent-of-project>/wikis/master/wiki/, and <parent-of-project>/wikis/main/wiki/.Read the project root and identify:
Gemfile, package.json, go.mod, Cargo.toml, pyproject.toml, requirements.txt, composer.json, pom.xml, build.gradle, *.sln, *.csproj, or equivalents.dirname "$(git rev-parse --show-toplevel)".~/wikis/master/wiki/~/wikis/main/wiki/<parent-of-project>/wikis/master/wiki/<parent-of-project>/wikis/main/wiki/<parent-of-project>/wikis/master/wiki/. Wait for the user's answer before continuing.index.md, patterns.md, learnings.md, and log.md with minimal grounded headings. Do not invent cross-project facts.Adapt all later page names and source reads to what the project actually uses.
Create:
mkdir -p wiki raw/notes
Create or update:
wiki/index.md: catalog of wiki pages.
wiki/log.d/: directory of append-only <timestamp>-<slug>.md changelog fragments (one file per change — conflict-free across branches/worktrees).
wiki/log.md: the COMPILED changelog, regenerated from wiki/log.d/*.md by .llm-wiki/compile-log.sh. Seed it with the header plus an empty generated block so the compiler is idempotent:
# Wiki Changelog
Append-only log of all wiki operations.
<!-- BEGIN GENERATED WIKI LOG FRAGMENTS -->
<!-- END GENERATED WIKI LOG FRAGMENTS -->
Never hand-edit the content between the markers. On an EXISTING project whose log.md predates fragments, leave the old hand-written ## entries in place below the markers — compile-log.sh preserves them as legacy and prepends compiled fragments above, so migration is lossless.
wiki/gaps.md: open questions, missing coverage, and uncertainty.
Create stack-appropriate subdirectories only when useful, such as models/, controllers/, services/, components/, packages/, modules/, commands/, or apis/.
Add .qmd/ to .gitignore if it is not already ignored.
Read source files before writing. Prefer fewer, richer pages over many thin pages.
Before writing pages, search the detected or user-provided main cross-project wiki when it exists. Read relevant pages such as patterns.md, learnings.md, decisions.md, architecture.md, and index.md if present. Use this context to align project wiki structure and note reusable patterns, but only cite or summarize cross-project facts from pages actually read.
Generate pages that apply to the project:
wiki/data-model.md: persistent entities, relationships, constraints, indexes, and Mermaid ER diagram when useful.wiki/routes.md, wiki/api.md, or wiki/commands.md: external interaction surface.wiki/architecture.md: major components, boundaries, patterns, integrations, and deployment clues.wiki/dependencies.md: key dependency choices and visible rationale.wiki/decisions.md: lightweight ADRs from source and git history.wiki/active-areas.md: recently active areas from git history.Use this frontmatter for pages where it helps:
---
title: Page Title
type: architecture
source: path/to/source
created: YYYY-MM-DD
updated: YYYY-MM-DD
tags: [architecture]
---
Include a one-sentence TLDR near the top of each page. Use [[page-name]] backlinks between related pages.
Read generated pages and compare them against the codebase.
Update wiki/gaps.md with:
Update wiki/index.md with:
Write the bootstrap changelog entry as a fragment wiki/log.d/<timestamp>-bootstrap.md (then run .llm-wiki/compile-log.sh . to regenerate wiki/log.md):
## [TIMESTAMP] bootstrap
**Action:** Initial wiki bootstrap from codebase
**Pages created:** ...
**Pages updated:** ...
**Gaps found:** ...
**Source:** Codebase read + git history
Create .llm-wiki/ if it does not exist, then create or update .llm-wiki/config.json.
Config shape:
{
"headless_agent": "<claude-or-codex-or-pi-or-openclaw>",
"context_agents": ["claude", "codex", "pi", "openclaw"],
"openclaw_agent_id": "<configured-agent-id-or-null>",
"automation_enabled": false,
"external_provider_access_approved": false,
"main_wiki_path": "<detected-or-provided-main-wiki-path>",
"created_by": "<current-tool>"
}
Rules:
headless_agent must be exactly one of claude, codex, pi, or openclaw. Reject any other value instead of silently falling back to a different agent.context_agents is the supported context list and should include claude, codex, pi, and openclaw.automation_enabled and external_provider_access_approved false
unless the user separately approves persistent automation and provider access.openclaw agents list --json, select the single agent whose workspace resolves to the project root, and persist its id as openclaw_agent_id. Do not guess main; agent IDs and the default agent can be customized.openclaw_agent_id or write null when no matching project-workspace agent is known..llm-wiki/config.json is missing, first check for legacy automation from older llm-wiki versions before treating this as a first bootstrap..llm-wiki/refresh-wiki.sh, .llm-wiki/post-commit-refresh.sh, .git/hooks/post-commit, known llm-wiki-<project-slug> systemd or launchd scheduler files, and existing cron entries for codex exec, claude -p, pi -p, pi --print, or openclaw agent --local.headless_agent and record it in .llm-wiki/config.json.headless_agent to the current tool: claude for Claude Code, codex for Codex, pi for Pi, or openclaw for OpenClaw.headless_agent unless the user explicitly asks to switch it.headless_agent, still update wiki context for the current tool, but do not change scheduler or post-commit ownership.headless_agent.Add a wiki section to all agents listed in context_agents:
CLAUDE.mdAGENTS.mdAGENTS.mdAGENTS.md in the configured OpenClaw agent workspaceCreate files if absent. Append or replace only the managed wiki section between the markers below. Do not replace unrelated instructions or any unmarked user-authored ## Wiki section.
When any of Codex, Pi, and OpenClaw share the same project workspace, update AGENTS.md once; do not duplicate the managed wiki block.
Legacy migration:
llm-wiki versions wrote an unmarked generated ## Wiki section.## Wiki section clearly matches the generated llm-wiki template, wrap or replace it with the managed marker block below.wiki/index.md, wiki/log.md, wiki/gaps.md, raw/notes/, and the QMD/rg query protocol.## Wiki sections that do not match the generated template, and add the managed block separately.Instruction content:
<!-- BEGIN LLM WIKI -->
## Wiki
This project has an LLM-maintained knowledge base in `wiki/`.
- `wiki/` — project knowledge pages maintained by the agent
- `wiki/index.md` — catalog of all pages
- `wiki/log.md` — compiled changelog (regenerated from `wiki/log.d/*.md` fragments; never hand-edited)
- `wiki/gaps.md` — known gaps and open questions
- `raw/notes/` — manually added reference material
Always check `wiki/` before answering questions about this project's architecture, patterns, or decisions.
When you learn something new about the project or make a decision:
1. Create or update the relevant page in `wiki/`
2. Update `wiki/index.md` if a new page was created
3. Add a `wiki/log.d/<timestamp>-<slug>.md` fragment (never hand-edit the compiled `wiki/log.md`; it is regenerated from fragments by `.llm-wiki/compile-log.sh`)
Never hallucinate. Ground everything in code or existing wiki pages. If unsure, note it in `wiki/gaps.md`.
Use `[[page-name]]` backlinks between wiki pages.
Query protocol:
1. Read `.llm-wiki/config.json` when it exists.
2. Run `qmd query "<topic>"` or `qmd search "<topic>"` when QMD is available.
3. Fall back to `rg "<topic>" wiki/`.
4. Check the configured `main_wiki_path` before making architectural decisions when it exists.
5. Also check default main cross-project wiki paths when they exist:
- `~/wikis/master/wiki/`
- `~/wikis/main/wiki/`
- `<parent-of-project>/wikis/master/wiki/`
- `<parent-of-project>/wikis/main/wiki/`
<!-- END LLM WIKI -->
Install session context for supported agents separately from headless maintenance ownership.
Claude Code context:
.claude/settings.json exists, or it can be safely created, merge a SessionStart hook that prints wiki/index.md and recent wiki/log.md.SessionStart hook as a context hook only. It does not mean Claude owns scheduled refresh.Codex context:
AGENTS.md contains the wiki section from Step 5.AGENTS.md; do not invent a Codex hook system if one is not available.Pi context:
AGENTS.md contains the wiki section from Step 5.AGENTS.md and CLAUDE.md; treat AGENTS.md as the primary llm-wiki context surface for Pi..pi/SYSTEM.md because it replaces Pi's default system prompt..pi/APPEND_SYSTEM.md by default. Use AGENTS.md unless the user explicitly asks for Pi-specific system prompt customization.OpenClaw context:
AGENTS.md contains the wiki section from Step 5. OpenClaw auto-injects the AGENTS.md in its configured agent workspace at the start of every session.openclaw as headless_agent. If it is not, report the workspace mismatch instead of claiming the project AGENTS.md will be injected.--deliver, --channel, --reply-channel, --reply-to, and --to
from every OpenClaw maintenance command.Do not install scheduled or post-commit automation unless the user separately
approves it after seeing the provider, files, hooks, and activation commands.
Without that approval, leave both consent flags false and report the manual
refresh commands instead.
If the current tool is not the configured headless_agent, update session context for the current tool and validate/report the existing automation owner. Do not rewrite scheduler or post-commit ownership unless automation is missing, unsafe, or the user asks to repair or switch ownership.
The scheduler and post-commit hook must use the configured
.llm-wiki/config.json headless_agent. Do not hand-write provider wrappers.
Resolve the installed llm-wiki package root by walking up from the active
skill until the ancestor containing both templates/ and the package manifest
is found. This works for native and generated host skill paths. Copy these
canonical files from <package-root>/templates/, make them executable, and keep
the same copies in .llm-wiki/:
post-commit-refresh.shrefresh-wiki.shcompile-log.shinstall-systemd-scheduler.shCopy the runner, compiler, and validated config into
$(git rev-parse --git-common-dir)/llm-wiki/. Wire the common post-commit
hook to call the shared runner with
--project "$(git rev-parse --show-toplevel)", falling back to the checkout
copy only when the shared runner is absent. This makes the primary checkout's
installed runtime authoritative for every linked worktree, including older
branches with stale ignored .llm-wiki files or config.
After the separate automation approval, on Linux run:
.llm-wiki/install-systemd-scheduler.sh --project "$(git rev-parse --show-toplevel)"
The installer reconciles all linked worktrees to one non-persistent timer for
the repository's primary checkout, removes and stops obsolete managed units,
serializes all repositories through one machine-wide lock, and enforces a 4 GiB
memory limit with no swap. The timer drains already queued commits; it does not
launch a direct refresh against whichever checkout happened to install it.
When automation is not approved, do not enable a timer; the upgrade path uses
--disabled to reconcile old units without activating maintenance. On
non-systemd platforms, leave the scripts installed, record the scheduler gap in
wiki/gaps.md, and report the manual drain command.
Preserve existing hooks and unrelated hook logic. The bundled runner reads the
canonical shared owner config and dispatches to exactly one of Claude Code,
Codex, Pi, or OpenClaw. It never falls back to a different provider. An
OpenClaw owner requires a validated openclaw_agent_id and never uses delivery,
channel, reply, or recipient flags. Provider, QMD, and Git ref execution is
time-bounded. A repository-wide circuit stops automatic provider launches after
two consecutive failed batches or more than 25 pending sources. Each worker
handles at most one batch of 10 sources, while the scheduler keeps draining
later batches without starting concurrent provider processes.
The supported provider set is Claude Code, Codex, Pi, and OpenClaw. The copied
config must preserve openclaw_agent_id when OpenClaw owns maintenance; the
runtime rejects an unsupported owner or a missing/invalid OpenClaw agent ID
instead of falling back to another provider.
Transactional refresh contract (the bundled script implements all of these; any hand-edit must keep them):
$(git rev-parse --git-common-dir)/llm-wiki/pending/ before attempting the worker lock. Never use the committing checkout or first/main checkout as an agent workspace, log destination, QMD cache, staging area, or commit target.llm-wiki/refresh in <shared-git-dir>/llm-wiki/refresh-worktree, based/rebased on the current remote default branch. The agent inspects source commits with git show; it writes only under the managed worktree's wiki/. Publish only this branch to origin; never dirty or push the protected default branch.wiki/, copy the committing checkout's untracked local wiki into the disposable worktree before invoking the agent. Never replace an already-established refresh-branch wiki, follow a top-level wiki symlink, or copy any path outside wiki/.refs/llm-wiki/refresh-lock. Its Git blob records PID, time, process-start identity, and nonce; git update-ref <ref> <new> <old> makes stale replacement single-winner, while ownership-checked deletion prevents an old worker from releasing a successor's lock. Check the wait deadline and sleep after every failed acquisition attempt. One worker snapshots at most 10 queued SHAs and runs one refresh agent for that batch. A busy worker leaves new queue entries intact for a later worker instead of dropping them.LLM-Wiki-Source: <sha> commit-message paragraph when the batch creates a wiki commit, then atomically update refs/llm-wiki/receipts/<sha> for every successful source before queue deletion. Check receipt refs first and commit history as migration fallback before invoking the agent. This makes both changed and no-op batches replay-safe after a crash between completion and acknowledgement.refs/llm-wiki/sources/<sha> when a source is queued and delete it in the same ref transaction that writes its durable receipt. Backfill pins for pre-upgrade pending and quarantined records in batches of 64 by default (LLM_WIKI_MAX_SOURCE_PIN_BATCH). Reconstruct empty crash-left .<sha>.<pid> queue files when their source commit is available; retain unavailable records for diagnosis. Refuse to invoke or acknowledge a batch whose selected SHA is not an available commit.wiki/. Compile wiki/log.md, force-stage only wiki/ so intentionally ignored wikis persist, and commit with both recursion guards (HIVE_SKIP_LLM_WIKI_POST_COMMIT=1 and git -c core.hooksPath=/dev/null). Fetch and merge the remote refresh branch, then push only llm-wiki/refresh; retain local work when fetch, merge, or push fails.<shared-git-dir>/llm-wiki/failed/ and open the repository-wide circuit. Continue queueing new sources without launching a provider. Never delete failed source data or automatically run a quarantined source again. User checkout bytes and branch refs must remain unchanged.timeout or gtimeout. If no bounded
runner is available, fail closed before starting a provider and retain the
queue. Open the circuit before a provider launch when pending sources exceed
25; cap every batch at 10 sources and bound the changed-path prompt context.
The circuit can be retried only through .llm-wiki/post-commit-refresh.sh --retry-failed <sha|all>; process one bounded batch per invocation and clear
it only when no queued or quarantined sources remain.<shared-git-dir>/llm-wiki/.Post-commit hook idempotency:
.git/hooks/post-commit block marked # BEGIN LLM WIKI POST-COMMIT and # END LLM WIKI POST-COMMIT. The block honors HIVE_SKIP_LLM_WIKI_POST_COMMIT so the script's own wiki commit cannot recurse..llm-wiki/post-commit-refresh.sh only when they are clearly attributable to llm-wiki..llm-wiki/post-commit-refresh.sh must sanitize Git hook-local environment variables before launching nested tools. Collect unset arguments from git rev-parse --local-env-vars and run codex exec, claude -p, pi, openclaw agent, qmd update, and qmd embed through env -u ... so variables such as GIT_INDEX_FILE, GIT_DIR, and GIT_WORK_TREE cannot leak into agent startup, plugin marketplace checkouts, or QMD indexing. Keep local Git commands that inspect the triggering commit, such as git diff-tree, in the hook context.The post-commit script detects relevant changed files and coalesces them into one focused headless refresh per queued batch:
Gemfile, package.json, go.mod, Cargo.toml, requirements.txt, pyproject.toml, composer.json.app/, src/, lib/, test/, tests/, spec/,
templates/, and config/ changes.For headless_agent: "codex", the runtime dispatcher must use codex exec -C "$refresh_root" "$prompt" and never use claude -p, pi -p, or openclaw agent.
For headless_agent: "claude", the runtime dispatcher must use claude -p "$prompt" --allowedTools "Bash,Read,Edit,Write" --add-dir "$refresh_root" --max-budget-usd 0.50 from the managed worktree and never use codex exec, pi -p, or openclaw agent.
For headless_agent: "pi", the runtime dispatcher must use pi -p --no-session --tools read,bash,edit,write,grep,find,ls "$prompt" from the managed worktree and never use claude -p, codex exec, or openclaw agent.
For headless_agent: "openclaw", the runtime dispatcher must use openclaw agent --local --agent "<openclaw_agent_id>" --message "$prompt" --json --timeout 1800 from the managed worktree without any delivery, channel, reply, or recipient flag. Never use claude -p, codex exec, or pi.
After a queued batch succeeds, run bounded qmd update and qmd embed from the managed refresh worktree with their cache outside user checkouts, then create <wikis-root>/.sync-needed/<project-name> when a supported sync directory exists. Failed batches retain their queue and do not index discarded work.
Check whether QMD is installed with command -v qmd.
If QMD is installed:
qmd collection add wiki/ --name "$(basename "$(git rev-parse --show-toplevel)")"
qmd embed
If QMD is not installed, do not install it automatically. Tell the user QMD is optional but recommended for semantic wiki search, then suggest:
npm install -g @tobilu/qmd
# or
bun install -g @tobilu/qmd
Mention that the first qmd embed may download local models. Ask whether they want to install QMD now or continue with the rg fallback for this bootstrap. If they continue without QMD, skip indexing and report that rg fallback is available.
Report:
wiki/gaps.md.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub ivankuznetsov/agent-plugins --plugin llm-wiki5 skills in this plugin
/researchSearch QMD-indexed project and main cross-project LLM wikis for past patterns, decisions, solutions, and pitfalls before planning or implementation. Use before feature planning, bug fixing, refactoring, architecture work, or code changes when a project wiki may exist./upgradeUpgrade an existing project's managed llm-wiki structure without rerunning broad wiki bootstrap. Use when a user asks to migrate, update, or upgrade project-local .llm-wiki scripts, hooks, or changelog structure after installing a newer llm-wiki release./wiki-planPlan a feature, bugfix, refactor, or improvement with wiki research first. Searches project and main cross-project wiki context, synthesizes Past Knowledge, then delegates to Compound Engineering planning when available or writes a standalone plan outline./wiki-statusReport llm-wiki maintenance status. Use only when the user explicitly mentions llm-wiki and asks for its installed version, update availability, project wiki structure, consent state, or refresh queue health. Do not select this skill for generic plugin, documentation, project-context, or upgrade questions.