A Python reimplementation of the Claude Code agent architecture β local models, full control, zero dependencies.
- π Interactive Chat Mode: Multi-turn REPL with
/exitto quit - π‘ Streaming Output: Token-by-token streaming with
--streamflag - π οΈ Plugin Runtime: Full manifest-based plugin system
- π Nested Agent Delegation: Subtask delegation with topological batching
- π Agent Manager: Lineage tracking and batch summaries
- π Custom Agent Profiles: Local markdown-defined agents
- π° Cost Tracking: Token budgets, cost limits, tool-call limits
- π Structured Output: JSON schema response mode
- ποΈ Context Compaction: Auto-snip, auto-compact, reactive compaction
- π File History Replay: Journaling and replay summaries
- π Truncation Continuation: Automatic continuation on cut-off responses
- π³ Ollama Support: Out-of-the-box OpenAI-compatible API
- π LiteLLM Proxy Support: Route to any provider
- π OpenRouter Support: Cloud API gateway access
- π Query Engine: Runtime event counters and orchestration reports
- π₯οΈ Remote Runtime: Manifest-backed local remote profiles
- π‘οΈ Hook & Policy Runtime: Local policy manifests and trust reporting
- π Task & Plan Runtime: Persistent local tasks and plans
- π¦ MCP Transport: Real stdio MCP transport
- π Search Runtime: Provider-backed
web_search - βοΈ Config & Account Runtime: Local config mutation and account profiles
- π¬ Ask-User Runtime: Queued or interactive user questions
- π₯ Team Runtime: Persisted local teams and message history
- π Notebook Edit Tool: Native
.ipynbcell editing - ποΈ Workflow Runtime: Manifest-backed local workflows
- π‘ Remote Trigger Runtime: Local remote triggers
- πΏ Worktree Runtime: Managed git worktrees
- π’ Tokenizer-Aware Context: Cached tokenizer backends
- βοΈ Prompt Budget Preflight: Token-budget reporting and auto-compact
- π οΈ LSP Runtime: Local LSP-style code intelligence
- π Local Web GUI: Browser-based chat UI
- π Daemon Commands: Background session management
- π Background Sessions: Local background session workflows
| Feature | Description |
|---|---|
| π€ Agent Loop | Full agentic coding loop with tool calling and iterative reasoning |
| π¬ Interactive Chat | Multi-turn REPL via agent-chat with session continuity |
| π Local Web GUI | Browser-based chat UI launched with python -m src.gui |
| π οΈ Core Tools | File read/write/edit, glob search, grep search, shell execution |
| π§© Plugin Runtime | Manifest-based plugins with hooks, aliases, virtual tools, and tool blocking |
| π Nested Delegation | Delegate subtasks to child agents with dependency-aware topological batching |
| π Custom Agents | Load local agent profiles from ~/.claude/agents and ./.claude/agents |
| π‘ Streaming | Token-by-token streaming output with --stream |
| β¨οΈ Slash Commands | Local commands for context, config, account, search, MCP, remote, tasks, etc. |
| π₯οΈ Remote Runtime | Manifest-backed remote profiles with local remote-mode support |
| π Task & Plan Runtime | Persistent tasks and plans with sync, next-task selection, and blocked/unblocked state |
| π¦ MCP Runtime | Local MCP manifests plus real stdio MCP transport |
| π Search Runtime | Provider-backed web_search plus provider activation and status reporting |
| βοΈ Config & Account Runtime | Local config mutation, settings inspection, account profiles, and login/logout state |
| π¬ Ask-User Runtime | Queued answer or interactive user-question flow with history tracking |
| π₯ Team Runtime | Persisted local teams plus message history, handoff notes, and collaboration metadata |
| π Notebook Editing | Native Jupyter notebook cell editing through notebook_edit |
| πΏ Worktree Runtime | Managed git worktrees with worktree_enter, worktree_exit, and live cwd switching |
| ποΈ Workflow Runtime | Manifest-backed workflows with slash commands, CLI inspection, and recorded runs |
| π‘ Remote Triggers | Local remote triggers with create/update/run flows and npm-style trigger actions |
| π‘οΈ Hook & Policy Runtime | Trust reporting, safe env, managed settings, tool blocking, and budget overrides |
| π’ LSP Code Intelligence | Local LSP-style definitions, references, hover, symbols, diagnostics, and call hierarchy |
| π Context Engine | Automatic context building with CLAUDE.md discovery, compaction, and snipping |
| π’ Tokenizer-Aware Accounting | Model-aware token counting with cached tokenizer backends and fallback heuristics |
| βοΈ Prompt Budgeting | Soft/hard prompt-window checks, token-budget reports, and preflight context collapse |
| πΎ Session Persistence | Save and resume agent sessions with file-history replay |
| π Background Sessions | agent-bg and local daemon wrappers for background runs, logs, attach, and kill |
| π° Cost & Budget Control | Token budgets, cost limits, tool-call caps, model-call caps |
| π Structured Output | JSON schema response mode for programmatic use |
| π Permission System | Granular control: --allow-write, --allow-shell, --unsafe |
| π OpenAI-Compatible | Works with vLLM, Ollama, LiteLLM Proxy, OpenRouter |
| π€ Qwen3-Coder | First-class support for Qwen3-Coder-30B-A3B-Instruct via vLLM |
| π« Zero Dependencies | Pure Python standard library β nothing to install |
This repository reimplements the Claude Code npm agent architecture entirely in Python, designed to run with local open-source models via an OpenAI-compatible API server.
Built on the public porting workspace from instructkr/claw-code, the active development lives at aliii-codes/claw-code-agent.
Goal: Not to ship the original npm source, but to reimplement the full agent flow in Python β prompt assembly, context building, slash commands, tool calling, session persistence, and local model execution.
Zero external dependencies β just Python's standard library.
| Category | Technologies |
|---|---|
| Language | Python 3.10+ |
| Model Server | vLLM, Ollama, LiteLLM Proxy, OpenRouter |
| Model | Qwen3-Coder-30B-A3B-Instruct (recommended) |
| GUI | FastAPI, Uvicorn, Vanilla JS |
| Testing | Unittest |
| Packaging | setuptools, pyproject.toml |
-
Clone the repository
git clone https://github.com/aliii-codes/claw-code-agent.git cd claw-code-agent -
Start vLLM with Qwen3-Coder
python -m vllm.entrypoints.openai.api_server \ --model Qwen/Qwen3-Coder-30B-A3B-Instruct \ --host 127.0.0.1 \ --port 8000 \ --enable-auto-tool-choice \ --tool-call-parser qwen3_xml
-
Verify the server
curl http://127.0.0.1:8000/v1/models
-
Configure environment variables
export OPENAI_BASE_URL=http://127.0.0.1:8000/v1 export OPENAI_API_KEY=local-token export OPENAI_MODEL=Qwen/Qwen3-Coder-30B-A3B-Instruct
-
Run the agent
python3 -m src.main agent "Read src/agent_runtime.py and summarize the loop." --cwd .
| Command | Description |
|---|---|
agent <prompt> |
Run the agent with a prompt |
agent-chat [prompt] |
Start interactive multi-turn chat mode |
agent-bg <prompt> |
Run the agent in a local background session |
agent-ps |
List local background sessions |
agent-logs <id> |
Show background session logs |
agent-attach <id> |
Show the current background output snapshot |
agent-kill <id> |
Stop a background session |
daemon <subcommand> |
Daemon-style wrapper over local background sessions |
agent-prompt |
Show the assembled system prompt |
agent-context |
Show estimated context usage |
agent-context-raw |
Show the raw context snapshot |
token-budget |
Show prompt-window budget, reserves, and soft/hard input limits |
agents [agent_type] |
List active local agent definitions or show one agent profile |
agents-create <agent_type> |
Create a project or user agent definition markdown file |
agents-update <agent_type> |
Update an existing project or user agent definition |
agents-delete <agent_type> |
Delete an existing project or user agent definition |
agent-resume <id> <prompt> |
Resume a saved session |
| Flag | Description |
|---|---|
--cwd <path> |
Set the workspace directory |
--model <name> |
Override the model name |
--base-url <url> |
Override the API base URL |
--allow-write |
Allow the agent to modify files |
--allow-shell |
Allow the agent to execute shell commands |
--unsafe |
Allow destructive shell operations |
--stream |
Enable token-by-token streaming output |
--show-transcript |
Print the full message transcript |
--scratchpad-root <path> |
Override the scratchpad directory |
--system-prompt <text> |
Set a custom system prompt |
--append-system-prompt <text> |
Append to the system prompt |
--override-system-prompt <text> |
Replace the generated system prompt |
--add-dir <path> |
Add extra directories to context |
claw-code-agent/
βββ images/
β βββ logo.png
β βββ demo_2.gif
βββ src/
β βββ QueryEngine.py
β βββ Tool.py
β βββ __init__.py
β βββ agent_context.py
β βββ agent_context_usage.py
β βββ agent_memory.py
β βββ agent_prompting.py
β βββ agent_runtime.py
β βββ agent_session.py
β βββ agent_slash_commands.py
β βββ agent_tools.py
β βββ agent_types.py
β βββ bootstrap_graph.py
β βββ command_graph.py
β βββ commands.py
β βββ context.py
β βββ costHook.py
β βββ cost_tracker.py
β βββ deferred_init.py
β βββ dialogLaunchers.py
β βββ direct_modes.py
β βββ dotenv_loader.py
β βββ execution_registry.py
β βββ history.py
β βββ ink.py
β βββ interactiveHelpers.py
β βββ main.py
β βββ models.py
β βββ openai_compat.py
β βββ parity_audit.py
β βββ permissions.py
β βββ port_manifest.py
β βββ prefetch.py
β βββ projectOnboardingState.py
β βββ query.py
β βββ query_engine.py
β βββ remote_runtime.py
β βββ replLauncher.py
β βββ runtime.py
β βββ session_store.py
β βββ setup.py
β βββ system_init.py
β βββ task.py
β βββ tasks.py
β βββ tool_pool.py
β βββ tools.py
β βββ transcript.py
β βββ web_server.py
β βββ gui/
β βββ __main__.py
β βββ server.py
β βββ static/
β βββ index.html
β βββ app.css
β βββ app.js
βββ tests/
β βββ test_agent_context.py
β βββ test_agent_context_usage.py
β βββ test_agent_memory.py
βββ pyproject.toml
βββ README.md
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/YourFeature). - Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature/YourFeature). - Open a pull request.
Please use the issue tracker to report bugs or request features.
This project is licensed under the MIT License - see the LICENSE file for details.
Built with β€οΈ by the aliii-codes team.
Built with π Python Β· Powered by π HarnessLab Team.

