正在加载陈远的个人网站

清理 Claude Code 系统提示词膨胀

通过代理审计请求内容并精简 settings.json,降低 Claude Code 会话启动上下文成本。

原始内容

Here's a step-by-step process to kill all the bloat from your Claude Code system prompt: 1. Run a proxy so you can see exactly what gets sent to Claude Code (included in the article) 2. "Fuck, there is so much cruft in there" 3. Use my settings.json to kill all the bloat Down to a clean 13K tokens to start each session with. Nice. Full process here: https://t.co/Kie84HMe2A

中文译文

机器翻译,保留原文供核对。

以下是一步步清除 Claude Code 系统提示词中所有臃肿内容的过程: 1. 运行一个代理,这样你就能准确看到发送给 Claude Code 的内容(文章中有介绍) 2. “靠,里面怎么这么多垃圾” 3. 用我的 settings.json 清除所有臃肿内容 每次开始会话时,干净地降到 13K tokens。不错。 完整流程在这里: https://t.co/Kie84HMe2A

深度解析

是什么 这条推文分享了一套清理 Claude Code 系统提示词的实践流程:先运行代理,观察客户端实际发送给模型的完整内容;再识别其中的冗余信息;最后通过 settings.json 进行配置级精简。作者声称优化后每次会话以约 13K Token 起步。\n\n核心机制 关键不在于重新设计提示词文案,而在于建立“请求可见性—问题定位—配置收敛”的闭环。代理提供了对上下文组成的直接观测,使开发者能够区分必要指令、工具描述、环境信息与历史遗留配置。\n\n关键洞察 Agent 系统的性能和成本不只取决于模型,也取决于每次调用前被动注入了多少上下文。降低固定启动负担,可以释放更多窗口给任务本身,并改善响应速度与可控性。\n\n边界与风险 当前材料只有推文摘要和未展开的 t.co 链接,无法核验 settings.json 的具体字段、代理实现方式或 13K Token 的测量口径。过度删减也可能移除安全约束、项目规范或必要工具说明,因此应在精简后验证任务成功率与行为稳定性。

精选追评与案例

  1. 给出启动上下文与工具数量的前后对比,量化收益。

    @mattpocockuk "Claude Code startup context dropped from 96,602 to 28,928 real input tokens, saving 67,674 tokens per request (70.1%) while tools dropped from 115 to 20 (82.6%)." 😬

    中文译文 · 机器翻译

    “Claude Code 启动上下文从 96,602 个真实输入 token 降至 28,928 个,每次请求节省 67,674 个 token(70.1%),同时工具从 115 个减至 20 个(82.6%)。” 😬

  2. 提醒改系统提示词可能触发封禁或 API 定价风险,是重要边界。

    @mattpocockuk Pretty sure changing the system prompt will lead to a ban at some point (or will lead to api price), it is effectively the same as customising the harness

    中文译文 · 机器翻译

    我相当确定,改系统提示词迟早会导致封禁(或者会带来 API 定价问题),这实际上等同于定制 harness。

  3. 提供无需代理的可视化脚本,并建议关闭冗余提醒,实操性强。

    @mattpocockuk If you want to visualize the hidden bloat live in claude without a proxy I made a user script that shows a hidden context drawer, great for getting a visceral feel. Also worth turning off all the annoying reminder prompts that get fired imo

    中文译文 · 机器翻译

    如果你想不借助代理,在 Claude 里实时可视化隐藏的臃肿内容,我写了一个用户脚本,会显示一个隐藏的上下文抽屉,很适合直观感受一下。 另外,我觉得也值得关掉所有那些烦人的、会被触发的提醒提示词。

  4. 给出企业环境下的降本数据,并指出被策略禁用的工具仍出现在系统提示词中。

    @mattpocockuk Dropped mine from ~31k to 12k. Interestingly I work at an enterprise where we don't even allow by enterprise policy some of these tools, yet claude still includes them in the system prompt. We don't allow remotetriggers, pushnotifications etc but they're still there.

    中文译文 · 机器翻译

    我把自己的从约 31k 降到了 12k。 有意思的是,我在一家企业工作,企业政策甚至不允许其中一些工具,但 Claude 仍把它们包含在系统提示词里。 我们不允许 remotetriggers、pushnotifications 等,但它们仍然在那里。

  5. 用竞品默认配置作横向参照,补充 13K 是否算低的判断。

    @mattpocockuk Kinda crazy you end up at 13k after aggressive optimization. Hermes Agent with all default settings which includes morr core tools and 60 built in skills etc is only ~11k

    中文译文 · 机器翻译

    经过如此激进的优化后,你最终才到 13k,真有点离谱。Hermes Agent 在所有默认设置下(包含更多核心工具和 60 个内置技能等)也只有约 11k。