📦 Original TypeScript Source - The leaked codebase (512k+ lines, 1,900+ files)
Complete Python Port of Anthropic's Agentic Coding Assistant
Migrated from the leaked TypeScript source
📚 EDUCATIONAL & RESEARCH PURPOSES ONLY - This is a Python port of code accidentally leaked by Anthropic. Original code is proprietary and owned by Anthropic.
| Metric | Value |
|---|---|
| Python modules | 1,805 |
| Lines of code | 149,032 |
| Unit tests | 925 |
| Tools ported | 88 |
| Services | 40+ |
| Commands | 85+ |
✅ Full query engine with tool-use loop · ✅ All 88 agent tools · ✅ Complete service layer · ✅ Working CLI · ✅ Type hints throughout
git clone https://github.com/mimran-khan/claude-code-python.git
cd claude-code-python
python3.11 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
export ANTHROPIC_API_KEY="sk-ant-..."Verify: claude --version && claude doctor
CLI:
claude # Interactive chat
claude -p "Your query" # One-shot query
claude doctor # DiagnosticsPython API:
from claude_code.core.query_engine import QueryEngine, QueryEngineConfig
import asyncio
async def main():
engine = QueryEngine(QueryEngineConfig(cwd="/path/to/project", tools=[], max_tokens=4096))
response = await engine.query("What files are in this directory?")
print(response)
asyncio.run(main())src/claude_code/
├── core/ # Query engine, tool contracts
├── cli/ # Typer-based CLI
├── tools/ # 88 tool implementations
├── services/ # API, MCP, OAuth, compaction
├── commands/ # Slash commands
├── hooks/ # Event system
└── utils/ # 500+ utility modules
| Category | Tools |
|---|---|
| File | Read, Write, Edit, MultiEdit, Glob, Grep, Search |
| Shell | Bash, PowerShell, subprocess |
| Web | WebFetch, WebSearch |
| MCP | Full client, tool discovery, OAuth |
| Agent | AgentTool, TaskTool, sub-agents |
ARCHITECTURE · TOOLS · SERVICES · API · CHANGELOG
pytest # Run tests
pytest --cov=src/claude_code # With coverage
ruff check src tests --fix # Lint
mypy src # Type check📦 TypeScript Source · 🌐 Live Analysis