context7-preload-standard

context7-preload-standard is a cursor rule for coding agents from Mr-chen-05/rules-2.1-optimized. It costs 21 tokens per session (1,247 once invoked), scanned A, original, MIT.

A set of rules for loading relevant project knowledge before fixing bugs or starting new development work. Context7 is a knowledge-retrieval tool, and the instructions define what project files to search, how to judge the results, and what to do if the tool is unavailable.

In plain words
What is it for?
Use it at the start of bug investigations, new features, optimizations, refactors, or new projects to collect relevant context and record a short summary for review.
Why use it?
It reduces the risk of changing code before understanding the architecture, interfaces, constraints, history, and testing approach.

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/mr-chen-05/rules-2.1-optimized/context7-preload-standard
Clone the repo
git clone --depth 1 https://github.com/Mr-chen-05/rules-2.1-optimized

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 context7-preload-standard

README.md
[![agentmods](https://agentmods.dev/badge/rules/mr-chen-05/rules-2.1-optimized/context7-preload-standard.svg)](https://agentmods.dev/rules/mr-chen-05/rules-2.1-optimized/context7-preload-standard)
Your own site
<a href="https://agentmods.dev/rules/mr-chen-05/rules-2.1-optimized/context7-preload-standard"><img src="https://agentmods.dev/badge/rules/mr-chen-05/rules-2.1-optimized/context7-preload-standard.svg" alt="Measured on agentmods" height="20"></a>
Per session 21 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,247 The whole file, excluding the scripts and references it only reads on demand.
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.00021 $0.01247
Opus 5 $0.00010 $0.00624
Sonnet 5 $0.00004 $0.00249
Haiku 4.5 $0.00002 $0.00125

Measured 4d ago against content hash f97c7f3c7749, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

context7-preload-standard 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 4d 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.

global-rules/context7-preload-standard.mdc · 76 lines

What it actually says

🧠 Context7 知识预载标准(修复/新项目前置)

目标:在修复 Bug 或启动新项目/新功能前,先用 Context7 预载关键知识(架构、约束、接口、历史决策、相关代码),避免“先动手后理解”,提升正确率与效率。

适用范围:前端、后端、全栈项目;适用于问题分析、任务实现、前端/后端开发工作流的起始阶段。

触发时机

  • 用户意图包含:Bug、Error、异常、修复、定位、排查、优化、重构、性能问题、新项目、新功能、初始化等
  • 工作流命令进入:/analyze-issue、/implement-task、/frontend-dev、/backend-dev 之前
  • 项目特征:存在 src/、docs/、tests/、config/、README.*、architecture/、api/ 等目录或文件
  • 触发约束(避免冲突与冗余):仅在进入上述工作流命令前触发;不在“启动超级大脑系统”等系统级启动命令下自动触发;若当前阶段已有足够上下文(已预载并未过期),则不重复执行。

执行步骤(标准化)

(1) 检索与聚合(Context7 优先)

  • 目录范围(默认):src、docs、tests、config、README.*、architecture、api、scripts、.github
  • Bug修复检索模板:错误堆栈/异常关键词、相关模块与文件名、最近改动记录、依赖和版本、兼容性/性能提示
  • 新功能/新项目检索模板:架构设计、核心模块与数据模型、接口协议/API 文档、技术约束(安全/性能/合规)、测试策略与最佳实践

(2) 质量阈值与时间界限

  • 至少命中 5 个高相关片段,或覆盖 3 类关键材料(架构、接口、约束)
  • 质量评分阈值:≥ 0.65(Context7 返回的相关度或评分)
  • 超时上限:60 秒;超过则进入回退流程

(3) 预载摘要输出与确认

  • 输出内容:关键结论、文件/链接清单、风险/约束、建议的下一步
  • 记录位置:project.context.md 的 Pinned 区块添加“知识预载摘要”与链接
  • 用户确认:通过增强反馈机制(mcp-feedback-enhanced)收集确认或补充,再继续执行后续流程

回退策略(Context7 不可用或质量不足)

  • 回退顺序:Context7 → 代码检索工具(search_codebase/search_by_regex)→ 文件系统直接读取
  • Context7 未安装:提示通过统一安装脚本或 MCP 管理规则安装并启用(参考 mcp-unified-management.mdc;install-mcp-tools-enhanced-final.ps1)
  • 质量不足:缩小或扩大检索范围、调整关键词模板、延长超时一次(最多 2 次重试),仍不足则进入最小必要信息模式

跳过条件(显式允许轻量变更直行)

  • 纯文档或注释修订、无代码行为改动
  • 打印/日志文本调整、单文件内小范围变量重命名
  • 单测文案微调且不影响逻辑
  • 如触发跳过,需在项目记录中标记“预载跳过原因”

安全与边界

  • 范围限制:仅在项目根及其子目录内检索,不越权访问外部系统
  • 输出约束:仅返回摘要与文件链接,不主动复制大量内容到对话
  • 合规保护:遵循 ai-ethical-boundaries.mdc;敏感信息脱敏

与系统的协同

  • 与 Context Loader:项目首次深度分析仍由 Context Loader 负责;Context7 预载用于具体任务前的针对性知识获取
  • 与记录员系统:预载摘要写入 project.context.md 的 Pinned/Notes;重要结论纳入决策记录链
  • 与智能推荐引擎:若意图为 Bug 修复或新项目启动,优先推荐执行本标准作为前置步骤

实施提示(为项目规则引用)

  • 在 analyze-issue.mdc、implement-task.mdc、frontend-dev.mdc、backend-dev.mdc 的“Process/流程”前插入“前置步骤:Context7 知识预载”,简述触发、步骤、质量阈值、回退与确认
  • 设置默认参数:目录范围(src, docs, tests, config, README.*, architecture, api)、质量阈值 ≥0.65、超时 60s、回退顺序如上、允许轻量变更跳过

核心目标:让“先理解后执行”成为系统默认行为,降低返工与错误率,加速交付。

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. 4d ago First seen · 76 lines · 21 tokens per session scan A f97c7f3c7749

Subscribe to this mod's changes

context7-preload-standard is a cursor rule published in the GitHub repository Mr-chen-05/rules-2.1-optimized (172 stars, last pushed 10mo ago), licensed MIT. It adds 21 tokens to every session and 1,247 once invoked, about $0.0001 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-30.