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.
npx agentmods add rules/kipill/kpknowledgegraph/cursor-kggit clone --depth 1 https://github.com/kipill/KPKnowledgeGraphWhat 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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00759 | $0.00759 |
| Opus 5 | $0.00380 | $0.00380 |
| Sonnet 5 | $0.00152 | $0.00152 |
| Haiku 4.5 | $0.00076 | $0.00076 |
Grade A, and why
cursor-kg 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 yesterday.
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.
What it actually says
知识图谱(kg)使用约定
本项目装有 KPKnowledgeGraph——一个「先查图谱再读代码」的成长型知识索引。
图谱数据在 .claude/kg/,唯一出入口是 kg MCP 工具(server 名 kg)。
何时先查图谱(满足任一,动代码前)
- 新功能开发:「加一个 X」「实现 Y」
- 跨模块改动:涉及联动 / 同步 / 触发 / 跨服 / 通知
- 不熟悉的系统名,或重构 / 迁移某系统
小改动(改单个方法 / 调数值 / 加 log)、bug 排查、性能调优、纯问答 → 跳过。
怎么查
kg_query(query="关键词")直接搜——一次返回代码路径 / 踩坑 / 出边入边。- 无命中或可疑时
kg_catalog()拿全量轻量目录,用语义判断哪些 entry 相关, 再kg_get_entry(entry_id=...)取详情。字面无命中 ≠ 图谱没有。 - 造新行为的需求(「加个能做 Y 的功能」),先
kg_scout_reuse(requirement=...)做复用分诊:是配现成能力还是真要开发——转述给用户 + 给选项,等人拍板, 绝不自行采纳推荐就写代码。
写图谱(⚠ Cursor 无 hook 拦截,靠本约定自律)
- 禁止直接 Edit / Write
graph*.json/reverse_index.json/*.jsonl—— 它们只能经 kg MCP 写工具(自带 schema 校验 + changelog + 反向索引重建)。 绕过会破坏图谱一致性,且丢失 changelog。 entries/*.md深度文档可直接编辑,不受限。- 写工具:
kg_add_entry/kg_update_entry/kg_add_relation/kg_add_pitfall/kg_verify_edge/kg_add_capability_catalog/kg_add_capability_members。 每个写操作的reason参数要写清「哪个任务 / 发现了什么」。
任务完成后
- 对实际用过的每个 entry 调
kg_feedback(entry_id, accurate, note)(遥测,不改图谱, 无需问用户):路径直达 / 联动正确 →accurate=true;漂移 / 误导 →false并写明。 - 发现新踩坑 / 验证了 draft 边 / 新增了系统 → 建议用户更新图谱(不自动改), 同意后走对应 MCP 写工具。
- 图谱路径和实际代码对不上时:代码是 source of truth,顺手
kg_update_entry修正 (会强校验新路径真实存在)。
MCP 不可用时
查询可退化为直接 Read .claude/kg/graph*.json;写操作不许退化为直接编辑文件,
报告用户 MCP 异常。
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.
- yesterday First seen · 46 lines · 759 tokens per session scan A 4cc5e976f5c7
cursor-kg is a cursor rule published in the GitHub repository kipill/KPKnowledgeGraph (9 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 759 tokens to every session, about $0.0038 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.
Other cursor rules, from other repositories
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.
dev-standard
Apache Superset development standards and guidelines for Cursor IDE.
typescript
Changes to these high-fan-out internals can affect every message, delta, element, or rerun. Keep work in them minimal, and benchmark changes with representative stress-test apps.
coolify-ai-docs
Master reference to all Coolify AI documentation in .ai/ directory.
python_lib
Tips and guidelines specific to the development of the Streamlit Python library, not applicable to scripts and e2e tests.
specs
This directory contains product and tech specs for Streamlit features.