Code with any AI.
Clew Code is an open-source AI coding agent that runs in your terminal, coordinates across machines on your LAN, and works with 27 different AI providers — no lock-in.
Features
27 Providers
Anthropic, OpenAI, Google Gemini, DeepSeek, Groq, Mistral, Ollama, OpenRouter, and 19 more. Switch mid-session with /model.
LAN Peer
Discover peers, assign tasks, execute remote commands, and coordinate across machines via UDP multicast or file registry.
15 toolsAutonomous Loop
Persistent task queue, lease-based concurrency, exponential-backoff retry, dead-letter management, and cron scheduling.
MCP Integration
Model Context Protocol via stdio, SSE with OAuth, or DirectConnect for in-process plugin servers.
50+ Built-in Tools
Read, Write, Edit, Bash, WebSearch, WebFetch, Browser (Playwright), PR, NotebookEdit, JsonPath, and more.
3 Execution Layers
Subagents (one-shot), Swarm/Teammates (long-running), Process Peer (Codex via exec/pty).
Skills & Plugins
Extend via SKILL.md, plugin manifests with lifecycle hooks at every stage (PreToolUse, PostBash, and more).
7 Permission Modes
Default, ask, plan, auto, acceptEdits, bypassPermissions, dontAsk — with granular allow/deny rule patterns.
Plan Mode
Full-access planning with bypass permissions. Explore, read, write, and edit freely. Plans persist with progress snapshots.
Memory System
Persistent auto-memory, topic indexing, session digests with weekly/monthly consolidation — like human memory decay.
Web UI & Remote
Local WebSocket server with one-time auth tokens, optional NAT-traversal relay, and session management.
Image & Video Generation
AI-callable tools for DALL-E 3, Imagen 3, OpenRouter image models, and Runway Gen-4. Auto-discovers models from provider APIs.
Multi-Pass Compaction
Automatic chunk-based context compression with recursive re-compaction when context exceeds the model window.
Quick Start
npm install -g clew-code
cd my-project
clew
# Inside the REPL:
# /model openai # pick a provider
# /help # list all commands
# /peer discover # find peers on LAN
Core Concepts
Clew Code has several execution layers, each serving a different purpose:
Agent
An AI worker with a prompt, model, tools, and permissions. The main chat session is an agent. Custom agents live in .clew/agents/*.md.
Subagent
A short-lived child agent for independent work like codebase exploration or test triage. The built-in Explore agent is read-only.
Teammate / Swarm
A longer-lived agent team member with identity, mailbox, task coordination, and optional pane/tmux execution.
LAN Peer
A network of Clew instances on the same machine or LAN. /peer discovers peers, sends messages, and assigns tasks.
Process Peer
Local process-backed worker. Delegates prompts to external CLIs like Codex using exec or pty modes.