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/error-recovery-systemgit 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/error-recovery-system)<a href="https://agentmods.dev/rules/mr-chen-05/rules-2.1-optimized/error-recovery-system"><img src="https://agentmods.dev/badge/rules/mr-chen-05/rules-2.1-optimized/error-recovery-system.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 | $0.03270 | $0.03270 |
| Opus 5 | $0.01635 | $0.01635 |
| Sonnet 5 | $0.00654 | $0.00654 |
| Haiku 4.5 | $0.00327 | $0.00327 |
Grade A, and why
error-recovery-system 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 5d 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 — 434 lines — stays where its author put it; the contents beside it link to each section on GitHub.
🔄 错误恢复机制系统
智能恢复: 自动检测错误并执行恢复策略,确保系统稳定运行
🎯 系统概述
错误恢复机制为规则系统提供三层保护:
- 预防层: 操作前验证和备份
- 检测层: 实时监控和异常识别
- 恢复层: 自动修复和降级策略
📋 恢复机制类型
1. 系统激活中断恢复
检测方法:
完整性检查:
- 检查 project.context.md 存在性
- 验证文件完整性(必需区块)
- 检查元数据一致性
- 验证文件大小和时间戳
必需区块列表:
- "项目元数据 (Project Metadata)"
- "快速导航 (Quick Navigation)"
- "置顶信息 (Pinned)"
- "决策记录 (Decisions)"
- "待办事项 (TODO)"
完整性评分:
计算公式: (存在的必需区块数 / 总必需区块数) * 100
恢复策略:
完整性 100%:
→ 跳过激活
→ 输出: "✅ 系统已激活,上下文完整"
→ 继续正常工作流
完整性 50-99%:
→ 补全缺失部分
→ 保留现有内容
→ 输出: "⚠️ 检测到部分缺失,已自动补全"
→ 执行增量更新
完整性 <50%:
→ 备份现有文件
→ 重新激活系统
→ 输出: "🔄 系统损坏严重,执行完整重建"
→ 询问用户是否恢复备份
完整性 0%:
→ 全新激活
→ 输出: "🆕 首次激活系统"
→ 创建完整项目记忆文件
中断恢复流程:
1. 检测中断点:
- 读取 .cache/activation-checkpoint.json
- 识别上次失败的步骤
2. 继续执行:
- 从中断点继续
- 跳过已完成步骤
- 输出进度: "🔄 从步骤 X 继续..."
3. 清理检查点:
- 成功完成后删除检查点文件
- 失败时保留供下次恢复
2. 文件操作失败恢复
备份机制:
自动备份:
触发时机:
- 修改 project.context.md 之前
- 执行大规模文件操作之前
- 用户明确请求时
备份路径:
- .backups/project.context.md.{timestamp}.bak
- 保留最近 3 个版本
- 超过 7 天的备份自动清理
备份内容:
- 完整文件内容
- 文件元数据
- 时间戳和校验和
备份元数据:
{
"version": "1.0",
"original_file": "project.context.md",
"backup_time": "2025-10-18T10:30:00Z",
"file_size": 15360,
"checksum": "abc123def456...",
"reason": "before_update",
"can_auto_restore": true
}
恢复命令:
用户指令:
- "/恢复上一版本" → 恢复最近的备份
- "/查看备份历史" → 列出所有可用备份
- "/恢复到 {timestamp}" → 恢复指定备份
- "/手动回滚" → 交互式选择备份
自动回滚:
触发条件:
- 文件操作失败
- 文件损坏检测到
- 写入操作异常
回滚流程:
1. 检测失败: catch exception
2. 查找最近备份: 最新的 .bak 文件
3. 验证备份完整性: checksum验证
4. 执行回滚: 覆盖当前文件
5. 通知用户: "🔄 操作失败,已自动回滚"
6. 记录日志: 失败原因和恢复结果
失败处理流程:
try {
// 1. 创建备份
backup_file = create_backup("project.context.md")
// 2. 执行操作
perform_file_operation()
// 3. 验证结果
if not validate_result():
throw new Error("Operation validation failed")
// 4. 操作成功,可选择删除备份
if auto_cleanup:
schedule_backup_cleanup(backup_file)
} catch (error) {
// 5. 操作失败,自动回滚
log_error(error)
restore_from_backup(backup_file)
notify_user("🔄 操作失败,已回滚到安全状态")
throw error // 重新抛出供上层处理
}
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.
- 5d ago First seen · 434 lines · 3,270 tokens per session scan A 67aab8f869a5
error-recovery-system 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 3,270 tokens to every session, about $0.0163 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.
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.
cli-error-handling
CLI command error handling patterns.
prefer-direct-imports-over-module-mocks
Prefer extracting a testable core over vi.mock / vi.resetModules when unit tests need to reach production logic entangled with config, env, or singletons.
control-plane-descriptors
Control plane descriptor and instance implementation patterns.
family-instance-domain-actions
Family instance domain action implementation patterns.