Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Claw x bkit

Local LLM + PDCA Development Harness
Claw Code(Rust CLI Runtime) + bkit(PDCA Process Framework) = AI-Native Coding Harness

InstallationQuick StartArchitectureFeaturesDocumentation

Rust Local LLM PDCA Tests License


What if you could run Claude Code with your own Local LLM, and have a PDCA quality framework automatically verify your code?

This project bridges Claw Code (open-source Rust CLI) with bkit (PDCA plugin) — enabling Local LLM-powered coding with automated quality gates.


Highlights

Feature Description
Local LLM ProviderKind::Local Run Claw Code with Ollama, vLLM, or llama.cpp. No API key needed.
Tool Calling Fallback ToolCallingMode::Auto 3-tier strategy: Native > Sequential > Prompt-based JSON parsing
PDCA Quality Gates 90% Match Rate Plan > Design > Do > Check > Act — automated gap detection and iteration
Bridge Pattern claw-bridge.sh Zero-modification bridge between bkit and Claw Code via JSON contract
Context Management filter_tools_for_context() 4-tier tool filtering for small context windows (4K~128K+)
Multi-Provider ProviderClient enum Anthropic, OpenAI, xAI, and Local — all through one unified interface

Architecture

Architecture

Developer
  └─ bkit (PDCA: 16 Agents, 27 Skills, 90% Quality Gate)
      └─ claw-bridge.sh (JSON Bridge)
          └─ Claw Code (Rust: 40 Tools, MCP, Streaming)
              └─ Local LLM (Ollama/vLLM) or Cloud API (Claude/GPT/Grok)

Installation

Prerequisites

  • Rust toolchain (rustup)
  • Ollama (or vLLM / llama.cpp) for Local LLM
  • Claude Code + bkit plugin (optional, for PDCA workflow)

1. Clone and Build

git clone https://github.com/humanist96/local_claw_code.git
cd local_claw_code

# Build Claw Code
cd /tmp && git clone https://github.com/ultraworkers/claw-code.git
cd claw-code/rust && cargo build --workspace

# Apply Local LLM patches
cp -r ~/local_claw_code/rust/crates/api/src/providers/ /tmp/claw-code/rust/crates/api/src/providers/
cp ~/local_claw_code/rust/crates/api/src/client.rs /tmp/claw-code/rust/crates/api/src/client.rs
cp ~/local_claw_code/rust/crates/api/src/lib.rs /tmp/claw-code/rust/crates/api/src/lib.rs
cp ~/local_claw_code/rust/crates/api/Cargo.toml /tmp/claw-code/rust/crates/api/Cargo.toml

# Rebuild with Local LLM support
cd /tmp/claw-code/rust && cargo build --workspace

2. Set Up Local LLM

# Start Ollama
ollama serve
ollama pull qwen2.5-coder:32b

# Configure
cp .env.claw.example .env.claw
# Edit .env.claw with your settings

3. Verify

bin/claw-bridge.sh check
# → {"ok":true,"claw_available":true}

bin/claw-bridge.sh doctor
# → {"ok":true,"command":"doctor","result":{...}}

Quick Start

Use Claw Code with Local LLM

# Set environment
export LOCAL_LLM_BASE_URL=http://localhost:11434/v1
export LOCAL_LLM_MODEL=qwen2.5-coder:32b

# Run via bridge
bin/claw-bridge.sh prompt "Read and summarize Cargo.toml"

# Or directly
/tmp/claw-code/rust/target/debug/claw prompt "explain this repository"

Use with bkit PDCA

# In Claude Code with bkit plugin:
/pdca plan my-feature          # Plan document
/pdca design my-feature        # Design document
/pdca do my-feature            # Implementation (uses Claw Code bridge)
/pdca analyze my-feature       # Gap Analysis (90% gate)
/pdca iterate my-feature       # Auto-improvement
/pdca report my-feature        # Completion report

Features

Local LLM Provider (rust/crates/api/src/providers/local.rs)

// Just set 2 environment variables:
// LOCAL_LLM_BASE_URL=http://localhost:11434/v1
// LOCAL_LLM_MODEL=qwen2.5-coder:32b

let client = LocalLlmClient::from_env();  // No API key needed
client.health_check().await?;              // GET /v1/models
client.send_message(&request).await?;      // Auto tool-calling fallback

Supported servers: Ollama, vLLM, llama.cpp, LM Studio — any OpenAI-compatible endpoint.

Tool Calling Fallback

Level Mode Description
A Native Full OpenAI function calling (Qwen, Llama 3.3)
B Auto Try native first, switch to prompt on failure
C Prompt Inject tool specs into system prompt, parse JSON from response

Claw Bridge (bin/claw-bridge.sh)

