Skip to content

About

Python implementation of Claude Code - AI coding assistant powered by Claude

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

88 Commits

Folders and files

Repository files navigation

📦 Original TypeScript Source - The leaked codebase (512k+ lines, 1,900+ files)


Claude Code Python

Claude Code Python

Complete Python Port of Anthropic's Agentic Coding Assistant

Migrated from the leaked TypeScript source

Stars Forks Watchers Views

Python Tests Lines License

Installation · Usage · Architecture · Documentation


⚠️ DISCLAIMER

📚 EDUCATIONAL & RESEARCH PURPOSES ONLY - This is a Python port of code accidentally leaked by Anthropic. Original code is proprietary and owned by Anthropic.


🚀 The Migration

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


📦 Installation

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


💻 Usage

CLI:

claude                    # Interactive chat
claude -p "Your query"    # One-shot query
claude doctor             # Diagnostics

Python 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())

🏗️ Architecture

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

🛠️ Tools

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

📚 Documentation

ARCHITECTURE · TOOLS · SERVICES · API · CHANGELOG


🧪 Development

pytest                              # Run tests
pytest --cov=src/claude_code        # With coverage
ruff check src tests --fix          # Lint
mypy src                            # Type check

🔗 Related

📦 TypeScript Source · 🌐 Live Analysis


Repo Size Last Commit

📚 For Educational Purposes Only · Not affiliated with Anthropic

About

Python implementation of Claude Code - AI coding assistant powered by Claude

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages