Click any tag below to further narrow down your results
Links
This article examines how Claude Code constructs its system prompts by analyzing recently leaked source code. It highlights the dynamic nature of these prompts, which are built from various components based on conditional statements. The author also outlines additional elements that contribute to context, like tool definitions and conversation history.
- Claude Code's system prompt isn't static text—it's dynamically assembled at runtime from conditional components, revealed by a recent source code leak.
- The prompt mixes always-included elements (like core instructions) with conditional ones (like tool-specific guidance) that only appear based on context.
- Beyond the system prompt itself, the full context sent to the model includes tool definitions, conversation history, attachments, and skills—all engineered together to shape responses.
The article breaks down the recently leaked source code of Anthropic's Claude Code CLI. It highlights the system's architecture, design choices, and differences from OpenAI's Codex, particularly in handling context overflow and user interactions. Key features like compaction strategies and internal versus external user instructions are explored.
- Claude Code uses a four-tiered compaction strategy (proactive token monitoring, reactive fallback, and a "snip compaction" mode for headless sessions) versus Codex's simpler diff-based approach that just minimizes data sent per turn
- The system prompt uses a boundary marker to cache roughly 3,000 tokens of static instructions across users for performance gains
- Internal users get specialized instructions specifically designed to stop the model from misrepresenting test results or giving misleading status updates
- The codebase includes feature flags and build-time checks specifically to prevent sensitive information from leaking into public builds
The entire source code for Anthropic’s Claude Code CLI has leaked due to an internal error during a package release. This includes nearly 2,000 TypeScript files and over 512,000 lines of code, exposing the application’s inner workings to competitors and developers. Anthropic has acknowledged the mistake and stated it was not a security breach.
- A packaging error in Claude Code v2.1.88 exposed a source map, leaking the entire ~2,000-file, 512,000+ line TypeScript codebase.
- The leaked code was quickly archived and uploaded to GitHub, gaining tens of thousands of forks within a short time.
- Anthropic says no customer data was exposed and calls it human error, not a security breach, while adding safeguards.
- Developers have already begun reverse-engineering internals, like Claude Code's memory architecture and background memory rewriting system.
Anthropic unintentionally exposed the source code for Claude Code, its AI product, through a public npm package. The leak, which includes sensitive architectural details, poses significant risks for users and gives competitors insights into its technology. Users are advised to take immediate security precautions due to potential vulnerabilities.
- A source map on public npm exposed ~512,000 lines of Claude Code's TypeScript source, discovered by an intern rather than Anthropic itself.
- The leak reveals unreleased internal architecture like "Self-Healing Memory," "Strict Write Discipline," and the always-on "KAIROS" background agent.
- Internal metrics show development problems including a high false claims rate, plus an "Undercover Mode" letting Claude Code contribute to open-source projects without disclosing its identity.
- Users who updated packages around the leak window face added risk from a separate, unrelated malicious attack on the axios package.