Skip to content

Clew CLI Docs

Open-source, local-first AI coding agent CLI. Runs on your own hardware using your own API keys — supporting 29 LLM providers.


Introduction

Clew Code is an autonomous coding agent that runs directly in your terminal. It features a complete Ink-based React REPL interface, automatic context compaction, SQLite-backed long-term memory, LAN peer discovery for multi-machine swarms, and modular tool integrations.


Installation

Choose your preferred installation method below:

This script installs Bun automatically if missing, then installs the Clew Code CLI.

macOS / Linux:

bash
curl -fsSL https://raw.githubusercontent.com/ClewCode/ClewCode/main/scripts/install.sh | bash

Windows (PowerShell as Admin):

powershell
irm https://raw.githubusercontent.com/ClewCode/ClewCode/main/scripts/install.ps1 | iex

With npm

Requires Node.js 18+ and Bun 1.3+.

bash
npm install -g clew-code

From Source (Bun)

bash
# Clone the repository
git clone https://github.com/ClewCode/ClewCode.git
cd ClewCode

# Install dependencies & build
bun install
bun run build

# Link globally
bun link

First Run

Simply type clew in your terminal inside any project directory to launch the interactive REPL:

bash
clew

To resume a past conversation or launch a specific session, use the session flags:

bash
# Resume your last active session
clew --resume last

# Start a plan-mode session (bypasses prompt confirmations)
clew --plan

29 Providers

Clew Code is provider-agnostic, supporting 29 native LLM engines. Setup your API key as an environment variable before launching the CLI:

ProviderEnvironment Variable
OpenAIOPENAI_API_KEY
Google Gemini / Code AssistGOOGLE_API_KEY
DeepSeekDEEPSEEK_API_KEY
GroqGROQ_API_KEY
Ollama (Local)OLLAMA_HOST (defaults to http://localhost:11434)
Sakana AISAKANA_API_KEY
Clew GatewayCLEW_GATEWAY_KEY

Switch between providers or models at any time inside a session using the /model slash command.


Persistent Memory

Clew Code contains a MiMo-inspired, SQLite-backed long-term memory system. It automatically:

  • Aggregates factoids, style preferences, and architectural decisions about your codebase.
  • Ranks memory importance and frequency of access.
  • Injects relevant context chunks back into the prompt cycles.
  • Stores human-readable markdown summaries locally under ~/.clew/memory/.

LAN Peer Swarm

With zero configuration, Clew Code instances discover each other on the local network (LAN) using UDP multicast. You can:

  • Sync project databases and memories across developer machines.
  • Delegate execution tasks to other machines on the LAN.
  • Broadcast bash commands to run concurrently on all peers (Swarm execution).

Execution Layers

Tasks are distributed across four isolated layers depending on your workflow:

  • Agent: The root agent session coordinating permissions, UI, and active memory context.
  • Subagent: Focus-oriented, short-lived child processes spawned in the background (typically read-only) to solve specific sub-tasks without cluttering your main session.
  • Peer: Network-connected nodes coordinating LAN swarms.
  • Process Peer: External CLI/Codex process delegation for running separate specialized model loops.

Slash Commands

Control the session directly using terminal slash commands:

CommandPurpose
/modelSwitch provider or model
/statusProvider, session, context info
/doctorDiagnostics and provider health checks
/profilePersonal profile mode (coding / command center)
/contextActive context usage
/compactCompress conversation history + extract memories
/goalTrack and verify overall task completion
/maxmodeToggle parallel candidate generation
/mcpModel Context Protocol server management
/code-reviewReview changed files for bugs
/simplifyCleanup-focused review
/pluginPlugin and hook management
/bridgeBridge mode configuration
/agentBackground agent dispatch
/agentsTUI Agent dashboard
/peerLAN peers: share, discover, swarm, dashboard
/remoteWebSocket remote control
/daemonAutonomous daemon dashboard
/taskScheduled tasks
/memorySQLite memory system management
/tasksCurated task checklist
/effortSet reasoning effort
/statsSession statistics
/guardianAuto-review mode using secondary LLM
/approveOverride guardian denials
/prGitHub PR lifecycle
/voiceVoice input
/buddyCompanion card
/teamTeam dashboard
/bgBackground sessions
/planPlan mode
/vimVim keybindings
/researchResearch dossier management
/workflowMulti-step workflow automation
/rewindUndo last response
/upgradeCheck for updates
/sessionSession management
/themeTheme switcher
/skillsList and manage skills
/loginSign in to Clew Gateway for cloud models and syncing

Configuration

Settings files are stored in your home directory under ~/.clew/:

  • ~/.clew/settings.json — Shared global configurations, default models, and UI preferences.
  • ~/.clew/settings.local.json — Local overrides (private config and custom developer setups).

Example settings.json

json
{
  "defaultProvider": "deepseek",
  "defaultModel": "deepseek-reasoner",
  "theme": "dark",
  "autoApprove": {
    "readFiles": true,
    "writeFiles": false,
    "runCommands": false
  },
  "mcp": {
    "servers": {
      "filesystem": {
        "command": "npx",
        "args": [
          "-y",
          "@modelcontextprotocol/server-filesystem",
          "C:/Users/Admin/Projects"
        ]
      }
    }
  }
}

Released under the GPL-3.0 License.