{"id":47807007,"url":"https://github.com/cablate/claude-code-research","last_synced_at":"2026-04-03T17:46:44.384Z","repository":{"id":347084324,"uuid":"1192787523","full_name":"cablate/claude-code-research","owner":"cablate","description":"Independent research on Claude Code internals, Claude Agent SDK, and related tooling.","archived":false,"fork":false,"pushed_at":"2026-03-27T02:49:48.000Z","size":525,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-27T06:27:05.306Z","etag":null,"topics":["claude-agent-sdk","claude-code","mcp","prompt-caching","research","reverse-engineering","system-prompt","token-optimization"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cablate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-26T15:03:24.000Z","updated_at":"2026-03-27T02:49:52.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/cablate/claude-code-research","commit_stats":null,"previous_names":["cablate/claude-code-research"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/cablate/claude-code-research","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cablate%2Fclaude-code-research","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cablate%2Fclaude-code-research/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cablate%2Fclaude-code-research/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cablate%2Fclaude-code-research/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cablate","download_url":"https://codeload.github.com/cablate/claude-code-research/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cablate%2Fclaude-code-research/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31366557,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T17:13:05.644Z","status":"ssl_error","status_checked_at":"2026-04-03T17:13:04.413Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["claude-agent-sdk","claude-code","mcp","prompt-caching","research","reverse-engineering","system-prompt","token-optimization"],"created_at":"2026-04-03T17:46:43.792Z","updated_at":"2026-04-03T17:46:44.370Z","avatar_url":"https://github.com/cablate.png","language":null,"readme":"# Claude Code Research\n\n[![Contributions Welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg)](./CONTRIBUTING.md)\n\nIndependent research on Claude Code internals.\n\n## What's in this repo\n\n| Directory | What | Source | Count |\n|-----------|------|--------|-------|\n| [`source-code-analysis/`](./source-code-analysis/) | Full architecture reverse-engineering | Leaked TypeScript source (v2.1.88) | **75 reports** |\n| [`reports/`](./reports/) | Problem-oriented investigations (cache, cost, injection) | Minified npm bundle (`cli.js`) | **8 reports** |\n\n\u003e **Looking for the source code analysis?** Go to [`source-code-analysis/`](./source-code-analysis/).\n\u003e **Looking for specific bug/cost investigations?** Go to [`reports/`](./reports/).\n\n---\n\n## Source Code Analysis (`source-code-analysis/`)\n\nOn 2026-03-31, the full source code of Claude Code was exposed via a sourcemap file in the npm registry ([discovered by Chaofan Shou](https://x.com/shoucccc), archived by [Kuberwastaken](https://github.com/Kuberwastaken/claude-code) and [sanbuphy](https://github.com/sanbuphy/claude-code-source-code)).\n\nWe performed a 10-domain, 75-report analysis — the most thorough publicly available breakdown of how a production AI coding agent works.\n\n**[Browse all reports →](./source-code-analysis/)**\n\nInteractive viewer — open `source-code-analysis/index.html` in your browser (all 75 reports are embedded, no server needed).\n\n### Key Findings\n\n| Domain | Reports | Highlights |\n|--------|---------|------------|\n| [Harness Engineering](./source-code-analysis/phase-09-harness-engineering/) ⭐ | 7 | Agent Loop reverse-engineering, 12 transferable harness design principles |\n| [System Prompt](./source-code-analysis/phase-01-system-prompt/) ⭐ | 6 | Complete 13-section prompt with dynamic assembly logic, 17 prompt engineering patterns |\n| [Cost \u0026 Quota](./source-code-analysis/phase-10-cost-quota/) ⭐ | 8 | Cost envelope, prompt cache break detection (12 causes), Haiku→Opus 37.5x cost gap |\n| [Tool Definitions](./source-code-analysis/phase-02-tool-definitions/) | 8 | All 36 tool prompts, read/write concurrency separation, ant vs public prompt variants |\n| [Agent Architecture](./source-code-analysis/phase-03-agent-architecture/) | 7 | 6 built-in agents, Coordinator mode, Swarm multi-agent, 50-message cap (from 36.8GB incident) |\n| [Security](./source-code-analysis/phase-06-security-permissions/) | 8 | 7-layer defense-in-depth, 23 Bash validators, Parser Differential threat model |\n| [Skills System](./source-code-analysis/phase-04-skills-system/) | 5 | 16 bundled skills, 12 design patterns + 5 anti-patterns |\n| [Memory \u0026 Context](./source-code-analysis/phase-05-memory-context/) | 9 | 6 memory subsystems, AutoDream consolidation, Team Memory dual-layer security |\n| [API \u0026 Models](./source-code-analysis/phase-07-api-model-architecture/) | 7 | 17 beta headers, 4 providers, model selection 5-layer priority |\n| [Hidden Features](./source-code-analysis/phase-08-special-features/) | 10 | 82 feature flags, KAIROS proactive mode, Buddy AI pet, UltraPlan, anti-distillation |\n\n---\n\n## Behavioral Reports (`reports/`)\n\nProblem-oriented investigations based on reverse engineering the minified `cli.js` from npm. Each includes English and Chinese versions.\n\n| # | Topic | TL;DR |\n|---|-------|-------|\n| 1 | [Agent SDK Cache Invalidation](./reports/agent-sdk-cache-invalidation/) | SDK `query()` costs 3–10x more than CLI — process-per-call kills prompt cache |\n| 2 | [System-Reminder Injection](./reports/system-reminder-injection/) | 15+ hidden injection types, 4 root-cause bugs |\n| 3 | [Prompt Cache Architecture](./reports/prompt-cache-architecture/) | Static/dynamic zone split, sliding window, byte-prefix matching |\n| 4 | [Tool Serialization \u0026 Cache Stability](./reports/tool-serialization-cache-stability/) | Zero `.sort()` on tools, deferred loading busts cache mid-conversation |\n| 5 | [Context Lifecycle Management](./reports/context-lifecycle-management/) | 5 threshold constants, 10-step compaction flow, chain reactions |\n| 6 | [Production Cache Optimization](./reports/production-cache-optimization/) | 3 concrete cli.js patches + monitoring strategies |\n| 7 | [Cache Invalidation Verification](./reports/cache-invalidation-verification/) | `defer_loading` excludes deferred tools from cache prefix entirely |\n| 8 | [Auto Mode Classifier Cost](./reports/auto-mode-classifier-cost/) | Hidden Opus-level call before every side-effecting tool use |\n\n---\n\n## Resources\n\n- [CLI Reverse Engineering Guide](./research/cli-reverse-engineering-guide.md) — search patterns \u0026 function locators for minified cli.js\n- [Analysis Plan](./source-code-analysis/ANALYSIS-PLAN.md) — methodology for the 10-phase source code analysis\n\n## Source Code Archives\n\nThe analysis is based on the full TypeScript source of Claude Code v2.1.88. The source code itself is not included in this repo.\n\n- [chatgptprojects/claude-code](https://github.com/chatgptprojects/claude-code) — full source code\n- [Kuberwastaken/claude-code](https://github.com/Kuberwastaken/claude-code) — source code breakdown \u0026 analysis\n- [sanbuphy/claude-code-source-code](https://github.com/sanbuphy/claude-code-source-code) — source code archive\n\n## Version Baseline\n\n| Scope | Version |\n|-------|---------|\n| Source Code Analysis | v2.1.88 (sourcemap leak, 2026-03-31) |\n| Behavioral Reports #1–2 | v2.1.71 |\n| Behavioral Reports #3–6 | Agent SDK v0.2.76 (build 2026-03-14) |\n| Behavioral Reports #7–8 | v2.1.85 / v2.1.88 |\n\n## How to Cite\n\n```\nCabLate, \"Claude Code Research,\" GitHub, 2026.\nhttps://github.com/cablate/claude-code-research\n```\n\n## Disclaimer\n\nThis is independent research, **not affiliated with or endorsed by Anthropic**. Behavioral reports analyze publicly distributed npm packages. Source code analysis is based on code exposed through npm registry sourcemaps.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcablate%2Fclaude-code-research","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcablate%2Fclaude-code-research","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcablate%2Fclaude-code-research/lists"}