From llm-wiki
Creates or refreshes a grounded LLM-maintained project wiki (wiki/) that tracks architecture, decisions, and source facts without hallucination.
How this skill is triggered — by the user, by Claude, or both
Slash command
/llm-wiki:bootstrapThe summary Claude sees in its skill listing — used to decide when to auto-load this 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.
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.md: append-only log of wiki operations.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:
Append to 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>",
"context_agents": ["claude", "codex", "pi"],
"main_wiki_path": "<detected-or-provided-main-wiki-path>",
"created_by": "<current-tool>"
}
Rules:
context_agents is the supported context list and should include claude, codex, and pi..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, or pi --print.headless_agent and record it in .llm-wiki/config.json.headless_agent to the current tool: claude for Claude Code, codex for Codex, or pi for Pi.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.mdCreate 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 both Codex and Pi are listed, 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` — append-only changelog
- `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. Append an entry to `wiki/log.md`
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.Always ensure scheduled wiki refresh automation exists for the configured headless_agent. Do not ask whether to add it.
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 must use the configured .llm-wiki/config.json headless_agent.
Create .llm-wiki/refresh-wiki.sh and make it executable. It should run the configured headless agent's CLI from the project root:
headless_agent: "codex": use codex exec -C "<project-root>" "<refresh prompt>".headless_agent: "claude": use claude -p "<refresh prompt>" with the same refresh intent.headless_agent: "pi": use pi -p --no-session --tools read,bash,edit,write,grep,find,ls "<refresh prompt>" with the same refresh intent.For Codex-owned headless automation, never write automation that shells out to claude or claude -p. Do not fall back from Codex automation to Claude if codex is missing; report the missing codex CLI instead.
For Claude-owned headless automation, never write automation that shells out to codex exec. Do not fall back from Claude automation to Codex if claude is missing; report the missing claude CLI instead.
For Pi-owned headless automation, never write automation that shells out to codex exec or claude -p. Do not fall back from Pi automation to Claude or Codex if pi is missing; report the missing pi CLI instead.
Codex refresh script shape:
#!/usr/bin/env bash
set -euo pipefail
project_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$project_root"
codex exec -C "$project_root" "Refresh this project's LLM wiki. Read .llm-wiki/config.json, AGENTS.md, wiki/index.md, wiki/gaps.md, and recent wiki/log.md entries first. If .llm-wiki/config.json contains main_wiki_path, search that exact path before changing project pages. Also search default main cross-project wiki paths when they exist: ~/wikis/master/wiki/, ~/wikis/main/wiki/, ../wikis/master/wiki/, and ../wikis/main/wiki/. Inspect recent git history and changed source files. Update stale wiki pages, update wiki/index.md when page coverage changes, append wiki/log.md, and record uncertainty in wiki/gaps.md. Do not invent facts."
Claude Code refresh script shape:
#!/usr/bin/env bash
set -euo pipefail
project_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$project_root"
claude -p "Refresh this project's LLM wiki. Read .llm-wiki/config.json, CLAUDE.md, wiki/index.md, wiki/gaps.md, and recent wiki/log.md entries first. If .llm-wiki/config.json contains main_wiki_path, search that exact path before changing project pages. Also search default main cross-project wiki paths when they exist: ~/wikis/master/wiki/, ~/wikis/main/wiki/, ../wikis/master/wiki/, and ../wikis/main/wiki/. Inspect recent git history and changed source files. Update stale wiki pages, update wiki/index.md when page coverage changes, append wiki/log.md, and record uncertainty in wiki/gaps.md. Do not invent facts." --allowedTools "Bash,Read,Edit,Write" --max-budget-usd 0.50
Pi refresh script shape:
#!/usr/bin/env bash
set -euo pipefail
project_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$project_root"
pi -p --no-session --tools read,bash,edit,write,grep,find,ls "Refresh this project's LLM wiki. Read .llm-wiki/config.json, AGENTS.md, wiki/index.md, wiki/gaps.md, and recent wiki/log.md entries first. If .llm-wiki/config.json contains main_wiki_path, search that exact path before changing project pages. Also search default main cross-project wiki paths when they exist: ~/wikis/master/wiki/, ~/wikis/main/wiki/, ../wikis/master/wiki/, and ../wikis/main/wiki/. Inspect recent git history and changed source files. Update stale wiki pages, update wiki/index.md when page coverage changes, append wiki/log.md, and record uncertainty in wiki/gaps.md. Do not invent facts."
Install the best available scheduler without prompting:
~/.config/systemd/user/llm-wiki-<project-slug>.service and .timer, then run systemctl --user daemon-reload and systemctl --user enable --now llm-wiki-<project-slug>.timer.~/Library/LaunchAgents/com.llm-wiki.<project-slug>.plist with a 24 hour StartInterval, then run launchctl load..llm-wiki/refresh-wiki.sh daily.Use a stable <project-slug> from the repository basename plus a short hash of the project root to avoid timer name collisions. Replace existing llm-wiki-<project-slug> scheduler files instead of adding duplicates. For cron, wrap the entry with # BEGIN LLM WIKI <project-slug> and # END LLM WIKI <project-slug> markers and replace that block on repeat bootstrap. If scheduler installation fails because the environment lacks systemd, launchd, cron, or permissions, keep .llm-wiki/refresh-wiki.sh, record the failure in wiki/gaps.md, and report the exact command the user can run.
Also install post-commit wiki maintenance automation. Preserve existing hooks; do not overwrite unrelated hook logic. Prefer creating .llm-wiki/post-commit-refresh.sh and wiring .git/hooks/post-commit to call it.
Post-commit hook idempotency:
.git/hooks/post-commit block marked # BEGIN LLM WIKI POST-COMMIT and # END LLM WIKI POST-COMMIT..llm-wiki/post-commit-refresh.sh only when they are clearly attributable to llm-wiki..llm-wiki/post-commit-refresh.sh must acquire a project-local lock, such as .llm-wiki/post-commit.lock, before refreshing. If the lock already exists, exit without starting another refresh. Always release the lock on exit..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, 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 must detect changed files and run focused headless refreshes:
Gemfile, package.json, go.mod, Cargo.toml, requirements.txt, pyproject.toml, composer.json.For headless_agent: "codex", every focused refresh command must use codex exec -C "$project_root" "<focused prompt>" in the background. Never use claude -p.
For headless_agent: "claude", every focused refresh command must use claude -p "<focused prompt>" --allowedTools "Bash,Read,Edit,Write" --max-budget-usd 0.50 in the background. Never use codex exec.
For headless_agent: "pi", every focused refresh command must use pi -p --no-session --tools read,bash,edit,write,grep,find,ls "<focused prompt>" in the background. Never use claude -p or codex exec.
After focused refreshes, run qmd embed in the background when qmd exists, then create <wikis-root>/.sync-needed/<project-name> when the configured or detected main wiki root has a .sync-needed directory. Use the root containing .llm-wiki/config.json main_wiki_path first; otherwise use ~/wikis/.sync-needed/<project-name> for home-based main wikis and <parent-of-project>/wikis/.sync-needed/<project-name> for parent-directory main wikis.
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.Guides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.
npx claudepluginhub ivankuznetsov/llm-wiki