# Kb query

> Kb query is an open-source agent skill for knowledge and memory. Lets an agent answer questions from a local materials-science knowledge base with cited. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/cqxcrl/matsci-kb-kit/tree/main/skills/kb-query
- **Repository:** https://github.com/cqxcrl/matsci-kb-kit
- **GitHub stars:** 6
- **License:** MIT
- **Skill name:** kb-query
- **Collection:** https://github.com/cqxcrl/matsci-kb-kit
- **Categories:** [knowledge and memory](https://ai-powered.com/categories/knowledge-and-memory)
- **Listing updated:** 2026-12-02

## About

This skill guides an agent to search and answer questions against a local knowledge base organized around the kb.py command. It separates simple lookups, which go to a plain top-K search, from comparisons, mechanisms, disputes and trend questions, which go to a bounded agentic retrieval that can follow sub-queries and graph links. Answers are meant to be built from the retrieved evidence, with concept and synthesis pages treated as secondary and source papers and raw full-text passages used to verify claims and cite file paths and line numbers.

The workflow asks the agent to check reliability fields and low-confidence signals, flag single-source claims, cross-compare sources that report the same figure, and treat low scores as gaps rather than forcing an answer. Before saying something is missing from the library, it runs a helper that searches several directories and reports hits per directory. It also covers running a local search server, checking the reranker model, and rebuilding indexes after edits.

The skill expects a Python environment with the repository's tools installed and a local knowledge base in place. Its documentation is written in Chinese, and the default reranker is a local bge model that must be explicitly allowed to download.

## When your agent uses it

> 在本知识库里检索并回答问题（传统 RAG、Agentic RAG、分层证据、原文回指）。用户提出需要库内证据的问题、要求比较机制/争议/趋势或核对原文时使用。首选 kb.py ask/search，不要先读 index.md 全表或手工 grep。

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/cqxcrl/matsci-kb-kit/tree/HEAD/skills/kb-query)
- [License: MIT](https://github.com/cqxcrl/matsci-kb-kit/tree/HEAD/skills/kb-query)

## Features

- **Strategy selection:** Chooses simple, agentic or automatic retrieval depending on whether a question is a fact lookup or a comparison.
- **Layered evidence handling:** Separates synthesized concept pages from individual source claims and verbatim raw text when answering.
- **Citation verification:** Checks claims against original file paths and line numbers rather than relying on grep.
- **Single-source flagging:** Marks conclusions supported by only one paper and notes disagreements between sources.
- **Local search service:** Starts, checks and stops a resident search server and verifies the reranker model.
- **Missing-content check:** Searches several library directories before concluding that a document is absent.

## Good for

- Compare two battery electrolyte mechanisms using the library's sources
- Find the original wording behind a figure quoted in a wiki page
- Answer a definition question from the knowledge base with file references
- Check whether a claimed result appears in the underlying papers
- Summarize a contested research trend and note the strength of evidence

## Install

### Claude Code

This skill ships in the `matsci-knowledge-base` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add cqxcrl/matsci-kb-kit
/plugin install matsci-knowledge-base@matsci-local
```

Or copy only this skill to `~/.claude/skills/kb-query`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/cqxcrl/matsci-kb-kit.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/kb-query &&
cp -R "$tmp/skills/kb-query" ~/.claude/skills/kb-query &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/kb-query` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/kb-query` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/cqxcrl/matsci-kb-kit.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/kb-query &&
cp -R "$tmp/skills/kb-query" ~/.agents/skills/kb-query &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/kb-query` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/kb-query` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/cqxcrl/matsci-kb-kit.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/kb-query &&
cp -R "$tmp/skills/kb-query" ~/.cursor/skills/kb-query &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/kb-query` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/cqxcrl/matsci-kb-kit.git --path skills/kb-query
```

Or copy the folder to `~/.gemini/skills/kb-query` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/kb-query`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/cqxcrl/matsci-kb-kit.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/kb-query &&
cp -R "$tmp/skills/kb-query" ~/.copilot/skills/kb-query &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/kb-query` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/cqxcrl/matsci-kb-kit.git
```

Then copy `matsci-kb-kit/skills/kb-query` into your agent's skills folder as `kb-query`. Agents that support SKILL.md read one folder per skill.

## FAQ

### When does Kb query trigger?

It is meant for questions that need evidence from the library, requests to compare mechanisms, disputes or trends, and checks against original text.

### Which command should the agent use first?

The skill names kb.py ask or search as the preferred entry point and tells the agent to list available tools with kb.py tools --json.

### Does Kb query need a local model?

It uses a local reranker by default, bge-reranker-base, which reads from local files; first download requires an explicit flag or environment variable.

### Is the skill openly licensed?

The repository is MIT licensed.

### How do I install Kb query in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/kb-query to use it in all your projects, or to .claude/skills/kb-query in one project. Or install the matsci-knowledge-base plugin, which includes it: /plugin marketplace add cqxcrl/matsci-kb-kit, then /plugin install matsci-knowledge-base@matsci-local.

### Does Kb query run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Kb query?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Kb query?

The closest alternatives to Kb query are Haiku rag, Knowledge base integration, Research ops edho ferdian, LLM wiki and Research.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Haiku rag](https://ai-powered.com/skills/haiku-rag-ggozad): Haiku rag is an open-source agent skill for knowledge and memory.
- [Knowledge base integration](https://ai-powered.com/skills/knowledge-base-integration): Knowledge base integration is an open-source agent skill for knowledge and memory.
- [Research ops edho ferdian](https://ai-powered.com/skills/research-ops-edho-ferdian): Research ops edho ferdian is an open-source agent skill for knowledge and memory.
- [LLM wiki](https://ai-powered.com/skills/llm-wiki): LLM wiki is an open-source agent skill for knowledge and memory.
- [Research](https://ai-powered.com/skills/research-hec-ovi-2): Research is an open-source agent skill for web search and scraping.
- [Kb lint](https://ai-powered.com/skills/kb-lint): Kb lint is an open-source agent skill for knowledge and memory.
- [Kb onboard](https://ai-powered.com/skills/kb-onboard): Kb onboard is an open-source agent skill for knowledge and memory.
- [Lit watch](https://ai-powered.com/skills/lit-watch): Lit watch is an open-source agent skill for knowledge and memory.

---
Source: https://ai-powered.com/skills/kb-query
