Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Claude Code (Unofficial Source Extraction)

This is NOT an official Anthropic repository.

This repository contains the extracted TypeScript source code of Anthropic's Claude Code CLI tool. The source was obtained by unpacking the source map (cli.js.map) bundled with the officially published npm package.

Why does this exist?

Anthropic publishes Claude Code as a bundled JavaScript CLI on npm. The published package includes a source map file (cli.js.map) that contains the original TypeScript source. This repository simply extracts and preserves that source for easier reading and reference.

How to get it yourself

Clone this repository

git clone git@github.com:chatgptprojects/claude-code.git
cd claude-code

Or extract it yourself from npm

  1. Install the package:
mkdir claude-code-extract && cd claude-code-extract
npm pack @anthropic-ai/claude-code@2.1.88
tar -xzf anthropic-ai-claude-code-2.1.88.tgz
cd package
  1. Run the unpack script:

Create a file called unpack.mjs:

import { readFileSync, writeFileSync, mkdirSync } from "fs";
import { dirname, join } from "path";

const mapFile = join(import.meta.dirname, "cli.js.map");
const outDir = join(import.meta.dirname, "unpacked");

console.log("Reading source map...");
const map = JSON.parse(readFileSync(mapFile, "utf-8"));

const sources = map.sources || [];
const contents = map.sourcesContent || [];

console.log(`Found ${sources.length} source files.`);

let written = 0;
let skipped = 0;

for (let i = 0; i < sources.length; i++) {
  const src = sources[i];
  const content = contents[i];

  if (content == null) {
    skipped++;
    continue;
  }

  const outPath = join(outDir, src.replace(/^\.\.\//g, ""));
  mkdirSync(dirname(outPath), { recursive: true });
  writeFileSync(outPath, content);
  written++;
}

console.log(`Done! Wrote ${written} files to ${outDir}`);
if (skipped > 0) console.log(`Skipped ${skipped} files with no content.`);
  1. Run it:
node unpack.mjs

The extracted source will be in the unpacked/ directory.

Project Structure

src/
├── cli/           # CLI entrypoint and argument parsing
├── commands/      # Command implementations
├── components/    # UI components (Ink/React)
├── constants/     # App constants and configuration
├── context/       # Context management
├── hooks/         # React hooks
├── ink/           # Terminal UI (Ink framework)
├── services/      # Core services
├── skills/        # Skill definitions
├── tools/         # Tool implementations (file editing, search, etc.)
├── types/         # TypeScript type definitions
├── utils/         # Utility functions
├── main.tsx       # Main application entry
├── query.ts       # Query handling
└── ...

The Leak (March 31, 2026)

Anthropic accidentally shipped a .map source map file with the Claude Code npm package (@anthropic-ai/claude-code@2.1.88), exposing the complete, readable TypeScript source (~1,884 files, 512K+ lines of code). Security researcher Chaofan Shou discovered the vulnerability, which pointed to an unobfuscated source archive on Anthropic's Cloudflare R2 bucket.

Anthropic's response: "This was a release packaging issue caused by human error, not a security breach." The root cause was a misconfigured .npmignore or files field in package.json that failed to exclude the source map from the published package.

This was Anthropic's second accidental exposure in one week, following the "Mythos" model spec leak days earlier.

The source was quickly mirrored across GitHub, with repositories accumulating over 41,500 forks.

Key Technical Findings

Finding Description
Anti-Distillation ANTI_DISTILLATION_CC flag injects fake/decoy tool definitions into API requests to poison training data from anyone recording API traffic. Bypassed via MITM proxies or environment variable manipulation.
Undercover Mode Strips internal codenames ("Capybara", "Tengu") when used in non-Anthropic repos. No force-off switch. Enables AI-authored commits to appear human-written.
Frustration Detection Regex-based profanity detection — notably using simple pattern matching rather than semantic analysis.
Client Attestation / DRM Bun's native HTTP layer (written in Zig) injects cryptographic hashes below the JavaScript runtime, functioning as DRM for API calls to prevent third-party tool access.
KAIROS Unreleased autonomous agent mode with background daemons, GitHub webhooks, and nightly memory distillation.
44 Feature Flags Fully-built but unshipped features revealing product roadmap.

Coverage

Disclaimer

All code in this repository is the intellectual property of Anthropic. This repository is provided for educational and reference purposes only. Please refer to Anthropic's license terms for usage restrictions.

This is not affiliated with, endorsed by, or supported by Anthropic.

About

Mirror of Claude Code source leaked via npm source map (March 31, 2026)

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages