用 CLAUDE.md 加本地 MCP 记忆架构,避免 Claude Code 反复纠正和烧额度
原文标题:Stop burning Claude Code quota on amnesia. The exact CLAUDE.md + MCP memory architecture that survived 1,900 sessions (Open Source)
作者开源了 Project Athena v9.9.9 内核(MIT 许可),一套本地优先的记忆与治理框架,用于解决 Claude Code 反复纠正、子智能体越界改文件、以及中途撞上额度上限后状态丢失的问题。
作者用 1900 次会话验证的 CLAUDE.md 瘦身与本地记忆方案,给出了可直接复用的目录结构和验证规则。
当前语言的正文正在等待翻译,暂时显示原文。
There’s a post on the front page right now mentioning that after 2,752 Claude Code prompts, most of them were typing the exact same corrections over and over:
- "Don't mock it."
- "Did you actually run it?"
- "I didn't ask you to change that."
- Mock data passing review that breaks in production. Alongside that, another thread highlights hitting the daily usage cap mid-task and feeling like "a worker who lost his hammer." If you run Claude Code daily in the terminal, you know this loop:
- You start a session, and Claude Code spends thousands of tokens exploring directories or reading a bloated CLAUDE.md before writing code.
- Sub-agents run wild, modify files outside their scope, and declare victory ("All tests verified!") without actually checking if the feature works.
- Mid-refactor, you hit your 5-hour limit or daily quota. Because state lived inside the CLI session's context, you either wait for reset or start from scratch. For the past 18 months, I’ve run everything through Claude Code using an open-source, local-first memory and governance harness called Project Athena (1,900+ logged CLI sessions). I just open-sourced the v9.9.9 kernel under the MIT license. Here is the operational setup that prevents token bleed and stops Claude Code from hallucinating completed tasks.
1. The Surgical CLAUDE.md Diet (<2K Tokens)
Your CLAUDE.md should not be an encyclopedia. It should be a deterministic state machine router. Instead of bloating CLAUDE.md with hundreds of lines of prose (which invalidates prompt caches and burns your quota), keep it under 80 lines and point state to plain, git-versioned Markdown on your local SSD:
[ Local Machine: Plain Git-Versioned Markdown ]
├── CLAUDE.md<-- Lightweight execution router (<1.5K tokens)
├── .context/ │
├── CANONICAL.md<-- Materialized rules, immutable tech contracts │
└── memory_bank/ │
└── activeContext.md <-- Active tasks & session checkpoints
├── .agent/workflows/ <-- Deterministic slash commands (/start, /end, /plan)
├── .agent/skills/ <-- Domain skills loaded strictly on-demand
└── .agent/scripts/ <-- Mechanical test runners & verification hooks
- Surgical Boot: Running /start loads only the active checkpoint block from activeContext.md and top-level constraints. Over 90% of Claude's context window stays open for actual code, AST analysis, and tool calls.
- Session Distillation (/start and /end): When you finish a work block, /end audits git diffs, extracts architectural decisions, and writes an atomic checkpoint back to disk. Session 1,900 boots faster and cleaner than Session 10.
- Quota Hedge: If you hit your usage limit mid-task, your state isn't trapped in a dead CLI process. It is committed to activeContext.md on your drive. You can resume cold tomorrow, or point another tool at the exact same files with zero context loss.
2. Eliminating the "Did You Actually Run It?" Loop
Prompting Claude Code: "Please verify your code" does not work. Models are sycophantic; they love to invent plausible mocks and claim green status. Athena enforces mechanical verification outside the model's weights:
- Red Run or It Didn't Happen: Any agent claiming to fix a test, gate, or bug must show the test script failing on the pre-fix state, then passing on the fixed state. If it cannot produce the red run, it found a blind spot, not a fix.
- The Immutable Test Invariant: When a test fails, Claude Code must correct the source code to satisfy the contract. It is strictly forbidden from loosening test assertions, commenting out checks, or mocking the interface solely to achieve a green exit code.
- Loop Circuit Breaker: If Claude Code loops 3 times on the same error signature, execution halts immediately with a diagnostic report rather than burning your quota in an infinite retry loop.
3. Native Local MCP Integration
Athena includes a standalone local MCP server (mcp-athena-server) that gives Claude Code native tools on your machine:
- smart_search: Local hybrid retrieval (BM25 keyword + local semantic embeddings) across 1,900+ sessions of project memory.
- quicksave: Instant atomic saving of verified architectural facts directly to disk.
- context_gate: Deterministic pre-flight check ensuring Claude Code inspects local dependency maps and contracts before modifying shared modules. Zero cloud databases. Zero telemetry. 100% Python, SQLite, and Markdown.
Works with Claude Code, Cursor, Antigravity, or raw terminal CLI workflows.
```bash
git clone https://github.com/winstonkoh87/Athena-Public.git
cd Athena-Public
pip install -e .
athena init .
来源:Reddit · ClaudeCode / Codex / VibeCoding · reddit.com