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
How Claude Code works in large codebases
Anthropic이 수백만 줄짜리 모노레포, 레거시 시스템, 수십 개 마이크로서비스 환경에서 Claude Code를 운영한 패턴을 정리한 글이다. RAG 방식 대신 에이전틱 검색을 쓰는 이유와 실제 현장의 한계를 함께 확인할 수 있다.
Show HN: Needle: We Distilled Gemini Tool Calling into a 26M Model
Gemini의 함수 호출(tool calling) 능력만 뽑아서 26M(2600만) 파라미터짜리 초경량 모델로 만든 프로젝트로, 폰/워치/스마트글라스 같은 엣지 디바이스에서 직접 실행 가능하다.
Show HN: Agentic interface for mainframes and COBOL
수십 년 된 메인프레임(z/OS) 환경을 AI 에이전트로 조작할 수 있게 해주는 개발 도구로, COBOL 코드 작성부터 JCL 실행, 디버깅까지 자연어로 처리할 수 있어 레거시 시스템 유지보수 비용을 크게 줄일 수 있다.
Show HN: Statewright – Visual state machines that make AI agents reliable
AI 에이전트에게 40개 이상의 도구를 주면 오히려 성능이 떨어지는 문제를 State Machine으로 각 단계별 사용 가능한 도구를 제한해 해결하는 오픈소스 프로젝트다. 더 큰 모델 대신 더 작은 문제 공간을 만들어 신뢰성을 높이는 접근이 핵심이다.
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이 프로세서'라는 아이디어를 네트워크 스택 수준까지 밀어붙인 재미있는 사례다.
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/