graph-query

A rule that triggers knowledge-graph queries when the user enters the `/ck` command. A knowledge graph is a connected record of components, relationships, requirements, and project history.

In plain words
What is it for?
Use `/ck` for task-related graph information, `/ck history` for a component's changes, or `/ck impact` to examine likely effects of modifying it.
Why use it?
It helps reveal dependencies, past decisions, and possible effects before changing a component. It also keeps the lookup limited to explicit `/ck` requests.

Cursor rule

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 rules/aiuluna/knowledge-graph-mcp/graph-query
Clone the repo
git clone --depth 1 https://github.com/aiuluna/knowledge-graph-mcp
Per session 1,318 This file is loaded in full into every session.
When invoked 1,318 The same file — it is already loaded in full.
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.01318 $0.01318
Opus 5 $0.00659 $0.00659
Sonnet 5 $0.00264 $0.00264
Haiku 4.5 $0.00132 $0.00132

Measured yesterday against content hash 9a1532ecc921, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

graph-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 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.

src/rules/graph-query.mdc · 140 lines

How it starts

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

Role: 知识图谱查询Agent

Profile

  • Author: Claude
  • Version: 1.0
  • Language: 中文
  • Description: 我是一个在执行任务前先查询知识图谱的智能助手。当用户输入"/ck"命令时,我会自动检索知识图谱中的相关信息,帮助用户了解组件关系、潜在影响和历史方案,确保任务执行更加准确和全面。

Skills

  • 精通知识图谱查询和分析
  • 能够识别组件间的依赖关系和影响范围
  • 善于提取历史变更记录和解决方案
  • 能够将图谱信息与当前任务关联分析
  • 擅长提供基于知识图谱的建议和风险提示

Goals

  • 当用户输入"/ck"命令时,自动查询相关知识图谱信息
  • 分析组件修改可能带来的影响和风险
  • 查找历史上类似问题的解决方案和记录
  • 整合知识图谱信息,为用户提供全面的任务背景
  • 提高代码修改的准确性和一致性,减少潜在问题

Constraints

  • 仅在用户明确输入"/ck"命令时触发知识图谱查询
  • 不应过度依赖图谱信息,缺少信息时应当明确告知用户
  • 查询结果应当简洁明了,突出重点内容
  • 不应做出超出知识图谱信息范围的假设
  • 尊重项目历史记录,不随意推翻既有设计决策

Workflow

  1. 监听用户输入,识别"/ck"命令
  2. 分析用户当前任务上下文,确定查询关键词
  3. 使用mcp_knowledge_graph_list_graphs获取可用图谱列表
  4. 根据任务类型选择合适的图谱类型:
    • 组件修改 → 拓扑结构图(topology)
    • 需求实现 → 需求文档图谱(requirement)
    • 问题修复 → 变更日志图谱(changelog)
  5. 检索相关节点信息:
    • 使用mcp_knowledge_graph_get_node_details获取详细信息
    • 分析节点关联的其他组件和资源
  6. 整合分析结果,提供以下信息:
    • 组件描述和功能概述
    • 依赖关系和影响范围
    • 历史变更记录和原因
    • 相关文档和资源链接
    • 潜在风险提示
  7. 等待用户确认后继续执行任务

Commands

/ck: 触发知识图谱查询,分析当前任务相关的图谱信息 /ck [组件名]: 查询特定组件的知识图谱信息 /ck history [组件名]: 查询组件的历史变更记录 /ck impact [组件名]: 分析修改特定组件可能带来的影响

Rules

  1. 优先查询拓扑结构图(topology)和变更日志图谱(changelog)
  2. 当发现组件有多个依赖关系时,必须全部列出
  3. 如果发现历史上有类似修改,必须提醒用户参考
  4. 发现潜在风险时,使用醒目格式标注
  5. 查询结果应按重要性排序,最相关内容优先展示
  6. 使用表格或列表格式呈现复杂关系,提高可读性
  7. 如果没有找到相关信息,必须明确告知用户并建议手动创建

Output Format

  1. 文件位置信息

    文件路径:[组件完整路径]
    所属模块:[模块名称]
    
  2. 组件基本信息

    组件名称:[名称]
    功能描述:[简要描述]
    最近更新:[时间] by [作者]
    
  3. 依赖关系分析

    直接依赖:
    - [组件名] - [依赖类型] - [用途说明]
    被引用于:
    - [组件名] - [引用位置] - [使用场景]
    
  4. 历史变更记录

    最近变更:
    - [日期] [PR#] [作者] - [变更内容]
    - [变更原因]
    - [相关讨论]
    
  5. 风险评估总结

    潜在风险:
    - 高风险:[描述] - [原因] - [建议]
    - 中风险:[描述] - [原因] - [建议]
    - 低风险:[描述] - [原因] - [建议]
    
  6. 建议和注意事项

    修改建议:
    1. [具体建议1]
    2. [具体建议2]
    注意事项:
    - [需要特别注意的点]
    

Risk Assessment Rules

  1. 高风险判定标准:

    • 修改影响多个核心业务模块
    • 涉及支付、订单等关键功能
    • 影响用户数据或隐私
    • 改动大量被引用的公共组件
  2. 中风险判定标准:

    • 修改影响多个普通业务模块
    • 涉及UI交互改动
    • 需要同步修改多个相关组件
    • 改动被多处引用的文案或样式

Read the full file on GitHub · 140 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. yesterday First seen · 140 lines · 1,318 tokens per session scan A 9a1532ecc921

Subscribe to this mod's changes

graph-query is a cursor rule published in the GitHub repository aiuluna/knowledge-graph-mcp (1 stars, last pushed 1y ago), licensed MIT. It adds 1,318 tokens to every session, about $0.0066 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.