memforge-codebase-memory-routing

memforge-codebase-memory-routing is a cursor rule for Cursor from zql0805/memforge. It costs 641 tokens per session, scanned A, original, MIT.

Code-discovery rules for projects connected to Codegraph, a service that indexes code structure for queries. They define when to use Codegraph and when to use ordinary file searches.

In plain words
What is it for?
Use them to locate definitions, callers, callees, call paths, affected symbols, related source files, and project file structures.
Why use it?
They help agents find relevant code with fewer manual searches and less text to read.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use them to locate definitions, callers, callees, call paths, affected symbols, related source files, and project file structures.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/zql0805/memforge/memforge-codebase-memory-routing
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.

Clone the repo
git clone --depth 1 https://github.com/zql0805/memforge

Made for: Cursor.

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 memforge-codebase-memory-routing

README.md
[![agentmods](https://agentmods.dev/badge/rules/zql0805/memforge/memforge-codebase-memory-routing/github.svg)](https://agentmods.dev/rules/zql0805/memforge/memforge-codebase-memory-routing)
Your own site
<a href="https://agentmods.dev/rules/zql0805/memforge/memforge-codebase-memory-routing"><img src="https://agentmods.dev/badge/rules/zql0805/memforge/memforge-codebase-memory-routing/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for memforge-codebase-memory-routing

Your own site · 80×15
<a href="https://agentmods.dev/rules/zql0805/memforge/memforge-codebase-memory-routing"><img src="https://agentmods.dev/badge/rules/zql0805/memforge/memforge-codebase-memory-routing.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 641 This file is loaded in full into every session.
When invoked 641 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.00641 $0.00641
Opus 5.5 $0.00256 $0.00256
Sonnet 5.5 $0.00128 $0.00128
Haiku 4.5 $0.00064 $0.00064

Measured 1mo ago against content hash 1144e346a652, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

memforge-codebase-memory-routing 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 1mo 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.

packages/memory-service/src/rules-templates/memforge-codebase-memory-routing.mdc · 50 lines

What it actually says

代码发现工具路由策略

核心原则

当需要理解代码结构时,优先使用 Codegraph MCP 的结构化工具,而非 Grep/Glob/Read 全文搜索。 Codegraph 基于 AST 实时解析,已索引多个仓库,查询精确且 Token 消耗低。

工具选择决策树

需要做的事 首选(Codegraph) 备选(传统工具)
根据任务描述获取相关代码 codegraph_context(task) 手动 Grep + Read 多文件
查找函数/类/方法定义 codegraph_search(query) Grep 按函数名搜索
追踪谁调用了某函数 codegraph_callers(symbol) Grep 逐文件追踪
追踪某函数调了什么 codegraph_callees(symbol) Grep 逐文件追踪
追踪两个符号间的调用路径 codegraph_trace(from, to) 手动逐层追踪
分析修改某符号的影响范围 codegraph_impact(symbol) git diff + 手动分析
批量查看多个相关符号源码 codegraph_explore(symbols) 逐个 Read 文件
查看单个符号签名和位置 codegraph_node(symbol) Grep + Read
查看项目文件结构 codegraph_files(project) ls / Glob

多项目查询

所有工具支持 projectPath 参数切换目标仓库,格式:/opt/memforge/repos/<产品线>/<仓库名>

仍然使用 Grep/Glob/Read 的场景

以下场景直接使用传统工具:

  • 文本内容搜索:日志文本、错误消息、配置值、字符串常量
  • 文件名搜索:按文件名模式查找文件(Glob)
  • 配置文件:读取 JSON/YAML/TOML/ENV 等
  • 文档/注释:搜索 Markdown、README、注释
  • 非代码文件:SQL 脚本、Shell 脚本、Dockerfile
  • 已知文件路径:直接 Read

注意事项

  • Codegraph 数据基于 AST 实时解析,代码变更后 ~1s 自动同步
  • 优先使用 codegraph_context(task) —— 描述任务即可获取相关代码,无需精确指定符号名
  • 如果 Codegraph MCP 不可用(服务离线/网络不通),静默回退到 Grep/Glob/Read
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. 1mo ago First seen · 50 lines · 641 tokens per session scan A 1144e346a652

Subscribe to this mod's changes

memforge-codebase-memory-routing is a cursor rule published in the GitHub repository zql0805/memforge (2 stars, last pushed 3mo ago), licensed MIT. It adds 641 tokens to every session, about $0.0026 per session on Opus 5.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 cursor rules, from other repositories

compression-safety

Cursor rule "compression-safety" from yvgude/lean-ctx, covering compression safety — prevent lean-ctx marker corruption, the problem, rules for all agents, never write compressed content to files and file restoration commands.

yvgude/lean-ctx · 399 tokens

honcho_rules

Honcho persistent memory — capture every conversation, recall past context, and build a growing model of the user. Activates on every conversation.

matthewdcage/llm-swarm-router · 1,412 tokens

nauro-adopt

Seeds Nauro's project store from an existing repo. Use after nauro adopt has run locally. On filesystem-capable surfaces, reads docs (README, manifests, ADRs, Memory-Bank) for rationale and inspects code, config, tests, lockfiles, and recent git history for evidence, then surfaces targeted probes that turn evidence…

Nauro-AI/nauro · 89 tokens

nauro-context

Writes durable shared context into Nauro's project store so other agents (a later session or a parallel one) can discover and pull it, finds and reads context another agent left, or captures a resumable brief so your own next session in this environment picks up cleanly. Three modes. Author writes a shared brief for…

Nauro-AI/nauro · 272 tokens

graphmind-memory

A set of rules connects the coding agent to GraphMind, a shared memory system that stores project knowledge between sessions. It uses an MCP service to restore context, record actions, and save decisions.

kostya-pakhomov/graphmind · 298 tokens

compendium

Prefer the Compendium MCP gateway to shrink noisy/large context before pasting it into the conversation.

hocestnonsatis/Compendium · 564 tokens