npx skills add ...
npx skills add ar9av/obsidian-wiki --skill wiki-context-pack
npx skills add ar9av/obsidian-wiki --skill wiki-context-pack
Produce a token-bounded context pack from the Obsidian wiki — a compact, structured slice of the most relevant pages for a topic or recent activity, designed for downstream consumption by another agent or skill. Use when the user says "/wiki-context-pack", "make a context pack", "give me a context slice for X", "pack the wiki for my agent", or "bounded context for Y". Different from wiki-query (which answers a question) — this produces reusable input material for a downstream task.
You are producing a focused, token-bounded context pack from the wiki. Unlike wiki-query (which answers a question), this skill packages the most relevant wiki knowledge into a single markdown block that a downstream agent, skill, or user can consume directly.
llm-wiki/SKILL.md (inline @name override → walk up CWD for .env → ~/.obsidian-wiki/config → prompt setup). This gives OBSIDIAN_VAULT_PATH and any QMD variables.$OBSIDIAN_VAULT_PATH/hot.md if it exists — gives instant context on recent activity.$OBSIDIAN_VAULT_PATH/index.md — the full page inventory.Parse the user's invocation to extract:
--recent)--budget N — token budget in tokens (default: 8000; max: 100000)--recent — pack the most recently updated/ingested pages instead of a topic queryWithout opening page bodies:
Scan index.md and frontmatter for topic match. Score each page:
summary: field contains the query termindex.md entry description contains the query termFor --recent mode: sort pages by updated: frontmatter descending. Take top 20 as candidates.
For topic mode: collect the top 20 candidates by score. If QMD is configured (QMD_WIKI_COLLECTION set), run a semantic pass and merge with the frontmatter score (QMD rank adds +4 to the page's score).
Within the candidate set, sort by relevance score, then apply tier ordering within each score bucket (see llm-wiki/SKILL.md, Importance Tiering section):
core-tier matches firstsupportingperipheral (only if budget allows)Maintain this ordering when filling the budget in Step 3.
For each selected page (in tier/relevance order), compute its compressed representation — not a full read, but a structured distillation:
tier:, tags:, summary: (from frontmatter — cheap, no body read needed)## Sources section (keep source names in a one-liner instead)_(content also in [[other-page]])_.Estimate tokens for each page representation as len(text_chars) / 4.
Fill the pack greedily in tier/relevance order until the budget is exhausted:
peripheral-tier pages first when trimming.Emit a single markdown block:
If --recent mode, the header reads:
Empty result: If no pages scored above 0 and --recent produced no results, output:
Append to $OBSIDIAN_VAULT_PATH/log.md:
/wiki-research — pass the pack as context to avoid re-discovering known facts/wiki-synthesize — scoped input for a specific synthesis task4 chars/token heuristic matches wiki-status's token footprint estimate — consistent across skills# Context Pack: Recent Activity (last N pages)# Context Pack: <topic>
No relevant pages found. Consider running /wiki-ingest to add sources about this topic.- [TIMESTAMP] CONTEXT_PACK topic="<topic>" budget=<N> actual_tokens=<M> pages_included=<K> pages_dropped=<D>