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
Migrating a production AI agent to GPT-5.6: 2.2x faster, 27% cheaper
마케팅 웹사이트를 자동 생성하는 프로덕션 AI 에이전트를 Claude Opus 4.8에서 GPT-5.6 Sol로 전환한 실전 경험담으로, 단순 모델 교체가 아니라 eval 하네스, 툴 스키마, 캐싱, 추론 리플레이까지 손봐야 했던 과정을 구체적인 수치와 함께 정리했다.
What xAI's Grok build CLI sends to xAI: A wire-level analysis
xAI의 공식 코딩 CLI 도구 Grok Build가 사용자 동의 없이 전체 Git 저장소와 .env 시크릿 파일을 xAI 서버로 업로드한다는 사실이 네트워크 트래픽 분석으로 밝혀졌다.
Remember When It Matters: Proactive Memory Agent for Long-Horizon Agents
LLM 에이전트가 긴 작업 중 중요한 정보를 잊어버리는 문제를 별도의 메모리 에이전트가 '적절한 타이밍에' 끼어들어 해결하는 방법
WebSwarm: Recursive Multi-Agent Orchestration for Deep-and-Wide Web Search
복잡한 웹 검색을 재귀적으로 분해하고 각 노드에 적합한 검색 모드를 동적으로 할당하는 멀티에이전트 프레임워크
Show HN: Reverse-engineering web apps into agent tools
로그인된 웹 앱의 API 호출을 브라우저에서 감시해 자동으로 MCP 도구로 변환하는 에이전트를 만들었다. 소스 코드나 공식 API 문서 없이도 Jira, Spotify 같은 서비스에 AI 어시스턴트를 붙일 수 있다.
Show HN: FableCut – A browser video editor AI agents can drive (zero deps)
타임라인 전체를 JSON 파일 하나로 표현하고 MCP/REST로 AI 에이전트가 직접 편집할 수 있는 브라우저 비디오 에디터로, Claude 같은 AI가 프롬프트 하나로 영상을 자동 컷편집하고 결과를 실시간으로 UI에 반영해준다.
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/