English | δΈζ | FranΓ§ais | Π ΡΡΡΠΊΠΈΠΉ | ΰ€Ήΰ€Ώΰ€¨ΰ₯ΰ€¦ΰ₯ | Ψ§ΩΨΉΨ±Ψ¨ΩΨ© | PortuguΓͺs
A production-oriented Python rebuild of Claude Code β real architecture, reliable CLI agent
Ported from the TypeScript reference implementation and extended with a Python-native runtime
π₯ Active Development β’ New Features Weekly π₯
git clone https://github.com/agentforce314/clawcodex.git
cd clawcodex
python3 -m venv .venv && source .venv/bin/activate # Python 3.10+
pip install -r requirements.txt
python -m src.cli login # writes config to ~/.clawcodex/config.json
python -m src.cli # start the REPL- 2026-05-14: Codebase stats β Total Python files: 837 files; Total Lines of Python Code: 167,034 lines.
- 2026-05-14: ESC cancellation latency fix (#130) β pressing ESC now cancels in-flight Bash commands and streaming responses within ~50ms, on top of the diff color-bar full-width render fix (#129) and the bypass-permissions outside-paths fix (#128).
- 2026-05-12: Bootstrap + architecture docs β new architecture overview at
docs/ARCHITECTURE.md; production bootstrap port (memoizedinit(), trust boundary, unifiedlaunch_repl(args),--barefast path, schema migration runner); main query loop and agent loop routed throughdispatch_fullwith deferred tool loading. - 2026-05-11 (v0.5.0): ClawCodex v0.5.0 released β rebrand to ClawCodex across user-visible UI; reactive state subsystem ported (signals, store, session context, cost tracker, 1h cache eligibility); API layer hardened (output-token cap, request-id injection, message-level cache breakpoints, Haiku fast path, watchdog + non-streaming fallback, retry-with-stream); agent loop foundation (typed terminal, media recovery, blocking-limit guards, token budget, stop hooks, model fallback, continuation nudge); refreshed README screenshot.
- 2026-05-10: MCP subsystem landed β full Model Context Protocol support with OAuth wiring, HTTPS, XSS hardening, and async I/O; passed a multi-pass security review.
- 2026-05-10: Performance pass β startup profiler, prompt-cache plumbing with sticky latches, bitmap + async search indexing with score-bound pruning, cold-start latency reduction, streaming hardening.
- 2026-05-10: CCR remote bridge (phases 0β5) β Direct Connect via
cc://andcc+unix://, Bridge v2 transport, Remote Session viewer, CCR upstream proxy. - 2026-05-10: Standalone REPL modules β vim mode, transcript search, IME cursor, terminal hyperlinks, frame metrics, thinking widget, per-tool permission specialization, output-styles frontmatter; REPL transcript readability and ANSI diff backgrounds.
- 2026-05-08: Hooks system β snapshot-based executor with workspace-trust gate, expanded event/source taxonomy, schema validation, environment injection.
- 2026-05-08: Multi-agent coordination β typed task state machine, JSONL transcript writer, agent task lifecycle, progress tracker, task-notification routing,
SendMessagepeer DMs, swarm primitives, background resume, coordinator mode + worker agents, permission forwarding bridge; full test suite green onmain. - 2026-05-07: Auto-memory + concurrency β ported the persistent auto-memory subsystem (user / feedback / project / reference types); concurrency-orchestrator and tool-execution parity with the TypeScript reference; permission-system gaps closed.
- 2026-05-06: Subagent parity β fork-subagent path ported; subagent async lifecycle aligned with TypeScript reference.
- 2026-05-05: Docs polish β added Quick Install section under header; documented the config path written by
clawcodex login. - 2026-04-30: Skills subsystem parity β Skills (project + user, named args, tool limits) brought to parity with the TypeScript reference.
- 2026-04-29: REPL spinner UX β show elapsed time and token count in the REPL spinner row.
- 2026-04-27: New demo β Adopt Me-style pet game (React + Vite + Vitest), generated end-to-end by ClawCodex.
- 2026-04-26: Reliability fix β DeepSeek thinking-mode replay failures and noisy permission prompts resolved.
- 2026-04-25: DeepSeek support β direct DeepSeek provider (V4 Pro / Flash via
api.deepseek.com) plus OpenRouter route. - 2026-04-25: API validation fix β
AskUserQuestionoptions schema fixed for API validation. - 2026-04-23: Generated demos β CRM, LinkedIn, and Minecraft demo apps (all generated by ClawCodex itself) and a Demos section in the README.
- 2026-04-21: Permissions wiring β
--dangerously-skip-permissionswired through every entrypoint (REPL, TUI,-p). - 2026-04-20: Initial public release β first commit with project source, docs, tests, and build config.
ClawCodex is a production-oriented Python rebuild of Claude Code, ported from the real TypeScript architecture and shipped as a working CLI agent, not just a source dump.
- Real Agent Runtime β tool-calling loop, streaming REPL, session history, and multi-turn execution
- High-Fidelity Port β keeps the original Claude Code architecture while adapting it to idiomatic Python
- Built to Hack On β readable Python codebase, rich tests, and markdown-driven skill extensibility
- Multi-LLM providers β the biggest step forward vs. upstream: Claude Code is built around Claude-series models only; ClawCodex is dedicated to wiring in all major LLM providers so you can choose the most flexible and cost-effective stack for agentic coding
A real Claude Code-style terminal workflow in Python: stream replies, call tools, fetch context, and extend behavior with skills.
π Try it now! Fork it, modify it, make it yours! Pull requests welcome!
View star history on star-history.com
>>> /stream on
>>> Explain tests/test_agent_loop.py
[streaming answer...]
β’ Read (tests/test_agent_loop.py) running...
β³ lines 1-180
>>> /render-last
- True API streaming for direct replies plus richer streaming during tool-driven agent loops
- Built-in
/streamtoggle for live output and/render-lastfor clean Markdown re-rendering on demand - Designed for real terminal demos: streaming text, visible tool activity, and stable fallback behavior
---
description: Explain code with diagrams and analogies
allowed-tools:
- Read
- Grep
- Glob
arguments: [path]
---
Explain the code in $path. Start with an analogy, then draw a diagram.- Markdown-based
SKILL.mdslash commands - Supports project skills, user skills, named arguments, and tool limits
ClawCodexβs main advantage is multi-provider support: while Claude Code targets Claude models, we aim to support every major LLM provider behind the same agent runtimeβso you can swap vendors, regions, and price tiers without giving up tools, skills, or the coding loop. That flexibility is what makes agentic coding practical at scale.
providers = ["anthropic", "openai", "glm", "minimax", "openrouter", "deepseek"] # OpenAI-compatible & GLM APIs; more can be addedThe default interactive UI is the inline prompt_toolkit + Rich REPL (transcript in scrollback, tool-aware status row). Use clawcodex --tui or the /tui slash command inside the REPL to launch the Textual in-app experience when you want it.
>>> Hello!
Assistant: Hi! I'm ClawCodex, a Python reimplementation...
>>> /help # Show commands
>>> /tools # List registered tools
>>> /tui # Hand off to the Textual TUI
>>> /stream on # Live response rendering
>>> /save # Save session
>>> Tab # Auto-complete
>>> /explain-code qsort.py # Run a SKILL.md skill (or /skill β¦)
# Multi-line input: Shift+Enter, Meta/Alt+Enter, or `\` then Enter for newline; plain Enter submits.
clawcodex # Inline REPL (default)
clawcodex --tui # Textual TUI
clawcodex --stream # REPL with live rendering
clawcodex login # Configure API keys (interactive)
clawcodex config # Show ~/.clawcodex/config.json-backed settings
clawcodex --version # Version string
# Non-interactive / scripting (pipes, CI, agents)
clawcodex -p "Summarize src/cli.py"
clawcodex -p "Hello" --output-format json
clawcodex -p --output-format stream-json --input-format stream-json < events.ndjson
# Overrides for a single run
clawcodex --provider anthropic --model claude-sonnet-4-6 -p "Hi"
clawcodex --max-turns 10 --allowed-tools Read,Grep -p "Find TODOs"
# Permission control (REPL, TUI, and -p all honor these)
clawcodex --permission-mode plan # plan / acceptEdits / dontAsk
clawcodex --dangerously-skip-permissions -p "ls" # bypass all permission checks
clawcodex --allow-dangerously-skip-permissions # allow /permission-mode bypass later
--dangerously-skip-permissionsdisables every tool permission check for the session. Recommended only inside sandboxed containers/VMs with no internet access. The flag is refused when the process is running as root/sudo unlessIS_SANDBOX=1orCLAUDE_CODE_BUBBLEWRAP=1is set.
| Component | Status | Count |
|---|---|---|
| REPL Commands | β Complete | Built-ins + /tools, /stream, /context, /compact, skills, etc. |
| Tool System | β Complete | 30+ tools |
| Automated Tests | β Present | Tools, agent loop, providers, parity, REPL, auth, and more |
| Documentation | β Complete | Guides, i18n READMEs, FEATURE_LIST.md |
| System | Status | Description |
|---|---|---|
| CLI Entry | β | clawcodex, login, config, -p / --print, --tui, --stream, --version |
| Interactive REPL | β | Default inline REPL; optional Textual TUI; history, tab completion, multiline |
| Multi-Provider | β | Anthropic, OpenAI, Zhipu GLM, Minimax, OpenRouter, DeepSeek |
| Session Persistence | β | Save/load sessions locally |
| Agent Loop | β | Tool calling loop with streaming and headless mode |
| Skill System | β | SKILL.md-based slash-command skills with args + tool limits |
| Context Building | π‘ | Workspace / git / CLAUDE.md injection; richer summaries and memory still evolving |
| Permission System | π‘ | Framework and checks; full integration still in progress |
| MCP | π‘ | MCP-oriented tools and wiring; full protocol/runtime polish ongoing |
| Category | Tools | Status |
|---|---|---|
| File Operations | Read, Write, Edit, Glob, Grep | β Complete |
| System | Bash execution | β Complete |
| Web | WebFetch, WebSearch | β Complete |
| Interaction | AskUserQuestion, SendMessage | β Complete |
| Task Management | TodoWrite, TaskManager, TaskStop | β Complete |
| Agent Tools | Agent, Brief, Team | β Complete |
| Configuration | Config, PlanMode, Cron | β Complete |
| MCP | MCP tools and resources | π‘ Tools wired; full client/runtime still evolving |
| Others | LSP, Worktree, Skill, ToolSearch | β Complete |
- β Phase 0: Installable, runnable CLI
- β Phase 1: Core Claude Code MVP experience
- β Phase 2: Real tool calling loop
- π‘ Phase 3: Context depth, permission integration,
/resume-class recovery (in progress) - π‘ Phase 4: MCP runtime depth, plugins, extensibility (tools exist; platform work continues)
- β³ Phase 5: Python-native differentiators
See FEATURE_LIST.md for detailed feature status and PR guidelines.
git clone https://github.com/agentforce314/clawcodex.git
cd clawcodex
# Create venv (uv recommended)
uv venv --python 3.11
source .venv/bin/activate
# Install package + entry point (recommended)
uv pip install -e ".[dev]"
# Alternative: requirements only, then editable install
# uv pip install -r requirements.txt && uv pip install -e .clawcodex login
# or: python -m src.cli loginThis flow will:
- ask you to choose a provider: anthropic / openai / glm / minimax / openrouter / deepseek
- ask for that provider's API key
- optionally save a custom base URL
- optionally save a default model
- set the selected provider as default
The configuration file is saved in in ~/.clawcodex/config.json. Example structure:
{
"default_provider": "anthropic",
"providers": {
"anthropic": {
"api_key": "base64-encoded-key",
"base_url": "https://api.anthropic.com",
"default_model": "claude-sonnet-4-6"
},
"openai": {
"api_key": "base64-encoded-key",
"base_url": "https://api.openai.com/v1",
"default_model": "gpt-5.4"
},
"glm": {
"api_key": "base64-encoded-key",
"base_url": "https://open.bigmodel.cn/api/paas/v4",
"default_model": "zai/glm-5"
},
"minimax": {
"api_key": "base64-encoded-key",
"base_url": "https://api.minimaxi.com/anthropic",
"default_model": "MiniMax-M2.7"
},
"openrouter": {
"api_key": "base64-encoded-key",
"base_url": "https://openrouter.ai/api/v1",
"default_model": "deepseek/deepseek-v4-pro"
},
"deepseek": {
"api_key": "base64-encoded-key",
"base_url": "https://api.deepseek.com",
"default_model": "deepseek-v4-pro"
}
}
}clawcodex # Start inline REPL (same as python -m src.cli)
clawcodex --help # All flags: --tui, -p, --provider, --model, β¦That's it! Configure keys, then run the CLI or REPL.
| Command | Description |
|---|---|
/ |
Show commands and skills |
/help |
Help text |
/tools |
List tool names from the registry |
/tool <name> <json> |
Run a tool directly with JSON input |
/stream |
Toggle streaming: /stream on, off, or toggle |
/render-last |
Re-render last assistant reply as Markdown |
/save / /load <id> |
Persist or restore a session |
/clear |
Clear conversation (also /reset, /new) |
/tui |
Switch to the Textual TUI |
/skill |
Skill launcher flow |
/context |
Workspace / prompt context (when available) |
/compact |
Compact or clear conversation (fallback clears if compact unavailable) |
/exit, /quit, /q |
Exit |
Skills are markdown-based slash commands stored under .clawcodex/skills. Each skill lives in its own directory and must be named SKILL.md.
1) Create a project skill
Create:
<project-root>/.clawcodex/skills/<skill-name>/SKILL.md
Example:
---
description: Explains code with diagrams and analogies
when_to_use: Use when explaining how code works
allowed-tools:
- Read
- Grep
- Glob
arguments: [path]
---
Explain the code in $path. Start with an analogy, then draw a diagram.2) Use it in the REPL
β― /
β― /<skill-name> <args>
Example:
β― /explain-code qsort.py
Notes
- User-level skills:
~/.clawcodex/skills/<skill-name>/SKILL.md - Tool limits:
allowed-toolscontrols which tools the skill can use. - Arguments: use
$ARGUMENTS,$0,$1, or named args like$path(fromarguments). - Placeholder syntax: use
$path, not${path}.
Every app under demos/ was generated end-to-end by ClawCodex itself β same CLI you just installed, same agent loop, same tools. No hand-edits π
| Demo | Stack | Description |
|---|---|---|
demos/crm-app |
React 18 + Vite + Vitest | Mini CRM with contacts, deals, dashboard, and a full test suite |
demos/linkedin-app |
React 18 + Vite + React Router | LinkedIn-style feed: profile, network, jobs, messaging |
demos/minecraft-app |
React + three.js + @react-three/fiber | Browser voxel sandbox with terrain, mining, HUD, and player controls |
cd demos/crm-app # or linkedin-app / minecraft-app
npm install
npm run dev # vite dev serverWant to see how it's done? Open ClawCodex in any empty directory and ask it to build something β these three were generated exactly that way.
- Not a clone β Ported from actual TypeScript implementation
- Architectural fidelity β Maintains proven design patterns
- Improvements β Better error handling, more tests, cleaner code
- Type hints β Full type annotations
- Modern Python β Uses 3.10+ features
- Idiomatic β Clean, Pythonic code
- 3-step setup β Clone, configure (
clawcodex login), run (clawcodex) - Interactive config β Provider, base URL, and default model in one flow
- Inline or TUI β Default terminal-native REPL; opt-in Textual UI
- Scriptable β
-p/ JSON / NDJSON for automation - Session persistence β Save and reload conversations
For the six core abstractions (query loop, tools, tasks, two-tier state,
memory, hooks) and the golden path from user input to model output,
see docs/ARCHITECTURE.md. It is the recommended
starting point for new contributors.
The reference for the original Claude Code architecture is at
claude-code-from-source/book/ch01-architecture.md; the
chapter-by-chapter port gap analyses and refactoring plans live under
my-docs/.
clawcodex/
βββ src/
β βββ cli.py # CLI entry (console: clawcodex)
β βββ entrypoints/ # Headless (-p) and TUI bootstraps
β βββ repl/ # Inline REPL (prompt_toolkit + Rich)
β βββ tui/ # Textual UI (--tui, /tui)
β βββ providers/ # Anthropic, OpenAI, GLM, Minimax, OpenRouter, DeepSeek
β βββ agent/ # Conversation, session, prompts
β βββ tool_system/ # Agent loop, tools, schemas
β βββ skills/ # SKILL.md loading and skill tool
β βββ services/ # MCP, compact, IDE bridge, tool execution, β¦
β βββ context_system/ # Workspace / git / CLAUDE.md context
β βββ permissions/ # Permission modes and bash parsing
β βββ hooks/ # Hook types and execution helpers
β βββ command_system/ # Slash commands and substitution
βββ typescript/ # Reference / parity source (not required to run Python CLI)
βββ tests/ # pytest suites
βββ docs/ # Guides, i18n READMEs, refactor notes
βββ .clawcodex/skills/ # Project-local skills (optional)
βββ FEATURE_LIST.md # Capability matrix and roadmap
βββ pyproject.toml # Package metadata and clawcodex script
We welcome contributions!
# Quick dev setup
pip install -e .[dev]
python -m pytest tests/ -vSee CONTRIBUTING.md for guidelines.
- SETUP_GUIDE.md β Detailed installation
- CONTRIBUTING.md β Development guide
- TESTING.md β Testing guide
- CHANGELOG.md β Version history
- Startup: < 1 second
- Memory: < 50MB
- Response: Turn-based assistant output with Rich markdown rendering
β Basic Local Safety Practices
- No sensitive data in Git
- API keys obfuscated in config
.envfiles ignored- Safe for local development workflows
MIT License β See LICENSE
- Based on Claude Code TypeScript source
- Independent educational project
- Not affiliated with Anthropic
If you find this useful, please star β the repo!
Made with β€οΈ by ClawCodex Team
