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/mr-chen-05/rules-2.1-optimized/context-recorder-edge-casesgit clone --depth 1 https://github.com/Mr-chen-05/rules-2.1-optimizedWrote 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.
[](https://agentmods.dev/rules/mr-chen-05/rules-2.1-optimized/context-recorder-edge-cases)<a href="https://agentmods.dev/rules/mr-chen-05/rules-2.1-optimized/context-recorder-edge-cases"><img src="https://agentmods.dev/badge/rules/mr-chen-05/rules-2.1-optimized/context-recorder-edge-cases.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00000 | $0.02740 |
| Opus 5 | $0.00000 | $0.01370 |
| Sonnet 5 | $0.00000 | $0.00548 |
| Haiku 4.5 | $0.00000 | $0.00274 |
Grade A, and why
context-recorder-edge-cases 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 6d 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.
How it starts
The opening of the file, as written. The whole thing — 439 lines — stays where its author put it; the contents beside it link to each section on GitHub.
🛡️ Context Recorder Edge Cases (记录员边界情况处理)
模块说明: 本文件包含边界情况处理、异常恢复和极端场景应对
相关模块
context-recorder-core.mdc- 核心定义和主要规则context-recorder-templates.mdc- 模板定义context-recorder-advanced.mdc- 高级功能
字符编码处理
编码支持
```yaml 支持的编码格式:
- UTF-8 (默认推荐)
- UTF-16
- ISO-8859-1
- GBK/GB18030 (中文)
- ASCII ```
编码检测和转换
```yaml 自动检测流程:
- 读取文件首字节检查BOM
- 分析文本特征确定编码
- 尝试UTF-8解码
- 若失败,尝试其他编码
- 最后使用 ISO-8859-1
编码转换规则: 输入时: - 自动检测输入编码 - 转换为UTF-8内部表示 - 保留原始编码信息
输出时: - 统一使用UTF-8输出 - 对特殊字符进行转义 - 保持可读性
错误处理:
- 编码错误时使用替代字符 (U+FFFD)
- 记录编码错误到日志
- 提示用户检查文件编码 ```
时间戳精度
时间戳格式
```yaml 标准格式: YYYY-MM-DD HH:MM:SS.mmm ±TIMEZONE 示例: 2025-01-31 14:30:45.123 +08:00
精度要求: 秒级: 正常操作 (标准) 毫秒级: 高精度需求 (可选) 微秒级: 性能敏感操作 (不推荐) ```
时间戳验证
```yaml 检查项:
- 格式是否符合标准
- 年月日是否有效
- 小时分钟秒是否有效
- 时区偏移是否正确
时间戳顺序检查:
- 同一操作内时间戳必须递增
- 不同操作的时间戳应合理
- 检测到时间逆转时发出警告
系统时间校准:
- 定期与NTP服务器同步
- 检测到系统时间跳跃时告警
- 时间异常时使用递增逻辑时间 ```
特殊字符处理
特殊字符分类
```yaml 控制字符 (ASCII 0-31, 127):
- 处理: 转义或删除
- 示例: \n, \t, \r
Unicode 补充字符:
- 处理: 使用代理对表示
- 范围: U+10000 到 U+10FFFF
零宽字符:
- 零宽空格 (U+200B)
- 零宽连接符 (U+200D)
- 处理: 删除或标记
方向标记:
- RTL标记 (U+202E)
- LTR标记 (U+202D)
- 处理: 保留,用于多语言支持 ```
特殊字符转义
```yaml 在JSON中:
- " → \"
- \ → \\
- \n → \\n
- \t → \\t
在URL中:
- 使用百分比编码 (%XX)
在Markdown中:
-
- → \*
- [ → \[
- _ → \_ ```
大文件处理
大文件定义
```yaml 文件分类:
- 普通文件: < 10MB
- 大文件: 10MB - 100MB
- 超大文件: > 100MB ```
处理策略
```yaml 分块处理: 块大小: 512KB 处理流程: 1. 打开文件流 2. 逐块读取数据 3. 处理每个块 4. 累积结果 5. 关闭文件流
内存优化:
- 不一次性加载整个文件
- 使用流式处理
- 及时释放已处理数据
进度跟踪:
- 显示处理进度百分比
- 估计剩余时间
- 允许用户取消操作 ```
并发访问处理
并发场景
```yaml 常见场景:
- 多个用户同时写入
- 一个用户读,另一个用户写
- 多个AI实例同时操作
- 系统维护与用户操作冲突 ```
锁机制
```yaml 文件锁:
- 共享锁 (读操作)
- 独占锁 (写操作)
- 获取时间: 操作开始
- 释放时间: 操作完成
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.
- 6d ago First seen · 439 lines · 0 tokens per session scan A e2790a57f02c
context-recorder-edge-cases 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 costs nothing until one of its globs matches a file; then it loads 2,740 tokens. 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.
Other cursor rules, from other repositories
mempalace-recall-always
Always-on MemPalace recall — search the palace before answering about past work, people, projects, or prior decisions.
dreamd-recall
Recall lessons, decisions, and prior context from the .agent/ memory daemon. Use when starting work in a project that has a .agent/ folder, when the user references a past decision, or when you are about to make a choice that has a documented prior.
session-memory
Use at conversation wrap-up or when the user explicitly indicates end-of-session — capture residual lessons not captured in-flight.
common_memory_bank
I am Cursor, an expert software engineer with a unique characteristic: my memory resets completely between sessions. This isn't a limitation - it's what drives me to maintain perfect documentation. After each reset, I rely ENTIRELY on my Memory Bank to understand the project and continue work effectively. I MUST read…
memsprout
Cursor rule "memsprout" from memsprout/agents, covering using memsprout, search first, capturing, spaces and topics and files.
self-improving-obsidian-llm-wiki
LLM Wiki OS operating rules.