closed-loop-cli
v1.1.1
Published
Self-Developing Multi-Agent CLI Coding Assistant
Readme
closed-loop-cli
A self-developing, multi-agent CLI coding assistant. It runs an agentic read → act → verify loop over your codebase using file, search, and shell tools, and works with any Anthropic-compatible endpoint — Anthropic itself, or a gateway/proxy serving another model (OpenRouter, LiteLLM, MiMo Token Plan, a local proxy, …).
Status: early/alpha. The core loop, tooling, permission system, and multi-model support work; expect rough edges.
Features
- Agentic loop with file read/write/edit, directory listing, grep, a local AST code index, web search, and sandboxed shell execution.
- Read-before-edit safety — a file must be read before it can be edited, and edits are rejected if the file changed on disk since it was read.
- Permission system —
default/acceptEdits/plan/yolomodes with per-session "always allow" choices, on top of hard safety rules (RuleZ). - Parallel tools — independent read-only tool calls run concurrently.
- Subagents — delegate self-contained sub-tasks to a fresh context.
- Automatic context compaction — long histories are summarized to stay in budget.
- Adaptive output budget and retry with backoff on transient API errors.
- Model-agnostic — works with any Anthropic-compatible model/endpoint via standard Claude Code environment variables; not tied to any single provider.
- Polished interactive REPL — clean banner, Markdown-rendered answers, concise progress (no wall of logs), multi-line paste, in-line cursor editing (←/→/Home/End/Delete), and ↑/↓ command history.
- Runs in your project folder — like
claude, it operates in the directory you launch it from and creates files there.
Install
npm install -g closed-loop-cliOr run without installing:
npx closed-loop-cliQuick start
Set credentials (the CLI also prompts for and saves a key to ~/.closed-loop.json
if none is found):
export ANTHROPIC_API_KEY="sk-ant-..."
closed-loopWith no model configured it defaults to claude-haiku-4-5, so a standard
Anthropic key works out of the box. The CLI operates in your current working
directory — cd into a project (or an empty folder) and run closed-loop
there. Type your task at the prompt; paste multi-line prompts freely (they submit
only on Enter); ↑/↓ recall history; type help, clear, or exit.
Configuration (environment variables)
Model selection follows the same conventions as Claude Code, so an existing Claude Code shell setup works unchanged.
| Variable | Purpose |
| --- | --- |
| ANTHROPIC_API_KEY / ANTHROPIC_AUTH_TOKEN | Credentials |
| ANTHROPIC_BASE_URL | Point at any Anthropic-compatible endpoint |
| ANTHROPIC_MODEL | Main model (also falls back to ANTHROPIC_DEFAULT_OPUS_MODEL, then ANTHROPIC_DEFAULT_SONNET_MODEL) |
| CLAUDE_CODE_SUBAGENT_MODEL | Subagent model (also falls back to ANTHROPIC_DEFAULT_HAIKU_MODEL) |
| ANTHROPIC_MAX_TOKENS | Override output token budget |
| CLAUDE_CODE_EFFORT_LEVEL | max / ultracode raises step + token budget |
| CLOSED_LOOP_PERMISSION_MODE | default / acceptEdits / plan / yolo |
| CONTEXT_COMPACT_THRESHOLD_TOKENS | When to summarize history (default 120000) |
| CONTEXT_KEEP_RECENT_MESSAGES | Recent messages kept verbatim on compaction |
Works with any model
The CLI talks to whatever ANTHROPIC_BASE_URL + model you configure — Anthropic
directly, or any Anthropic-compatible gateway (OpenRouter, LiteLLM, a local proxy,
MiMo Token Plan, …). To use Anthropic, just set ANTHROPIC_API_KEY. To use any
other provider, point ANTHROPIC_BASE_URL at its compatible endpoint and set the
model id. No code changes required.
Example: a non-Claude provider (MiMo Token Plan)
# Anthropic-compatibility endpoint + token
$env:ANTHROPIC_BASE_URL = "https://token-plan-sgp.xiaomimimo.com/anthropic"
$env:ANTHROPIC_AUTH_TOKEN = "tp-...your-token..."
# Main model. mimo-v2.5-pro has a 1M context window natively.
$env:ANTHROPIC_MODEL = "mimo-v2.5-pro"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL = "mimo-v2.5-pro"
# Cheaper model for subagents (mimo-v2.5 is a deep-thinking, lower-cost model)
$env:CLAUDE_CODE_SUBAGENT_MODEL = "mimo-v2.5"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "mimo-v2.5"
$env:CLAUDE_CODE_EFFORT_LEVEL = "max"
closed-loopNote on the
[1m]suffix: Claude Code uses amodel[1m]notation to opt into a 1M-context beta. That suffix is not part of the model id a raw API accepts, so the CLI strips any trailing[...]automatically — a pasted Claude Code config likemimo-v2.5-pro[1m]works, and resolves tomimo-v2.5-pro.
CLI flags
| Flag | Effect |
| --- | --- |
| --plan | Read-only; no edits or commands |
| --accept-edits | Auto-approve file edits (commands still prompt) |
| --yolo | Auto-approve everything (RuleZ hard rules still apply) |
| -e, --effort <standard\|ultracode\|max> | Reasoning/step budget |
| --codeact / --openhands | CodeAct-style coder profile |
| --dashboard | Launch the monitoring dashboard server |
| --telegram | Run the Telegram ChatOps bot |
Equivalent npm scripts when running from source: npm start,
npm run dashboard, npm run telegram, npm run dgm.
Permission modes
- default — read-only tools run automatically; file edits and shell commands ask for confirmation (with an "always allow" option for the session).
- acceptEdits — file edits auto-run; shell commands still ask.
- plan — read-only only; mutating tools are denied.
- yolo — everything auto-runs. Use with care.
In a non-interactive session, actions that would prompt are denied unless the
mode auto-approves them (acceptEdits / yolo).
Build from source
git clone <repo>
cd closed-loop
npm install
npm run build
npm startRequires Node.js 18+ and a TypeScript toolchain (installed via devDependencies).
License
See repository.
