Skip to content

aliii-codes/claw-code-agent

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Claw Code Agent logo

πŸ¦€ Claw Code Agent

A Python reimplementation of the Claude Code agent architecture β€” local models, full control, zero dependencies.

Python 3.10+ GitHub Stars GitHub Forks GitHub Issues License


✨ Highlights

  • πŸš€ Interactive Chat Mode: Multi-turn REPL with /exit to quit
  • πŸ“‘ Streaming Output: Token-by-token streaming with --stream flag
  • πŸ› οΈ 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 .ipynb cell 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

Claw Code Agent demo

πŸ“– About

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.


πŸ› οΈ Tech Stack

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

πŸš€ Installation

  1. Clone the repository

    git clone https://github.com/aliii-codes/claw-code-agent.git
    cd claw-code-agent
  2. 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
  3. Verify the server

    curl http://127.0.0.1:8000/v1/models
  4. 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
  5. Run the agent

    python3 -m src.main agent "Read src/agent_runtime.py and summarize the loop." --cwd .

πŸ•ΉοΈ Usage

Agent Commands

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

CLI Flags

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

πŸ“‚ Project Structure

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

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/YourFeature).
  3. Commit your changes (git commit -m 'Add some feature').
  4. Push to the branch (git push origin feature/YourFeature).
  5. Open a pull request.

πŸ› Bug Reports & Feature Requests

Please use the issue tracker to report bugs or request features.


πŸ“„ License

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.

About

Claw Code No Rust No TypeScript Only Python. Easy to work with. Fast to iterate. πŸ”₯ Zero external dependencies πŸ”₯

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 92.6%
  • HTML 7.4%