展示HN:我通过持久化的Markdown文件解决了Claude Code的上下文漂移问题
我一直在使用Claude Code构建SaaS产品,但总是遇到同样的问题:它写出出色的代码20分钟后,就忘记了你的数据库架构,开始重写已经工作的代码。问题不在于模型的记忆,而在于会话之间没有持久的项目上下文。明天再回来,Claude对昨天构建的内容一无所知。
我的解决方案是:在每次操作之前强制Claude读取项目真相文件。我构建了一个多代理系统,提前创建持久的上下文文件:
- PROJECT.md - 你正在构建的内容、商业模型、核心功能
- REQUIREMENTS.md - 数据库架构、认证流程、API结构、边缘案例
- ROADMAP.md - 构建阶段及成功标准
- STATE.md - 当前状态、已完成的工作、待办任务
它是如何工作的:
AI产品经理会提出大多数开发者跳过的问题:
“资金是如何流动的?”
“用户在月中取消时会发生什么?”
+ 任何特定于你SaaS的边缘案例
根据你的回答创建markdown文件。Claude Code在写任何代码之前都会读取这些文件。没有猜测。无法忘记架构,因为它被明确记录。
执行代理根据任务生成,每个代理都读取相同的上下文文件。它们并行构建,但从不破坏已经工作的部分。验证代理在每个阶段后根据成功标准进行测试。如果出现问题,会生成调试代理,并附带持久的调查文件。
结果:
使用这个系统在30天内构建了3个产品:
- 分析仪表盘:13小时
- 反馈小部件:18小时
- 内容日历:9小时
没有上下文漂移。没有“Claude忘记了我的认证系统”的时刻。只有一致的构建。
最大的区别是:
星期六:与Claude一起构建认证
星期天:回来,描述下一个功能
Claude读取REQUIREMENTS.md,看到现有的认证架构
在不触及认证的情况下构建新功能
而不是Claude重写所有内容的正常体验。
我将其打包为PropelKit(Next.js模板 + 自动创建这些文件的AI PM系统)。但核心概念,即持久的markdown上下文,适用于任何Claude Code设置。
试试吧: [https://propelkit.dev](https://propelkit.dev)
该代理架构使用Claude Sonnet/Opus(可配置)并行思维,生成多个代理,这些代理都从相同的真相文件中读取。欢迎随时询问关于实现的任何问题。
查看原文
I've been using Claude Code to build SaaS products, and kept hitting the same wall: it writes brilliant code for 20 minutes, then forgets your database schema and starts rewriting working code.
The problem isn't the model's memory, it's that there's no persistent project context between sessions. Come back tomorrow and Claude has zero knowledge of what it built yesterday.
My solution: Force Claude to read project truth files before every action.
I built a multi-agent system that creates persistent context files upfront:
PROJECT.md - What you're building, business model, core features
REQUIREMENTS.md - Database schema, auth flows, API structure, edge cases
ROADMAP.md - Build phases with success criteria
STATE.md - Current position, completed work, pending tasks
How it works:<p>AI Product Manager asks questions most developers skip:<p>"How does money flow through this?"
"What happens when users cancel mid-month?"
+ Any Edge cases specific to your SaaS<p>Creates the markdown files from your answers.
Claude Code reads these files before writing ANY code.
No guessing. Can't forget the schema, it's literally documented.
Executor agents spawn per task, each reading the same context files.
They build in parallel but never break what's already working.
Verifier agent tests against success criteria after each phase.
If broken, spawns debugger agent with persistent investigation files.<p>Results:
Built 3 products in 30 days using this system:<p>Analytics dashboard: 13 hours
Feedback widget: 18 hours
Content calendar: 9 hours<p>No context drift. No "Claude forgot my auth system" moments. Just consistent builds.
The biggest difference:
Saturday: Build auth with Claude
Sunday: Come back, describe next feature
Claude reads REQUIREMENTS.md, sees existing auth schema
Builds new feature without touching auth
vs. the normal experience of Claude rewriting everything.
I packaged this as PropelKit (Next.js boilerplate + AI PM system that creates these files automatically). But the core concept, persistent markdown context, works with any Claude Code setup.<p>Try it: <a href="https://propelkit.dev" rel="nofollow">https://propelkit.dev</a><p>The agent architecture uses Claude Sonnet/Opus (configurable) parallel thinking to spawn multiple agents that all read from the same truth files. Happy to answer questions about the implementation.