从 500,000 行 Claude Code 泄露中你能学习和复制什么
A source map bundled into the Claude Code npm package exposed the entire TypeScript source tree: 2,203 files, 512,664 lines of code.
捆绑在 Claude Code npm 包中的源映射暴露了整个 TypeScript 源代码树:2,203 个文件,512,664 行代码。
The high-level architecture has been covered elsewhere. This piece focuses on the specific, non-obvious things that are actually useful: prompt engineering patterns that steer model behavior, operational thresholds calibrated from production incidents, security techniques, context management strategies, and a few things that are just fun to know about.
高层架构已在其他地方覆盖。本文聚焦于具体、非显而易见的真正有用的东西:引导模型行为的提示工程模式、从生产事件校准的操作阈值、安全技术、上下文管理策略,以及一些只是有趣的知识点。
Each section explains not just what they built, but why they built it that way, and what you can take from it.
每个部分不仅解释了他们构建了什么,还解释了为什么那样构建,以及你能从中获得什么。
1. The System Prompt Is a Masterclass in Behavioral Steering
1. 系统提示是行为引导的大师课
The full system prompt lives in constants/prompts.ts and it's the single most valuable file in the archive. Not because it's secret, but because it shows exactly how Anthropic steers Claude's behavior in a production coding agent, and why each instruction exists.
完整的系统提示位于 constants/prompts.ts,它是存档中最有价值的单个文件。不是因为它是秘密的,而是因为它精确展示了 Anthropic 如何在生产编码代理中引导 Claude 的行为,以及每个指令的存在原因。
"Three similar lines of code is better than a premature abstraction." The coding instruction section explicitly tells Claude not to create helpers, utilities, or abstractions for one-time operations. It says don't design for hypothetical future requirements.
“三行相似的代码比过早抽象更好。” 编码指令部分明确告诉 Claude 不要为一次性操作创建 helpers、utilities 或 abstractions。它说不要为假设的未来需求设计。
Why this exists: LLMs love to abstract. Given a repeated pattern, Claude will instinctively create a helper function, add configurability, or build a utility class. In a coding agent, this creates bloat the user never asked for. Anthropic learned that you have to explicitly tell the model to resist its own instinct toward over-engineering. If you're building any AI coding tool, you'll face the same problem. Encode your coding philosophy...