{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreiheg6ezalowdxpqxgrxgnyoospufuotaix6dzazq2du2jo2frr7pq",
"uri": "at://did:plc:pgryn3ephfd2xgft23qokfzt/app.bsky.feed.post/3mieqshewojs2"
},
"path": "/t/claude-code-source-leak-production-ai-architecture-patterns-from-512-000-lines/174846#post_1",
"publishedAt": "2026-03-31T13:19:21.000Z",
"site": "https://discuss.huggingface.co",
"tags": [
"https://github.com/instructkr/claude-code",
"https://x.com/Fried_rice/status/2038894956459290963"
],
"textContent": "On March 31, 2026, Claude Code’s entire source code was exposed via npm source map. This analyzes what the codebase reveals about production AI architecture patterns.\n\n## **Technical Root Cause**\n\nSingle `.map` file in production npm package → R2 bucket URL → complete TypeScript source download. Textbook supply chain security failure.\n\n## **What Was Exposed**\n\n**Scale:** 1,900 files, 512,000+ lines, TypeScript + Bun + React/Ink\n\n**Core files:**\n\n * `QueryEngine.ts` (46K lines): LLM API engine, streaming, tool loops\n\n * `Tool.ts` (29K lines): Agent tools, permission schemas\n\n * `commands.ts` (25K lines): Slash commands\n\n\n\n\n**~40 tools, ~85 commands, feature flags, unreleased BUDDY digital pet system**\n\n## **4 Production AI Architecture Patterns**\n\n### **1. System Prompt Engineering**\n\n * Tool constraints, risk controls, output specs\n\n * Makes AI predictable, controllable, production-ready\n\n\n\n\n### **2. Multi-Agent Orchestration**\n\n * Coordinator-worker architecture\n\n * Permission mailbox pattern\n\n * Atomic claim mechanism\n\n * Team memory\n\n\n\n\n### **3. Three-Layer Context Compression**\n\n * **MicroCompact** : Local cleanup\n\n * **AutoCompact** : Near-limit summarization (13K buffer, 20K summary, circuit breaker)\n\n * **Full Compact** : Emergency compression + selective re-injection (50K budget)\n\n\n\n\n### **4. AutoDream Memory Consolidation**\n\nBackground process with 4 phases: Orient → Gather → Consolidate → Prune\n\n**Trigger conditions:** ≥24h, ≥5 sessions, no other consolidation, ≥10min since scan\n\n* * *\n\n**For AI researchers/engineers, this is a free case study in production AI architecture.** Anthropic’s patterns, refined at scale, are now available for analysis.\n\n**Links:**\n\n * Mirror: https://github.com/instructkr/claude-code\n\n * Tweet: https://x.com/Fried_rice/status/2038894956459290963\n\n\n",
"title": "Claude Code Source Leak: Production AI Architecture Patterns from 512,000 Lines"
}