Open Source Terminal AI Runtime

Run AI agents locally.
Fully transparent.

KLAW runs AI agents directly in your shell. It plans, writes files, executes commands, and repairs errors, keeping everything fully visible step-by-step with complete permission control.

PowerShell / Bash
$ npm install -g @phartmann80/klaw
$ klaw doctor
[DOCTOR] OK Package: 0.3.0
[DOCTOR] OK Provider: openai (gpt-4o-mini)
$ klaw run "build a Next.js landing page" --yes
[KLAW][ARCHITECT] Planning 4 steps...
[KLAW][WRITER] Wrote package.json, pages/index.js
[KLAW][SHELL] Executing: npm install
[KLAW][SYSTEM] Status: completed

Quick Installation

Install globally via npm or clone directly from GitHub. Available for Windows PowerShell, Linux / WSL, and macOS.

# Install KLAW globally
$ npm install -g @phartmann80/klaw

# Set your API Key (e.g. OpenAI, Anthropic, Gemini)
$ export OPENAI_API_KEY="sk-..." # or $env:OPENAI_API_KEY="..." on PowerShell

# Verify setup & run your first task
$ klaw doctor
$ klaw run "create an express server" --model gpt-4o-mini --yes

Support for Any Provider

Switch models dynamically using CLI flags or configure your provider in ~/.klaw/config.json.

OpenAI & GPT-4o

Fast, precise generation with gpt-4o-mini or gpt-4o defaults.

Google Gemini

Native integration with gemini-2.0-flash for rapid planning and coding tasks.

Anthropic Claude

Powered by claude-3-5-sonnet for complex architectural reasoning.

OpenRouter

Access hundreds of models using a single unified OpenRouter API key.

Ollama (Local AI)

Run 100% offline with local models like llama3.2 without sharing data.

Langdock

Enterprise multi-llm routing and custom endpoints compatibility.

Model Context Protocol

Connect Klaw directly to Claude Desktop, Cursor, or any other MCP host to run Klaw agents as a tool.

# Start the MCP server locally over stdio
$ klaw mcp
# Or connect Klaw dynamically to your Claude Desktop config file:
{
  "mcpServers": {
    "klaw": {
      "command": "npx",
      "args": ["-y", "@phartmann80/klaw", "mcp"]
    }
  }
}

Built for Developer Control

KLAW operates through four specialized, coordinated agents that run strictly within your workspace.

Architect Agent

Generates structured JSON execution plans before any file edits take place, validating steps and retry logic automatically.

Writer Agent

Creates and modifies project files safely, enforcing workspace boundary security to prevent modifications outside your target folder.

Shell Agent

Runs terminal commands with strict user prompt checks, non-interactive CI flags (--ci), and real-time execution logging.

Fixer Agent

Captures command failures (such as missing npm packages or syntax errors), inspects context, applies precise patches, and retries automatically.

  • CLI --model and --provider override flags
  • Non-interactive auto-approval mode with --yes and --ci
  • Model Context Protocol (MCP) server support built in
  • Zero telemetry; everything runs locally in your terminal
  • Automated recovery loop for broken builds