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

# Pass a one-shot prompt without entering REPL
clew -p "summarize CHANGELOG.md"

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
OpenGatewayOPENGATEWAY_API_KEY
Ollama (Local)OLLAMA_HOST (defaults to http://localhost:11434)
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 several layers depending on your workflow:

  • Agent: The root agent session coordinating permissions, UI, and active memory context. Custom agents live in .clew/agents/*.md.
  • 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.
  • ExecAgent: External CLI/Codex process delegation for running separate specialized model loops (formerly "Process Peer").
  • Background Agent: Persistent task queue with lease-based concurrency, cron scheduling, and daemon mode.

Slash Commands

Control the session directly using terminal slash commands:

CommandPurpose
/modelSwitch provider or model
/statusProvider, session, context info
/doctorDiagnostics and provider health checks
/contextActive context usage
/compactCompress conversation history + extract memories
/goalTrack and verify overall task completion
/mcpMCP server management
/code-reviewReview changed files for bugs
/pluginPlugin and hook management
/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
/ruleView / toggle project rules
/workspaceLink / unlink / list project repos
/cdChange working directory
/diffShow git diff
/filesExplore project files
/branchGit branch operations
/forkFork a conversation
/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
/deep-researchDeep research with multi-source synthesis
/workflowMulti-step workflow automation
/rewindUndo last response
/upgradeCheck for updates
/sessionSession management
/themeTheme switcher
/skillsList and manage skills
/ultracodeUltraCode reasoning mode
/costToken cost summary
/thinkbackBrowse past agent thoughts
/passesView test/code passes
/hooksManage lifecycle hooks
/exportExport conversation
/sandbox-toggleToggle sandbox mode
/insightsGenerate session analysis report

Profile is set via settings.json ("profile": "personal") — no slash command.


Configuration

Settings files are stored in .clew/ at the project root:

  • .clew/settings.json — Shared project settings (checked into version control)
  • .clew/settings.local.json — Private/local overrides (gitignored, never commit)

Also supports ~/.clew/ for global defaults.

Example settings.json

json
{
  "defaultProvider": "deepseek",
  "defaultModel": "deepseek-reasoner",
  "theme": "dark",
  "autoApprove": {
    "readFiles": true,
    "writeFiles": false,
    "runCommands": false
  },
  "hooks": {
    "PostToolUse": "echo 'tool used: $TOOL_NAME'"
  },
  "permissions": {
    "allow": ["Bash", "Read", "Edit", "Write", "Glob", "Grep"],
    "deny": []
  }
}

Released under the GPL-3.0 License.