kb-memory

kb-memory is a skill for Claude Code, Codex from fish827-08/rag-kb. It costs 0 tokens per session (1,095 once invoked), scanned A, original, Apache-2.0.

A local-first memory and knowledge service that an AI client can access through MCP or HTTP. It stores long-term facts and preferences, indexes documents and web pages, and supports retrieval while offline.

In plain words
What is it for?
It is for saving and searching memories, importing documents or web content, and asking questions over the stored knowledge.
Why use it?
It keeps useful project knowledge available across sessions without depending on a cloud service for storage or retrieval.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

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/fish827-08/rag-kb/kb-memory
Any agent
npx skills add fish827-08/rag-kb --skill kb-memory
Clone the repo
git clone --depth 1 https://github.com/fish827-08/rag-kb

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for kb-memory

README.md
[![agentmods](https://agentmods.dev/badge/skills/fish827-08/rag-kb/kb-memory.svg)](https://agentmods.dev/skills/fish827-08/rag-kb/kb-memory)
Your own site
<a href="https://agentmods.dev/skills/fish827-08/rag-kb/kb-memory"><img src="https://agentmods.dev/badge/skills/fish827-08/rag-kb/kb-memory.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,095 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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.1 $0.00000 $0.01095
Opus 5 $0.00000 $0.00548
Sonnet 5 $0.00000 $0.00219
Haiku 4.5 $0.00000 $0.00110

Measured 2d ago against content hash 3e8586c42632, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

kb-memory scanned grade A with 1 finding 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 2d 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

- curl 是 Invoke-WebRequest 的**别名,不是原生 curl**:参数完全不同,直接写 curl 必然报错。
skills/kb-memory/SKILL.md · 68 lines

How it starts

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


name: kb-memory description: kb 本地记忆与知识服务接入规约。当会话需要给用户写入/检索长期记忆、导入文档/网页做 RAG 问答、或用户提到"kb 记忆/MCP 工具"时使用。已挂载 kb MCP 的客户端自动获得全局规约(instructions),本 skill 主要用于未挂载 MCP 时的 HTTP 兜底。

kb-memory:本地 Agent 记忆与知识服务接入规约

kb 是本机常驻服务(默认 http://127.0.0.1:8000),本地优先、免费、断网可用, 写入/检索不依赖大模型(仅 ask 问答需要 LLM)。接入前无需探测服务是否在跑—— 直接调用即可,一切正常就继续工作;只有工具/HTTP 调用报连接失败时才提示服务未启动。

1. 核心规约

  • 记忆与知识全共享:任何客户端/任务写入的记忆对所有会话可见,跨 agent 跨任务共享。 不用传 client/project(仅审计归类),不传也完整可用;服务端自动识别来源客户端。

  • 何时写入(write_memory,精炼 1~3 句):用户偏好 / 项目决策 / 事实与约定 / 敏感约束 / 任务进度。 不写:寒暄、临时计算、代码文档里能查到的实现细节。

  • 写前查重:先 search_memory,已有同类则 update_memory 覆盖,不新增重复。

  • 敏感不入库:密钥、凭据、身份证号等严禁写入。

  • 何时检索:任务开始 / 回答涉及历史决策偏好 / 跨会话接力时,先 search_memory 主动召回。

2. 对用户反馈(极简)

  • 写入/更新成功:只轻提一句(如"已记住你的偏好");失败才说明原因 (如"没记:与已有记忆重复 / 内容敏感 / 格式不支持")。

  • 不要展示:健康检查过程、工具名、记录 ID、JSON、检索命中详情。

  • 仅在工具/HTTP 调用真正报连接失败时,简提"kb 服务未启动,需先运行 python -m kb serve",不臆造结果。

3. 接入方式

  1. MCP(首选):write_memory / search_memory / read_memory / update_memory / delete_memory / add_document / add_webpage / ask_kb(8 个工具,全共享,无归属限制)。

  2. HTTP 兜底(未挂载 MCP 时)

    • 写:POST /api/v1/memories {"content":"…","tags":["…"]}

    • 检索:POST /api/v1/search {"query":"…","top_k":5}

    • 问答:POST /api/v1/ask {"question":"…"}(LLM 未配 → LLM_DISABLED)

    • 文档/网页入库:POST /api/v1/documents(multipart 或 {"path":"…"})、POST /api/v1/ingest/web {"url":"…"}

Windows PowerShell 注意事项

  • curl 是 Invoke-WebRequest 的别名,不是原生 curl:参数完全不同,直接写 curl 必然报错。 统一用 curl.exeInvoke-RestMethod

  • 中文 JSON 必须强制 UTF-8:Windows PowerShell 默认按本机 ANSI/GBK 发送中文,服务端按 UTF-8 解析会全部变成 ? 乱码。含中文的写/查/答请求都用字节数组发送:

$json  = ConvertTo-Json -InputObject @{ content = "用户喜欢的动画片"; tags = @("偏好") }
$bytes = [System.Text.Encoding]::UTF8.GetBytes($json)
Invoke-RestMethod -Uri http://127.0.0.1:8000/api/v1/memories -Method Post -ContentType 'application/json; charset=utf-8' -Body $bytes

Read the full file on GitHub · 68 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. 2d ago Changed · -30 lines · -98 tokens per session 3e8586c42632
  2. 5d ago First seen · 98 lines · 98 tokens per session scan A 295ecb77bd66

Subscribe to this mod's changes

kb-memory is a skill published in the GitHub repository fish827-08/rag-kb (2 stars, last pushed 3d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 1,095 tokens. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.