corpus-query

A read-only gateway for querying registered LoreKit knowledge bases, which are searchable stores of notes or project knowledge. It sends each question to a named knowledge base or to the configured default.

In plain words
What is it for?
Use it to search a shared knowledge base or a specific project corpus by name, alias, or registered path fragment, while following that corpus’s own query rules.
Why use it?
It avoids guessing which knowledge base or file path should answer a cross-project question. If a requested knowledge base is not registered, it asks you to choose from the available names.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/gyf0311/lorekit/corpus-query
Any agent
npx skills add GYF0311/lorekit --skill corpus-query
Clone the repo
git clone --depth 1 https://github.com/GYF0311/lorekit

Made for: Claude Code, Codex.

Per session 64 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 845 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00064 $0.00845
Opus 5 $0.00032 $0.00423
Sonnet 5 $0.00013 $0.00169
Haiku 4.5 $0.00006 $0.00085

Measured 3d ago against content hash e970f0ee32d4, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

corpus-query scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/corpus-query/SKILL.md · 84 lines

How it starts

The opening of the file, as written. The whole thing — 84 lines — stays where its author put it; the contents beside it link to each section on GitHub.

corpus-query

Optional read-only query gateway for registered Lorekit corpora. It routes a cross-project question to the named (or default) corpus, then follows that corpus's own rules.

Config

Read:

~/.config/lorekit/global-corpus.json

Required:

  • default_corpus
  • lorekit_bin or <default_corpus>/bin/lorekit
  • knowledge_dir (default 知识库)

Optional:

  • output_dir
  • corpora — multi-corpus registry, enables querying any registered corpus by name:
"corpora": {
  "总库":  { "path": "/path/to/corpus",       "aliases": ["总知识库", "主库"] },
  "AI产品": { "path": "/path/to/ai-corpus",    "aliases": ["AI产品工作集"] }
}

If the config is missing, ask for it. Do not guess the corpus path.

Target resolution(先定库,再查询)

  1. 用户点名了库(名称 / alias / 路径片段命中 corpora 注册表)→ 路由该库。
  2. 用户没点名("查总知识库"、"查我的知识库")→ 用 default_corpus
  3. 点名了但注册表对不上 → 列出已注册库名让用户选,不要猜路径
  4. 问题其实属于当前所在 corpus → 不走本 gateway,直接用当前库的 wiki-query

CLI 一律优先目标库自带的 <corpus>/bin/lorekit;不存在时才用全局 lorekit(或配置里的 lorekit_bin,仅对 default_corpus 有效)。

Boundary

This skill is an optional cross-project gateway. Target corpus rules remain authoritative.

Before answering, read the relevant local rules when available (<corpus> = the resolved target corpus):

  • <corpus>/AGENTS.md
  • <corpus>/CLAUDE.md
  • <corpus>/index.md
  • <corpus>/skills/wiki-query/SKILL.md

Read only what is needed. Do not bulk-load the corpus.

Query Route

  1. cd <corpus>(按 Target resolution 定出的库).
  2. For exact terms, run <corpus>/bin/lorekit search "<q>".
  3. Read <corpus>/index.md, then the relevant _INDEX.md files.
  4. Read canonical pages under 知识库/ before answering.
  5. 目标库无命中时诚实说明,随后直接联网检索兜底(WebSearch / WebFetch),不要停在「库里没有」;回答分层标注「库内已沉淀」(引 corpus 页)vs「联网新查」(给 URL,注明未入库)。另可按需:换另一个注册库查 / 记一条 capture。

Output

Answer with:

  • concise synthesis
  • citations to real corpus pages
  • confidence notes when source confidence is low or medium
  • query path summary when useful

If the corpus does not contain relevant information, say so, then fall back to web research directly; label web findings as not-yet-ingested and cite URLs. Offer an inbox capture when a finding is worth keeping.

Read the full file on GitHub · 84 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 84 lines · 64 tokens per session scan A e970f0ee32d4

Subscribe to this mod's changes

corpus-query is a skill published in the GitHub repository GYF0311/lorekit (5 stars, last pushed 1mo ago), licensed MIT. It adds 64 tokens to every session and 845 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

llm-wiki

Build and maintain a persistent, interlinked Obsidian-compatible markdown wiki using Karpathy's LLM Wiki pattern. Extension-backed with auto-generated metadata, guardrails, and 14 custom tools (+3 opt-in agent-trajectory tools).

zosmaai/pi-llm-wiki · 52 tokens

mindbase

Maintain a persistent AI-tended research wiki. Activates when the user wants to ingest a source (PDF, URL, article, paste), capture a thought, build the wiki context, query what's already known, lint for orphans/contradictions, or maintain page conventions. Phrases include "add this to my wiki", "today I decided…"…

frankchu91/mindbase-llm-wiki · 105 tokens

llm-wiki

Build and maintain an LLM-curated personal knowledge base — the "LLM Wiki" pattern from Andrej Karpathy's April 2026 gist. Use this skill whenever the user wants to ingest a source (paper, article, transcript, PDF, notes) into a persistent compounding knowledge base, ask a question against accumulated notes, lint or…

praneybehl/llm-wiki-plugin · 221 tokens

wiki-ingest

Process source files into synthesised wiki pages. Always use this skill when the user says /wiki-ingest, 'import these files', 'process my clippings', 'ingest this article', 'I have new articles to add', 'turn this PDF into a wiki page', 'what's in my raw/ folder', or 'what have I ingested'. Also use when the user…

vanillaflava/llm-wiki-skills · 182 tokens

wiki-config

Set up, validate, and reconfigure the llm-wiki skill suite. Always use this skill when the user says /wiki-config, asks to 'set up my wiki', 'configure wiki', 'initialize wiki config', mentions 'page structure problems', 'schema issues', 'missing templates', 'wiki help', 'how does the wiki work', or when any wiki…

vanillaflava/llm-wiki-skills · 166 tokens

wiki-lint

Health-check the wiki: scan all pages for broken wikilinks, orphaned pages, stale index entries, missing connections, em-dash violations, orphaned assets, and schema errors. Produces a dated lint report. Always use this skill when the user says /wiki-lint, mentions broken links, dead wikilinks, orphaned pages, 'what's…

vanillaflava/llm-wiki-skills · 177 tokens