Summary

A deep-dive engineering guide to Claude Code written by a practitioner who spent 6+ months and $40/month using it in production. The article dissects Claude Code into 6 layers (context, control, tools, skills, subagents, verification) and argues that most failures are context engineering problems, not model capability problems. It covers context cost breakdowns, skill design patterns, tool selection principles, hook architecture, and how to write a CLAUDE.md that actually works.

一篇來自深度使用者(每月 40 刀、兩個帳號、半年實戰)的 Claude Code 工程指南。文章將系統拆成六層分析,核心論點是:大多數卡住的問題不是模型不夠聰明,而是給錯了上下文。涵蓋上下文成本分拆、Skill 設計模式、工具選型原則、Hook 架構,以及如何寫出真正有效的 CLAUDE.md。

Key Points

  • Claude Code 200K 上下文並非全可用:MCP Server 工具定義每個約 200 tokens,接 5 個 Server 就固定消耗 25K tokens(12.5%)
  • 上下文分層策略:CLAUDE.md 常駐 → rules 按路徑加載 → Skills 按需加載 → Subagents 隔離加載 → Hooks 不進上下文
  • 壓縮機制陷阱:默認算法會優先刪掉架構決策和約束理由,需在 CLAUDE.md 寫明 Compact Instructions 保留優先級
  • HANDOFF.md 模式:切換 session 前先讓 Claude 寫交接文件,讓下一個 agent 直接讀而不依賴壓縮摘要
  • Skill 描述符應寫「何時該用我」而非「我是做什麼的」,且要短(9 tokens vs 45 tokens 差距顯著)
  • Plan Mode:把探索和執行拆開,複雜重構先用一個 Claude 寫計劃,再用 Codex 以「高級工程師」身份審計
  • 有副作用的 Skill 必須設 disable-model-invocation: true,防止 Claude 自行決定是否執行

Insights

  • 「上下文不是容量問題,而是噪聲問題」——這個框架轉換很重要,意味著解法不是擴大窗口,而是降低信噪比
  • MCP Server 的隱形成本被嚴重低估:大多數人只想著「加更多工具」,但每個工具定義都在消耗固定 token
  • CLAUDE.md 官方自己只用 2.5K tokens,這個錨點值得警惕——很多人的 CLAUDE.md 已經比官方的長
  • Skill 使用頻率決定設計策略:高頻保持 auto-invoke、低頻手動觸發、極低頻直接移除改為文件
  • RTK(Rust Token Killer)透過 Hook 攔截並壓縮 Tool Output,只保留決策需要的核心信息——這個模式可推廣到任何輸出很長的工具
  • 「AI 審 AI」:用一個 Claude 寫計劃 + 另一個 AI 以高級工程師身份審查,是一個成本低但品質高的驗證模式

Connections

Raw Excerpt

卡住的地方几乎从来不是模型不够聪明,更多时候是给了它错误的上下文,或者写出来了但根本没法判断对不对,也没法撤回。