Skip to content
Back to search

claude-code

An independent Python feature port of Claude Code, entirely rewritting from scratch using oh-my-codex. Educational Purpose only.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/tinkeringg-lab--claude-code/badge.svg)](/listings/tinkeringg-lab--claude-code)

HTML

<a href="/listings/tinkeringg-lab--claude-code"><img src="/api/listings/tinkeringg-lab--claude-code/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 257 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # Claude Code — Leaked Source (2026-03-31)
  2. > **On March 31, 2026, the full source code of Anthropic's Claude Code CLI was leaked** via a `.map` file exposed in their npm registry.
  3. ---
  4. ## How It Leaked
  5. [Chaofan Shou (@Fried_rice)](https://x.com/Fried_rice) discovered the leak and posted it publicly:
  6. > **"Claude code source code has been leaked via a map file in their npm registry!"**
  7. >
  8. > — [@Fried_rice, March 31, 2026](https://x.com/Fried_rice/status/2038894956459290963)
  9. The source map file in the published npm package contained a reference to the full, unobfuscated TypeScript source, which was downloadable as a zip archive from Anthropic's R2 storage bucket.
  10. ---
  11. ## Overview
  12. Claude Code is Anthropic's official CLI tool that lets you interact with Claude directly from the terminal to perform software engineering tasks — editing files, running commands, searching codebases, managing git workflows, and more.
  13. This repository contains the leaked `src/` directory.
  14. - **Leaked on**: 2026-03-31
  15. - **Language**: TypeScript
  16. - **Runtime**: Bun
  17. - **Terminal UI**: React + [Ink](https://github.com/vadimdemedes/ink) (React for CLI)
  18. - **Scale**: ~1,900 files, 512,000+ lines of code
  19. ---
  20. ## Directory Structure
  21. ```
  22. src/
  23. ├── main.tsx # Entrypoint (Commander.js-based CLI parser)
  24. ├── commands.ts # Command registry
  25. ├── tools.ts # Tool registry
  26. ├── Tool.ts # Tool type definitions
  27. ├── QueryEngine.ts # LLM query engine (core Anthropic API caller)
  28. ├── context.ts # System/user context collection
  29. ├── cost-tracker.ts # Token cost tracking
  30. │
  31. ├── commands/ # Slash command implementations (~50)
  32. ├── tools/ # Agent tool implementations (~40)
  33. ├── components/ # Ink UI components (~140)
  34. ├── hooks/ # React hooks
  35. ├── services/ # External service integrations
  36. ├── screens/ # Full-screen UIs (Doctor, REPL, Resume)
  37. ├── types/ # TypeScript type definitions
  38. ├── utils/ # Utility functions
  39. │
  40. ├── bridge/ # IDE integration bridge (VS Code, JetBrains)
  41. ├── coordinator/ # Multi-agent coordinator
  42. ├── plugins/ # Plugin system
  43. ├── skills/ # Skill system
  44. ├── keybindings/ # Keybinding configuration
  45. ├── vim/ # Vim mode
  46. ├── voice/ # Voice input
  47. ├── remote/ # Remote sessions
  48. ├── server/ # Server mode
  49. ├── memdir/ # Memory directory (persistent memory)
  50. ├── tasks/ # Task management
  51. ├── state/ # State management
  52. ├── migrations/ # Config migrations
  53. ├── schemas/ # Config schemas (Zod)
  54. ├── entrypoints/ # Initialization logic
  55. ├── ink/ # Ink renderer wrapper
  56. ├── buddy/ # Companion sprite (Easter egg)
  57. ├── native-ts/ # Native TypeScript utils
  58. ├── outputStyles/ # Output styling
  59. ├── query/ # Query pipeline
  60. └── upstreamproxy/ # Proxy configuration
  61. ```
  62. ---
  63. ## Core Architecture
  64. ### 1. Tool System (`src/tools/`)
  65. Every tool Claude Code can invoke is implemented as a self-contained module. Each tool defines its input schema, permission model, and execution logic.
  66. | Tool | Description |
  67. |---|---|
  68. | `BashTool` | Shell command execution |
  69. | `FileReadTool` | File reading (images, PDFs, notebooks) |
  70. | `FileWriteTool` | File creation / overwrite |
  71. | `FileEditTool` | Partial file modification (string replacement) |
  72. | `GlobTool` | File pattern matching search |
  73. | `GrepTool` | ripgrep-based content search |
  74. | `WebFetchTool` | Fetch URL content |
  75. | `WebSearchTool` | Web search |
  76. | `AgentTool` | Sub-agent spawning |
  77. | `SkillTool` | Skill execution |
  78. | `MCPTool` | MCP server tool invocation |
  79. | `LSPTool` | Language Server Protocol integration |
  80. | `NotebookEditTool` | Jupyter notebook editing |
  81. | `TaskCreateTool` / `TaskUpdateTool` | Task creation and management |
  82. | `SendMessageTool` | Inter-agent messaging |
  83. | `TeamCreateTool` / `TeamDeleteTool` | Team agent management |
  84. | `EnterPlanModeTool` / `ExitPlanModeTool` | Plan mode toggle |
  85. | `EnterWorktreeTool` / `ExitWorktreeTool` | Git worktree isolation |
  86. | `ToolSearchTool` | Deferred tool discovery |
  87. | `CronCreateTool` | Scheduled trigger creation |
  88. | `RemoteTriggerTool` | Remote trigger |
  89. | `SleepTool` | Proactive mode wait |
  90. | `SyntheticOutputTool` | Structured output generation |
  91. ### 2. Command System (`src/commands/`)
  92. User-facing slash commands invoked with `/` prefix.
  93. | Command | Description |
  94. |---|---|
  95. | `/commit` | Create a git commit |
  96. | `/review` | Code review |
  97. | `/compact` | Context compression |
  98. | `/mcp` | MCP server management |
  99. | `/config` | Settings management |
  100. | `/doctor` | Environment diagnostics |
  101. | `/login` / `/logout` | Authentication |
  102. | `/memory` | Persistent memory management |
  103. | `/skills` | Skill management |
  104. | `/tasks` | Task management |
  105. | `/vim` | Vim mode toggle |
  106. | `/diff` | View changes |
  107. | `/cost` | Check usage cost |
  108. | `/theme` | Change theme |
  109. | `/context` | Context visualization |
  110. | `/pr_comments` | View PR comments |
  111. | `/resume` | Restore previous session |
  112. | `/share` | Share session |
  113. | `/desktop` | Desktop app handoff |
  114. | `/mobile` | Mobile app handoff |
  115. ### 3. Service Layer (`src/services/`)
  116. | Service | Description |
  117. |---|---|
  118. | `api/` | Anthropic API client, file API, bootstrap |
  119. | `mcp/` | Model Context Protocol server connection and management |
  120. | `oauth/` | OAuth 2.0 authentication flow |
  121. | `lsp/` | Language Server Protocol manager |
  122. | `analytics/` | GrowthBook-based feature flags and analytics |
  123. | `plugins/` | Plugin loader |
  124. | `compact/` | Conversation context compression |
  125. | `policyLimits/` | Organization policy limits |
  126. | `remoteManagedSettings/` | Remote managed settings |
  127. | `extractMemories/` | Automatic memory extraction |
  128. | `tokenEstimation.ts` | Token count estimation |
  129. | `teamMemorySync/` | Team memory synchronization |
  130. ### 4. Bridge System (`src/bridge/`)
  131. A bidirectional communication layer connecting IDE extensions (VS Code, JetBrains) with the Claude Code CLI.
  132. - `bridgeMain.ts` — Bridge main loop
  133. - `bridgeMessaging.ts` — Message protocol
  134. - `bridgePermissionCallbacks.ts` — Permission callbacks
  135. - `replBridge.ts` — REPL session bridge
  136. - `jwtUtils.ts` — JWT-based authentication
  137. - `sessionRunner.ts` — Session execution management
  138. ### 5. Permission System (`src/hooks/toolPermission/`)
  139. Checks permissions on every tool invocation. Either prompts the user for approval/denial or automatically resolves based on the configured permission mode (`default`, `plan`, `bypassPermissions`, `auto`, etc.).
  140. ### 6. Feature Flags
  141. Dead code elimination via Bun's `bun:bundle` feature flags:
  142. ```typescript
  143. import { feature } from 'bun:bundle'
  144. // Inactive code is completely stripped at build time
  145. const voiceCommand = feature('VOICE_MODE')
  146. ? require('./commands/voice/index.js').default
  147. : null
  148. ```
  149. Notable flags: `PROACTIVE`, `KAIROS`, `BRIDGE_MODE`, `DAEMON`, `VOICE_MODE`, `AGENT_TRIGGERS`, `MONITOR_TOOL`
  150. ---
  151. ## Key Files in Detail
  152. ### `QueryEngine.ts` (~46K lines)
  153. The core engine for LLM API calls. Handles streaming responses, tool-call loops, thinking mode, retry logic, and token counting.
  154. ### `Tool.ts` (~29K lines)
  155. Defines base types and interfaces for all tools — input schemas, permission models, and progress state types.
  156. ### `commands.ts` (~25K lines)
  157. Manages registration and execution of all slash commands. Uses conditional imports to load different command sets per environment.
  158. ### `main.tsx`
  159. Commander.js-based CLI parser + React/Ink renderer initialization. At startup, parallelizes MDM settings, keychain prefetch, and GrowthBook initialization for faster boot.
  160. ---
  161. ## Tech Stack
  162. | Category | Technology |
  163. |---|---|
  164. | Runtime | [Bun](https://bun.sh) |
  165. | Language | TypeScript (strict) |
  166. | Terminal UI | [React](https://react.dev) + [Ink](https://github.com/vadimdemedes/ink) |
  167. | CLI Parsing | [Commander.js](https://github.com/tj/commander.js) (extra-typings) |
  168. | Schema Validation | [Zod v4](https://zod.dev) |
  169. | Code Search | [ripgrep](https://github.com/BurntSushi/ripgrep) (via GrepTool) |
  170. | Protocols | [MCP SDK](https://modelcontextprotocol.io), LSP |
  171. | API | [Anthropic SDK](https://docs.anthropic.com) |
  172. | Telemetry | OpenTelemetry + gRPC |
  173. | Feature Flags | GrowthBook |
  174. | Auth | OAuth 2.0, JWT, macOS Keychain |
  175. ---
  176. ## Notable Design Patterns
  177. ### Parallel Prefetch
  178. Startup time is optimized by prefetching MDM settings, keychain reads, and API preconnect in parallel — before heavy module evaluation begins.
  179. ```typescript
  180. // main.tsx — fired as side-effects before other imports
  181. startMdmRawRead()
  182. startKeychainPrefetch()
  183. ```
  184. ### Lazy Loading
  185. Heavy modules (OpenTelemetry ~400KB, gRPC ~700KB) are deferred via dynamic `import()` until actually needed.
  186. ### Agent Swarms
  187. Sub-agents are spawned via `AgentTool`, with `coordinator/` handling multi-agent orchestration. `TeamCreateTool` enables team-level parallel work.
  188. ### Skill System
  189. Reusable workflows defined in `skills/` and executed through `SkillTool`. Users can add custom skills.
  190. ### Plugin Architecture
  191. Built-in and third-party plugins are loaded through the `plugins/` subsystem.
  192. ---
  193. ## Disclaimer
  194. This repository archives source code that was leaked from Anthropic's npm registry on **2026-03-31**. All original source code is the property of [Anthropic](https://www.anthropic.com).

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.