/kb:kbfrom kb
Manages an LLM-maintained knowledge base: compiles raw sources into wiki articles, answers queries, lints coverage, evolves content, and suggests improvements. Activates on wiki-related commands.
Ships in kb. 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.
Main operating skill for LLM-maintained knowledge bases. Five workflows: compile, query, lint, evolve, reflect. All opus-orchestrated with model-aware subagent dispatch.
First action in every invocation: read kb.yaml from the project root. If missing, tell the user to run kb-init and stop.
After reading kb.yaml, extract the report_preferences: block. These are free-text prose instructions the user set via kb-init or /kb-preferences, controlling how outputs are written (audience, register, depth, code_handling, diagrams, self_containment, citations, argument_iteration, notes).
Apply to all generated prose:
If report_preferences: is missing: fall back to factory defaults in plugins/kb/references/report-style-guide.md silently. Mention it once in the first output of the session: "No report_preferences set — using factory defaults. Run /kb-preferences init to customize."
Per-task overrides. If the user's current request explicitly contradicts a stored preference, follow the request for this task only. Do NOT modify kb.yaml — reflection handles persistence.
After a compile or query finishes writing its output, run a lightweight reflection step — only propose preference updates for high-confidence signals:
Follow the Reflection Protocol in plugins/kb/skills/kb-preferences/SKILL.md. On approval, write updates to kb.yaml and log to .meta/_preference_history.md with trigger reflection after /kb compile (or /kb query). Skip silently otherwise.
Do NOT run reflection for lint / evolve / reflect workflows — their output is too mechanical to surface meaningful style signals most of the time. The user can run /kb-preferences reflect manually if they want a forced pass.
All wiki output MUST use Obsidian-native conventions:
---[[wikilinks]] for ALL internal links -- NEVER use markdown-style [text](url) links for internal references[[wikilinks|display text]] when the display name differs from the target articletags: [concept, topic]aliases: [alternate name]![[image-name.png]]Every .md file in an Obsidian vault becomes a node in the graph. Every internal link — [[wikilink]] or markdown-style [text](file.md) — becomes an edge. Link syntax does not control the graph. Inventory files (_index, _sources, _categories, _evolution, _tags) exist as files that link to every article, so they appear as the highest-degree nodes by construction. The fix is to keep them out of the vault index entirely.
Meta/index files live in .meta/ at the vault root, not in wiki/. Obsidian ignores any folder whose name starts with . (the same mechanism that hides .obsidian/ itself). Files in .meta/ do not appear in the graph, search, quick switcher, backlinks, or file explorer. They remain readable and writable by tooling.
Canonical paths:
.meta/_index.md — master article index.meta/_sources.md — raw-source → article mapping.meta/_categories.md — auto-maintained category tree.meta/_evolution.md — append-only change log.meta/_tags.md — canonical tag vocabularyAny new meta/inventory file goes in .meta/ too, never in wiki/.
Article-to-article links MUST be [[wikilinks]]. These carry semantic weight and are the intended graph edges.
MOC pages MUST use [[wikilinks]] and live in wiki/. MOCs are curated, narrative conceptual hubs and belong in the graph.
Verify every [[wikilink]] target exists before emitting it. Confirm either (a) the target article already exists in wiki/**/*.md (including via its aliases frontmatter), or (b) the agent is creating that target in the same compile pass. If neither, do NOT emit a wikilink — use plain text or italics. Never emit a wikilink as a "TODO placeholder." Why: dangling wikilinks render as ghost/placeholder nodes in the graph and open an empty editor when clicked.
kb-init and compileEnsure .meta/ exists in the vault root. If the vault contains legacy meta files at wiki/_index.md, wiki/_sources.md, wiki/_categories.md, wiki/_evolution.md, or wiki/_tags.md, move them to .meta/ with the same filename, and make sure no wiki/**/*.md articles reference them (they shouldn't — meta files reference articles, not the other way around).
.meta/ being a dotfolder is load-bearing. Do NOT rename it to meta/ or _meta/ — Obsidian would then index it.
Past mistakes recorded here so future agents don't repeat them:
search filter in .obsidian/graph.json — it hides files from the graph only, not from search/backlinks/quick-switcher.userIgnoreFilters in .obsidian/app.json — this was partially correct (it does hide files from the index), but leaves the files visible in the file explorer and depends on the user not clearing the filter. The .meta/ dotfolder is the structural fix: Obsidian cannot index it regardless of user settings.Tags are for cross-cutting classification, not restating the title. Without a controlled vocabulary, tags drift (reasoning vs reasoning-models vs cot vs chain-of-thought) and lose their value as navigation.
domain/* — broad subject area (e.g., domain/reasoning, domain/rl, domain/alignment, domain/interpretability)method-family/* — class of technique (e.g., method-family/policy-gradient, method-family/preference-optimization)status/* — mirrors the status frontmatter field (status/seedling, status/budding, status/evergreen)moc — the existing bare tag for Map of Content pages (preserved for continuity)grpo. Tag it domain/rl, method-family/policy-gradient. The title and aliases already handle that lookup dimension..meta/_tags.md (the canonical tag index — see Index Maintenance) and pick an existing tag if it fits. Invent a new tag only when no existing tag captures the dimension, and when you do, add it to .meta/_tags.md in the same pass.Always set the model parameter explicitly when dispatching subagents.
| Task | Executor | Verifier |
|---|---|---|
| Index scanning, link checking, file diffing | haiku subagents | none |
| Summarizing individual sources | haiku subagents | opus spot-checks |
| Wiki article writing | sonnet subagents | opus reviews before commit |
| Deep research | sonnet subagents | opus orchestrates + verifies |
| Research synthesis / final reports | opus | none |
| Lint issue detection | sonnet subagents | opus prioritizes + filters |
| Query answering | opus | none |
| Consistency checks | sonnet subagents | opus final judgment |
| Media type detection | haiku subagents | none |
| Image/diagram description | sonnet subagents | opus reviews |
| MOC generation | sonnet subagents | opus reviews |
Every wiki article MUST declare an entity type in frontmatter. Types:
| Type | Description | Examples |
|---|---|---|
concept | Abstract idea, principle, phenomenon | Chain-of-Thought Reasoning, Superposition |
method | Algorithm, technique, procedure | GRPO, DPO, Flash Attention |
model | Specific ML model or system | DeepSeek-R1, Tulu 3 |
tool | Software, library, framework | PyTorch, vLLM |
benchmark | Evaluation dataset or metric | MATH, SWE-Bench |
dataset | Training/evaluation data | OpenWebText, RedPajama |
person | Researcher, author | (rare — only if heavily referenced) |
phenomenon | Observed behavior without explanation | Attention Sinks, Reward Hacking |
moc | Map of Content navigation page | RL & Alignment MOC |
Every article MUST declare a maturity status in frontmatter:
| Status | Criteria | Action |
|---|---|---|
seedling | Initial extraction from one source. Under 300 words or single-perspective. | Auto-assigned on creation. Lint flags seedlings older than 30 days. |
budding | Multiple sources integrated. Key relationships mapped. 300-800 words. | Promoted when second source adds information or article is enriched via evolve/query. |
evergreen | Comprehensive coverage. 3+ sources. Well-linked. Relationships section complete. 800+ words. | Promoted by opus during compile/evolve when criteria are met. |
Status transitions are unidirectional: seedling -> budding -> evergreen. The compile and auto-evolve workflows automatically check and promote status when criteria are met.
Trigger: User adds files to raw/ and says "compile" or "update the wiki".
Apply report_preferences from kb.yaml to all article prose (register, self_containment, depth per profile section, diagrams). See the Report Preferences section above. Run lightweight reflection at the end.
.meta/_index.md (lists every raw source with its last-compiled hash)raw/ recursively with Globraw/ folderBefore extraction, classify each new/changed file using the media routing table:
| File Type | Detection | Raw Directory | Extraction Method |
|---|---|---|---|
| PDF (.pdf) | Extension | raw/papers/ | Read tool (supports PDF) -> sonnet extraction |
| Markdown/Text (.md, .txt) | Extension | raw/articles/ | Read tool -> sonnet extraction |
| Image (.png, .jpg, .svg, ...) | Extension | raw/images/ | Read tool (supports images) -> vision description |
| Video (.mp4, .mkv, ...) | Extension | raw/transcripts/ | ffmpeg audio extract -> Whisper transcription -> sonnet |
| Audio (.mp3, .wav, ...) | Extension | raw/transcripts/ | Whisper transcription -> sonnet |
| Slides (.pptx) | Extension | raw/articles/ | python-pptx extraction -> sonnet |
| Notebook (.ipynb) | Extension | raw/repos/ | Read tool (supports notebooks) -> sonnet |
| Code repo (directory with .git) | Directory check | raw/repos/ | Tree + key files -> sonnet |
| YouTube URL | URL pattern | raw/transcripts/ | yt-dlp transcript -> sonnet |
| arXiv URL | URL pattern | raw/papers/ | Download PDF -> process as PDF |
| X/Twitter URL | URL pattern | raw/notes/ | Smaug or manual paste -> sonnet |
| Web URL | URL pattern | raw/articles/ | WebFetch -> sonnet |
| Dataset (.csv, .json, .parquet) | Extension | raw/datasets/ | Schema + sample -> sonnet |
Detection heuristic: Run this check for each file:
# Pseudocode — the agent uses its tools, not this script directly
if is_url(source):
match url patterns -> youtube, arxiv, tweet, github_repo, web_page
elif is_directory(source):
check for .git, package.json, pyproject.toml -> repository
else:
match extension -> pdf, text, image, video, audio, slides, notebook, dataset
PDF papers:
method, model, or conceptImages and diagrams:
![[image-name.png]] embedmedia_type: image in frontmatterVideo files (local):
which whisper 2>/dev/nullffmpeg -i input.mp4 -vn -acodec pcm_s16le -ar 16000 /tmp/audio.wav then whisper /tmp/audio.wav --model base --output_format txtYouTube URLs:
yt-dlp --write-auto-sub --sub-lang en --skip-download --output "/tmp/%(id)s" "<url>" to get subtitlesmedia_type: video in frontmatter, include channel and video titleAudio files (podcasts, recordings):
[HH:MM:SS] timestamps for key insightsmedia_type: audio in frontmatterSlides (.pptx):
python -c "from pptx import Presentation; ..." or use Read toolmedia_type: slides in frontmatterCode repositories:
find <repo> -name "*.py" -o -name "*.js" -o -name "*.ts" | head -30 for file listingtype: tool and media_type: repository in frontmatterDatasets:
head -5 <file> for schema, wc -l <file> for row countpython -c "import pandas as pd; df = pd.read_parquet('<file>'); print(df.dtypes); print(len(df))"type: dataset in frontmatterNotebooks (.ipynb):
For each new or changed source, dispatch a sonnet subagent with:
.meta/_index.md (so it knows existing articles)The subagent returns a structured extraction object.
After extractions complete, opus:
type and status: seedling)[[wikilink]] and confirm the target exists in wiki/**/*.md or is being created in this same compile pass. Replace any dangling link with plain text (or a sentence that doesn't assert a link). Never leave a wikilink as a placeholder — dangling links create ghost nodes in the graph.status: seedling MUST still meet the 100-word floor — the single-source criterion is about provenance, not length. Exception: a genuinely atomic entry (e.g., a one-line benchmark definition) may go shorter, but opus must explicitly justify it in the article body.---
title: "Concept Name"
aliases: [alternate name, abbreviation]
type: method
status: seedling
tags: [domain/rl, method-family/policy-gradient]
sources:
- "[[raw/articles/source-file.md]]"
media_type: text
confidence: high
created: 2026-04-07
updated: 2026-04-07
---
# Concept Name
Core explanation of the concept — what it is, why it matters, one-paragraph summary.
## Mechanism
How it works in detail. Include key equations, algorithms, or procedures.
## Key Findings
Numbered or bulleted list of the most important results, claims, or insights from sources.
## Limitations
Known weaknesses, failure modes, or caveats.
## Relationships
- **Predecessor:** [[Foundation Concept]] — what this builds on
- **Successor:** [[Improved Method]] — what improved on this
- **Contrasted with:** [[Alternative Approach]] — key differences
- **Applied in:** [[Model or System]] — where this is used
- **Builds on:** [[Underlying Theory]] — theoretical foundation
- **Related:** [[Adjacent Concept]] — conceptual connection
## Sources
- [[raw/articles/source-file.md]] — key claims extracted from this source
When a category accumulates 5+ articles, create a MOC page:
---
title: "Category Name"
type: moc
status: evergreen
tags: [moc, category-name]
created: 2026-04-07
updated: 2026-04-07
---
# Category Name
Brief overview of this knowledge domain and why it matters.
## Core Concepts
- [[Concept A]] — one-line summary
- [[Concept B]] — one-line summary
## Methods & Techniques
- [[Method X]] — one-line summary
- [[Method Y]] — one-line summary
## Models & Systems
- [[Model Z]] — one-line summary
## Key Relationships
Brief narrative of how concepts in this category connect to each other
and to concepts in other categories.
## Open Questions
- Questions this category's articles don't yet answer
- Gaps that could be filled with more research
After every compile, update these files:
.meta/_index.md -- master list: article name, one-line summary, compiled-from hash.meta/_sources.md -- mapping from raw sources to wiki articles they contributed to.meta/_categories.md -- auto-maintained category tree reflecting folder structure, with article counts.meta/_evolution.md -- append-only log: date | trigger | action | articles affected. Create if missing..meta/_tags.md -- canonical tag vocabulary. A flat list of every allowed tag with a one-line description, grouped by namespace (domain/*, method-family/*, status/*, plus moc). Any new tag introduced in this compile pass must be appended here with its description. Agents consult this file before inventing a new tag. Create if missing.Link-style inside .meta/ files is free. Because .meta/ is ignored by Obsidian, links inside these files do not create graph edges regardless of syntax. Pick whatever is easiest for tooling to parse — typically plain markdown-style links with paths relative to the vault root (e.g., [GRPO](wiki/rl-alignment/GRPO.md)) or just article titles in table cells. Do not waste cycles converting between styles.
Trigger: User asks a question about the knowledge base.
Apply report_preferences from kb.yaml to the final answer prose and to any auto-evolved article updates. See the Report Preferences section above. Run lightweight reflection at the end (after the answer is delivered; independent of the auto-evolve subagent).
Present three options:
/research for outline, /research-deep dispatches sonnet subagents, opus orchestrates and verifies.Run the appropriate pipeline. For Standard and Deep, clearly mark which information came from the wiki and which came from external sources.
See Auto-Capture Web Research section below. Any web pages fetched via WebSearch/WebFetch that contributed to the answer must be saved as raw documents.
Format the answer according to kb.yaml output preferences (markdown, Marp, matplotlib, etc.) and save to output/.
After delivering the answer to the user, immediately dispatch a background opus subagent (via Agent tool with run_in_background: true). Do NOT ask the user for permission — this runs silently.
The subagent receives:
.meta/_index.mdThe subagent decides and acts:
type, status: seedling, and all required frontmatter fields.[[wikilinks]] between articles that the query revealed are related.meta/_index.md, .meta/_sources.md, .meta/_categories.md.meta/_evolution.md: YYYY-MM-DD | query | action taken | articles affectedConstraints:
type and status fields in any new article frontmatterTrigger: "health check", "lint the wiki", or invoked via /loop or /schedule.
Run the graph health script if available:
python plugins/kb/scripts/graph_health.py "<vault_path>" --json --fix-suggestions
If the script is not available, perform the checks manually via subagents.
[[wikilinks]] pointing to non-existent articlesraw/ that were never compiledtype or status fieldsstatus: seedling older than 30 dayswiki/ instead of .meta/ -- any _*.md file under wiki/ should be moved to .meta/ so Obsidian does not index it. Flag as a fix.domain/*, method-family/*, status/*, moc), or any tag not listed in .meta/_tags.md.grpo). Tags are for cross-cutting classification.Report these metrics in the lint output:
| Metric | Target | What It Means |
|---|---|---|
| Orphan rate | < 5% | Articles nobody links to |
| Broken link rate | < 2% | Links pointing to nothing |
| Avg outgoing links | >= 5 | How well-connected articles are |
| Bidirectional rate | >= 50% | Two-way relationship coverage |
| Evergreen rate | >= 30% | Maturity of the knowledge base |
| Type diversity | >= 4 types | Variety of entity types |
| Cross-cluster links | report count | Knowledge integration across categories |
Opus collates all findings, filters false positives, and prioritizes by severity:
Save to output/lint-YYYY-MM-DD.md. Include:
Ask the user if they want auto-fix applied for mechanical fixes (adding missing frontmatter fields, creating MOC pages, fixing broken links to articles that exist under different names).
Trigger: "evolve the wiki", "suggest improvements", or "what's missing".
.meta/_index.md, .meta/_categories.md, and samples articles across categoriesIf the evolve analysis identifies categories with 5+ articles and no MOC, automatically create MOC pages (don't just suggest — do it). MOCs are low-risk, high-value additions that improve navigability.
Trigger: "reflect on the wiki", "what have we learned", "knowledge audit", or after every 10th compile.
This is the meta-improvement workflow inspired by autoresearch. It evaluates the knowledge base against quality rubrics and proposes structural improvements.
python experiments/evaluate.py "<vault_path>" --json
compile scores low: improve extraction prompts or add missing frontmatter fieldsgraph_health scores low: fix broken links, connect orphans, create MOCsknowledge_architecture scores low: refactor articles, improve typingexperiments/logs/experiment_log.mdWhen the user pastes an x.com or twitter.com URL and wants it added to the knowledge base:
Read kb.yaml and look for integrations.smaug.path. If it exists, verify the path is still valid:
test -d "<smaug_path>" && test -f "<smaug_path>/smaug.config.json" && echo "smaug-ready" || echo "smaug-missing"
If integrations.smaug is not in kb.yaml, try finding it:
which bird 2>/dev/null && find ~ -maxdepth 4 -name "smaug.config.json" -type f 2>/dev/null | head -1
If found, save the path to kb.yaml under integrations.smaug.path so future sessions don't need to search again.
cd to the Smaug path from kb.yaml/status/)npx smaug fetch <tweet_id> then npx smaug processknowledge/ directoryraw/articles/ and trigger CompileTell the user you cannot directly fetch X/Twitter content, then present these options:
git clone https://github.com/alexknowshtml/smaug && cd smaug && npm install, then npx smaug setup to configure X session cookies (auth_token + ct0 from browser DevTools → Cookies → x.com). After setup, save the install path to kb.yaml under integrations.smaug.path. Note: uses session cookies, technically violates X TOS but practical risk for personal read-only use is very low.raw/articles/x-<tweet_id>.md with the tweet URL as a source link.If the user provides the tweet content directly (paste, screenshot, or any other method), accept it immediately and proceed — save to raw/articles/x-<tweet_id>.md with proper frontmatter and trigger Compile. Do not gatekeep.
Smaug produces markdown like:
## @username - Title
> Tweet text
- **Tweet:** https://x.com/...
- **Link:** https://...
- **What:** One-line description
And knowledge files with YAML frontmatter in knowledge/articles/ or knowledge/tools/. Both formats are valid raw sources for Compile.
When the user provides a YouTube URL:
yt-dlp --write-auto-sub --sub-lang en --skip-download --output "/tmp/%(id)s" "<url>" 2>&1pip install yt-dlp then retryyt-dlp --dump-json "<url>" 2>/dev/null | python -c "import sys,json; d=json.load(sys.stdin); print(f'Title: {d[\"title\"]}\nChannel: {d[\"channel\"]}\nDuration: {d[\"duration\"]}s')" if yt-dlp availableraw/transcripts/yt-<video_id>.md with frontmatter including title, channel, URLApplies to ALL workflows — Compile, Query (Standard/Deep), Evolve — any time WebSearch or WebFetch is used to gather context.
Config: auto_capture_web in kb.yaml (default: true). If false, skip entirely.
Any time the skill fetches a web page to help with its work:
Only pages whose content actually contributed to the output. Do NOT save:
For each contributing web page:
Dedup check — search raw/ for the URL:
grep -rl "<url>" raw/ 2>/dev/null | head -1
If found, skip saving — just reference the existing file as a source.
Save — if the URL is new, write to raw/articles/<slug>.md using the page title as a natural filename (lowercase, hyphens). Frontmatter:
---
title: "Page Title"
url: "https://example.com/article"
fetched: YYYY-MM-DD
media_type: web_article
---
[fetched page content]
Continue — the saved raw file will be compiled into wiki articles either:
/kb compile run (for compile-time context searches)User provides a YouTube video about RLHF. During compile, the skill searches the web for "proximal policy optimization LLM training" to understand a reference in the video. It finds and reads a blog post at https://example.com/ppo-explained. That blog post contributed to understanding the video → save it to raw/articles/ppo-explained.md with the URL in frontmatter.
raw/ folder when only a few files changed -- always use incremental detection[text](url) instead of [[wikilinks]] for internal references.meta/_index.md, .meta/_sources.md, .meta/_categories.md) after compiletype or status fields -- every article MUST have bothmedia_type in frontmatterauto_capture_web is on and a web page helped produce the output, it must be saved[[wikilinks]] and [text](file.md) become graph edges. The fix is to keep meta files in .meta/ (a dotfolder at the vault root), which Obsidian does not index at all.wiki/ -- wiki/_index.md, wiki/_anything.md etc. will always be graph nodes. Meta files belong in .meta/.meta/, _meta/, or similar -- the leading dot is what makes Obsidian ignore it. Non-dot folders are indexed.[[wikilinks]] to articles that don't exist yet and aren't being created in the same pass -- produces ghost nodes in the graph and opens empty editors when clicked. Use plain text or italics instead.domain/*, method-family/*), not restating what the title already says.meta/_tags.md vocabulary -- always consult the tag index first; add to .meta/_tags.md only when no existing tag fitsWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
knowledge-base, wiki, compilation, query, lint, evolution, obsidian
npx claudepluginhub rvk7895/llm-knowledge-bases --plugin kb8 skills in this plugin
/kb-initUse when setting up a new knowledge base, bootstrapping an Obsidian vault, or when user says 'init kb', 'new knowledge base', 'create kb', or 'setup vault'. Triggers on any request to initialize or scaffold a knowledge base project./kb-preferencesUse when user wants to view, update, reset, or audit report preferences stored in vault kb.yaml. Triggers on '/kb-preferences', 'update report prefs', 'change report style', 'my preferences', or when a passive reflection step in another skill needs to propose preference updates./researchResearch Skill - Preliminary ResearchConduct preliminary research on a target topic and generate a research outline. Used for academic research, benchmark research, technology selection, and similar scenarios.Other plugins' skills for the same job