Claude Code's source code has been leaked via a map file in their NPM registry
TL;DR Highlight
The source code of Anthropic's AI coding tool Claude Code was publicly exposed through source map files included in its NPM package, revealing an undisclosed feature roadmap and internal security mechanisms.
Who Should Read
Developers who publish or maintain NPM packages, as well as developers interested in the internal architecture of AI coding agents or Anthropic's product strategy.
Core Mechanics
- Source map (.map) files were distributed alongside the bundled JavaScript in Claude Code's NPM package (@anthropic-ai/claude-code), exposing the original TypeScript source code as-is. Source maps are intended for debugging—allowing minified JS to be traced back to original code—but including them in a production package was the root of the problem.
- Anthropic eventually took action on the affected version (v2.x), but used npm deprecate (marking it as 'deprecated' without deletion) instead of npm unpublish (which actually removes the version), leaving the package still downloadable. Commenters sarcastically noted it felt like 'asking Claude to unpublish it, and getting a deprecate instead.'
- Numerous feature flags for undisclosed features were found in the source code. The most notable were: an 'assistant mode' codenamed 'kairos', a Tamagotchi-style ASCII art virtual pet system called the 'Buddy System (/buddy)', and an 'Undercover mode' that strips internal information from commits/PRs when Anthropic employees contribute to open source.
- An internal flag called ANTI_DISTILLATION_CC was also uncovered. When enabled, it injects anti_distillation: ['fake_tools'] into every API request, causing the server to secretly insert fake tool definitions into the system prompt. This is a data poisoning defense mechanism designed to disrupt competitors attempting to scrape Claude Code's API traffic to train their own models (distillation).
- Regex patterns that detect negative sentiment or specific keywords in user prompts were also found, with the code explicitly noting that such content is logged. This effectively exposed which expressions are being monitored by the system.
- There were also notable issues with code quality. A single function in src/cli/print.ts was found to be 3,167 lines long, with up to 12 levels of nesting, a cyclomatic complexity of approximately 486, 12 parameters plus an options object with 16 properties, 21 inner functions, and sole responsibility for the agent loop, SIGINT handling, AWS authentication, MCP lifecycle, and more. Commenters noted it 'should be split into at least 8–10 modules.'
Evidence
- "Regarding the npm deprecate vs. unpublish mistake, one commenter accurately explained the difference: 'npm deprecate does not remove the package from the registry—it only marks it as deprecated while keeping it fully downloadable. npm unpublish should have been used to actually remove it.' They added that Anthropic's use of the wrong command gave the impression that Claude had misunderstood the task. There was also debate over the severity of the leak: some argued that since TypeScript/JS is not machine code and obfuscated code is already somewhat reversible, leaking a CLI tool's code is not a big deal—they suggested open-sourcing it instead. Others countered that what Google or OpenAI have released is an Agent SDK toolkit, not code revealing how their flagship agent works internally, making this leak—which exposed the roadmap and internal architecture—categorically different. The undisclosed /buddy feature received detailed analysis: a commenter reverse-engineered the code and found it was planned as an April Fools' Day easter egg, with 18 species, rarity levels, stats, hats, and eye shapes generated deterministically using the user's account UUID as a seed. They even built and shared a website (claudebuddychecker.netlify.app) to preview one's buddy in advance. The ANTI_DISTILLATION feature drew significant attention from multiple commenters. The fact that AI companies are already implementing this kind of defense mechanism—secretly injecting fake tool definitions into API responses to corrupt competitors' training data—in commercial products was widely noted as remarkable in itself. Legal concerns were also raised: some asked whether using AI to analyze the leaked code and reimplement similar systems would be legally permissible, with cautious responses suggesting it may be safer to treat it like 'tainted goods.' Others were more dismissive, questioning whether there was any moral issue given that AI models have already been trained on billions of lines of open-source code."
How to Apply
- "If you distribute NPM packages, always verify that source map files are not included in the production bundle. In Webpack, set the devtool option to 'hidden-source-map', or add *.map to your .npmignore file to prevent internal logic from being reverse-engineered. When you urgently need to take down a package version, use npm unpublish [package-name]@[version]—not npm deprecate—to actually remove it from the registry. Since npm deprecate only leaves a marker while keeping the files downloadable, it's worth proactively sharing the difference between these two commands within your team to avoid confusion during security incident response. If you have undisclosed features managed via feature flags, be aware that flag names and feature identifiers can be exposed as-is in the distributed code. Consider separating sensitive roadmap information from the codebase, or managing it server-side only so it is never included in the client bundle. If your application logs user input, having the logging conditions and patterns visible in client-side code can erode user trust. Consider documenting your logging policy in public documentation or a privacy policy, and evaluate moving detection patterns to the server side so they are not exposed externally."
Terminology
Related Papers
Show HN: adamsreview – better multi-agent PR reviews for Claude Code
Claude Code에서 최대 7개의 병렬 서브 에이전트가 각각 다른 관점으로 PR을 리뷰하고, 자동 수정까지 해주는 오픈소스 플러그인이다. 기존 /review나 CodeRabbit보다 실제 버그를 더 많이 잡는다고 주장하지만 커뮤니티에서는 복잡도와 실효성에 대한 회의론도 나왔다.
How Fast Does Claude, Acting as a User Space IP Stack, Respond to Pings?
Claude Code에게 IP 패킷을 직접 파싱하고 ICMP echo reply를 구성하도록 시켜서 실제로 ping에 응답하게 만든 실험으로, 'Markdown이 곧 코드이고 LLM이 프로세서'라는 아이디어를 네트워크 스택 수준까지 밀어붙인 재미있는 사례다.
Show HN: Git for AI Agents
AI 코딩 에이전트(Claude Code 등)가 수행한 모든 툴 호출을 자동으로 추적하고, 어떤 프롬프트가 어느 코드 줄을 작성했는지 blame까지 가능한 버전 관리 도구다.
Principles for agent-native CLIs
AI 에이전트가 CLI 도구를 더 잘 사용할 수 있도록 설계하는 원칙들을 정리한 글로, 에이전트가 CLI를 도구로 활용하는 빈도가 높아지면서 이 설계 방식이 실용적으로 중요해지고 있다.
Agent-harness-kit scaffolding for multi-agent workflows (MCP, provider-agnostic)
여러 AI 에이전트가 서로 역할을 나눠 협업할 수 있도록 조율하는 scaffolding 도구로, Vite처럼 설정 없이 빠르게 멀티 에이전트 파이프라인을 구성할 수 있다.
Show HN: Tilde.run – Agent sandbox with a transactional, versioned filesystem
AI 에이전트가 실제 프로덕션 데이터를 건드려도 롤백할 수 있는 격리된 샌드박스 환경을 제공하는 도구로, GitHub/S3/Google Drive를 하나의 버전 관리 파일시스템으로 묶어준다.
Related Resources
- https://twitter.com/Fried_rice/status/2038894956459290963
- https://www.npmjs.com/package/@anthropic-ai/claude-code/v/2
- https://github.com/chatgptprojects/claude-code
- https://github.com/instructkr/claude-code/blob/main/src/constants.ts
- https://daveschumaker.net/digging-into-the-claude-code-source-code/
- https://news.ycombinator.com/item?id=43173324
- https://claudebuddychecker.netlify.app/
- https://malus.sh/