Discover MCPs & agents
Loading MCPs and agents…
Loading MCPs and agents…
Claude Code 上下文健康诊断指南 — 识别和修复会话中的上下文退化问题
From the repo.
English Summary: Claude Code sessions degrade over time through 5 failure modes: Context Rot (early instructions forgotten), Context Pollution (irrelevant data diluting signal), Context Drift (gradual goal deviation), Context Explosion (window overflow triggering compression), and Context Cross-Contamination (cross-project interference). This guide provides symptoms, diagnostic methods, and mitigation strategies for each. Key prevention: one task per session, persist decisions to
CLAUDE.md, use subagents for exploration, checkpoint regularly.
帮助你识别和修复 Claude Code 会话中的上下文退化问题。
Claude Code 在长会话中可能出现五类上下文问题。本指南提供每类问题的定义、症状、诊断方法和缓解策略。
定义:早期指令/决策被压缩或遗忘,Claude 不再遵守会话开始时约定的规则。
直接询问 Claude:
"请复述我们在这个会话中做出的所有架构决策"
"我之前要求你遵守哪些约束?"
如果 Claude 无法准确复述,说明早期上下文已被压缩丢失。
CLAUDE.md 或 memory,不依赖会话记忆/compact 时在 prompt 中嵌入关键规则定义:大量无关信息(冗长报错、巨型文件内容、无用搜索结果)占据上下文窗口,稀释有效信号。
观察 Claude 的引用来源:
offset/limit 精确读取,不要全量读取大文件grep 返回几百行结果定义:Claude 逐步偏离原始任务目标,不知不觉中改变了实现方向。
问 Claude:
"我最初的请求是什么?你现在在做什么?这两者之间的关系是什么?"
或者检查 git diff — 如果改动的文件数量远超预期,说明已经漂移。
TaskCreate 分解任务,每完成一个就检查是否偏离定义:上下文窗口被快速填满,触发自动压缩,导致信息大量丢失。
关注以下信号:
head_limit 截断定义:不同任务/项目的上下文互相干扰,Claude 把 A 项目的模式应用到 B 项目。
问 Claude:
"你现在的工作目录是什么?这个项目用的是什么技术栈?"
然后检查:
package.json / requirements.txt 中?CLAUDE.md 明确声明项目技术栈和惯例| 检查项 | 方法 | 异常信号 |
|---|---|---|
| 规则记忆 | 要求复述约定 | 无法准确复述 |
| 任务焦点 | 对比初始请求与当前动作 | 明显偏离 |
| 引用准确性 | 检查引用的路径/函数是否存在 | 引用幽灵代码 |
| 风格一致性 | 对比新代码与项目惯例 | 风格突变 |
| 响应质量 | 观察回答的具体性 | 从精确变为笼统 |
| 改动范围 | git diff --stat | 超出预期的文件变更 |
CLAUDE.md + memory,不依赖会话记忆欢迎提交 Issue 或 PR 补充更多诊断场景和缓解策略。
Built by @MackDing — One-Person Company infrastructure powered by AI agents.
| Project | What it does |
|---|---|
| opc.ren | OPC founder hub — tools, signals, community |
| CodexClaw | Telegram bot for remote Codex access with MCP + subagent routing |
| awesome-ai-api | Leaderboard of 200+ AI API gateways & relays |
| claude-context-health | Diagnose & fix Claude Code session degradation |
| opc-daily-signal | AI-powered daily decision intelligence for OPC founders |
| doc-preprocess-hub | Enterprise document preprocessing — MinerU + docling |
Replace {MCP_ENDPOINT_URL} with this MCP’s endpoint URL (from its repo or docs above). No API key — you connect directly.
Tool
OS
Config file: ~/.cursor/mcp.json
{
"mcpServers": {
"mcp-server": {
"url": "{MCP_ENDPOINT_URL}"
}
}
}Paste into mcpServers in the config file. Restart Cursor after saving.
If this MCP is also published on mcpchannel.ai, you can subscribe from Browse and use the gateway config there instead.