claw-bridge.sh prompt "..."    # Execute prompt via Claw Code
claw-bridge.sh status          # Workspace status (JSON)
claw-bridge.sh doctor          # Health check (JSON)
claw-bridge.sh check           # Quick availability check

# Options
--model <model>                # Override model
--timeout <seconds>            # Timeout (default: 300)
--cwd <directory>              # Working directory

JSON contract: All responses wrapped in {"ok": true/false, ...} for reliable parsing.

Recommended Models

Model Params Context Tool Calling VRAM
Qwen2.5-Coder-32B 32B 128K Native 20GB+
Llama-3.3-70B 70B 128K Native 40GB+
Qwen2.5-Coder-7B 7B 32K Native 5GB+
DeepSeek-Coder-V2-16B 16B 128K Prompt 10GB+

Project Structure

local_claw_code/
├── bin/
│   ├── claw-bridge.sh          # Main bridge script (4 commands, JSON output)
│   └── claw-bridge-env.sh      # Environment loader
├── rust/crates/api/src/
│   ├── providers/
│   │   ├── local.rs            # LocalLlmClient + ToolCallingMode + Fallback
│   │   ├── mod.rs              # ProviderKind::Local + detect_provider_kind()
│   │   └── openai_compat.rs    # OpenAiCompatConfig::local() + for_local()
│   ├── client.rs               # ProviderClient::Local integration
│   └── lib.rs                  # Exports
├── rust/crates/rusty-claude-cli/src/
│   └── main.rs                 # CLI: resolve_default_model(), build_provider_client()
├── tests/
│   └── test-claw-bridge.sh     # 15 tests (unit + integration)
├── docs/
│   ├── 01-plan/                # PDCA Plan documents
│   ├── 02-design/              # PDCA Design documents
│   ├── 03-analysis/            # Gap Analysis reports
│   ├── 04-report/              # Completion reports
│   ├── archive/                # Archived PDCA cycles
│   └── claw-code-vs-bkit-analysis.md  # Comparative analysis
├── .env.claw                   # Configuration (Local LLM + Claw Code binary path)
├── CLAUDE.md                   # Claude Code project instructions
└── README.md

Environment Variables

Variable Required Default Description
LOCAL_LLM_BASE_URL Yes http://localhost:11434/v1 LLM server endpoint
LOCAL_LLM_MODEL Yes Model name (e.g. qwen2.5-coder:32b)
LOCAL_LLM_API_KEY No local-no-key API key (usually not needed)
LOCAL_LLM_TOOL_MODE No auto native / prompt / auto
LOCAL_LLM_CONTEXT_WINDOW No auto-detect Context window size
CLAW_BIN No auto-detect Path to claw binary

PDCA Documents

This project was built entirely through PDCA (Plan-Do-Check-Act) cycles:

Feature Match Rate Iterations LOC Documents
local-llm 92% 1 ~674 Rust Plan, Design, Analysis, Report
claw-bkit-integration 100% 0 ~353 Shell Plan, Design, Analysis, Report

How It Works

Claw Code + Local LLM

1. User sets LOCAL_LLM_BASE_URL + LOCAL_LLM_MODEL
2. detect_provider_kind() detects ProviderKind::Local
3. LocalLlmClient::from_env() creates client (no API key needed)
4. ToolCallingMode::Auto tries native function calling
5. If 400 error or JSON-in-text detected → switches to Prompt mode
6. Tool specs injected into system prompt, JSON parsed from response
7. Extracted tool calls converted to OutputContentBlock::ToolUse

bkit PDCA + Claw Code Bridge

1. /pdca do feature → bkit provides implementation guide
2. bkit Agent calls: bin/claw-bridge.sh check
3. If ok → bin/claw-bridge.sh prompt "implement based on design..."
4. Claw Code uses Local LLM → generates code → JSON response
5. bkit Agent parses result → writes files
6. /pdca analyze → gap-detector compares design vs implementation
7. If < 90% → /pdca iterate auto-fixes
8. If >= 90% → /pdca report generates completion report

Claw Code vs bkit — Why Both?

Claw Code bkit
Layer Runtime engine (Rust) Process framework (Plugin)
Strength Full runtime control, Local LLM, physical parallelism PDCA process, auto quality management, 16 agents
Weakness No development process No runtime control
Analogy V8 Engine React Framework

Together: Local LLM + PDCA Quality Gates = a combination no other tool provides.

See full analysis for detailed comparison.


Contributing

  1. Fork this repository
  2. Create a feature branch
  3. Follow the PDCA workflow: /pdca plan > /pdca design > /pdca do > /pdca analyze
  4. Ensure Match Rate >= 90%
  5. Submit a Pull Request

Acknowledgments


License

MIT License. See LICENSE for details.

This project is not affiliated with, endorsed by, or maintained by Anthropic.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages