Clio
A Claude Code clone CLI - agentic coding assistant in your terminal
Ask AI about Clio
Powered by Claude Β· Grounded in docs
I know everything about Clio. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
δΈζ | English
Clio β Claude Code CLI
A feature-rich Claude Code clone that runs in your terminal. Connects to the Anthropic API (or any compatible endpoint) and provides an interactive agentic coding assistant with local tool execution.
46 source files, ~9200 lines of TypeScript. Zero external runtime dependencies beyond fast-glob.
Quick Start
# Clone and install
git clone https://github.com/icebear0828/clio.git
cd clio
npm install
# Set your API key (pick one)
export CLIO_API_KEY=sk-ant-xxx # Linux/macOS
set CLIO_API_KEY=sk-ant-xxx # Windows CMD
$env:CLIO_API_KEY = "sk-ant-xxx" # PowerShell
# Run without building (development)
npm run dev
# Or build and install globally
npm run build
npm link # now `clio` is available everywhere
# Use in any project
cd your-project
clio
Features
- Agent Loop β Multi-turn tool calling: Claude reads files, writes code, runs commands, iterates until done
- 21 Tools β Read, Write, Edit, Bash, Glob, Grep, WebFetch, WebSearch, Agent, AskUserQuestion, EnterPlanMode, ExitPlanMode, TaskCreate/Update/List/Get, Skill, ToolSearch, TeamCreate/Delete, SendMessage
- Streaming β Real-time markdown rendering with syntax-highlighted code blocks, headers, lists, inline formatting
- Prompt Caching β
cache_controlon system prompt, tools, and message history for ~90% input token savings - Model-aware Context β Dynamic context limits per model (opus 1M, sonnet/haiku 200k), auto-compact at 85%
- Permissions β Three modes (default/auto/plan), Y/n/a prompts, regex allow + deny rules, two-stage auto classifier (pattern + LLM), Shift+Tab to cycle
- Context β Auto-loads CLAUDE.md files (upward traversal) + git branch/status/commits into system prompt
- Sessions β Auto-save conversations, resume with
--resume <id>, fork with--fork-session <id> - Git Workflow β
/commit,/pr,/reviewcommands with AI-generated messages - MCP Support β JSON-RPC 2.0 over stdio, server lifecycle management, tool discovery with
mcp__prefix - Custom Agents β Define agents in
.clio/agents/*.mdwith front-matter (tools, model, max_iterations) - Background Agents β
run_in_backgroundfor async sub-agent execution with completion notifications - Worktree Isolation β Run sub-agents in isolated git worktrees
- Agent Teams β TeamCreate/TeamDelete/SendMessage for inter-agent messaging and collaboration
- Extended Thinking β Show Claude's reasoning process with
--thinking, adaptive thinking budget - Image Input β Paste image file paths to send screenshots to Claude
- Hooks β Pre/post tool execution hooks via settings.json with env vars and tool filtering
- Plugin System β Manifest-driven plugins (plugin.json) supporting skills, agents, hooks, MCP, LSP, commands injection
- LSP Integration β LspClient/LspManager with Content-Length framing, diagnostics injected into system prompt
- Skills β Skill/ToolSearch tools for deferred tool loading and built-in skill execution
- Sandboxing β Path restrictions, env filtering, network control, resource limits
- Status Bar β Configurable bottom bar (model/tokens/cost/mode/verbose/session)
- Syntax Highlighting β Language-aware coloring for TS/JS/Python/Rust/Go/Bash/JSON/CSS/HTML
- Undo/Redo β Ctrl+Z / Ctrl+Shift+Z in input with snapshot-based undo stack
- Checkpoint Rollback β Esc-Esc to restore files modified by Write/Edit
- Task Management β TaskCreate/Update/List/Get for tracking multi-step workflows
- Smart Truncation β Grep pagination (head_limit/offset), Bash output capped at 500 lines, Glob pagination
- Cost Tracking β
/costcommand + status bar with per-model USD pricing - Print Mode β Non-interactive output with
-pflag, JSON support - Keybindings β Customizable keyboard shortcuts via keybindings.json
- OpenAI Compatibility β
--api-format openaifor any OpenAI-compatible endpoint
Configuration
CLI Flags
--api-url <url> API base URL (default: https://api.anthropic.com)
--api-key <key> API key
--api-format <fmt> anthropic | openai (default: anthropic)
--model <model> Model name (default: claude-sonnet-4-20250514)
--resume <id> Resume a previous session
--fork-session <id> Fork from an existing session
--thinking <tokens> Enable extended thinking with token budget
--permission-mode <mode> default | auto | plan
--allow <pattern> Auto-allow Bash commands matching glob pattern (repeatable)
--deny <pattern> Always deny Bash commands matching pattern (repeatable)
--allow-outside-cwd Allow file tools to access paths outside working directory
--dangerously-skip-permissions Allow all tools without prompting
--no-color Disable colored output
--version Show version
Environment Variables
| Variable | Description |
|---|---|
ANTHROPIC_API_KEY | Anthropic API key |
ANTHROPIC_BASE_URL | Custom API base URL |
CLIO_API_KEY | Gateway API key (alternative) |
CLIO_API_URL | Gateway URL (alternative) |
CLIO_MODEL | Default model |
NO_COLOR | Disable colored output |
Settings Files
4-level hierarchy (later overrides earlier):
~/.clio/settings.json Global config (shared across projects)
~/.clio/settings.local.json Global secrets (gitignored β API keys)
.clio/settings.json Project config (committed, team-shared)
.clio/settings.local.json Project secrets (gitignored, personal)
Example ~/.clio/settings.json:
{
"model": "claude-sonnet-4-20250514",
"permissionMode": "default",
"allowRules": ["npm *", "git *", "pnpm *"],
"denyRules": ["rm -rf *"],
"thinkingBudget": 0,
"allowOutsideCwd": false,
"hooks": {
"pre": [
{ "command": "echo $CLIO_TOOL_NAME", "tools": ["Bash"], "timeout": 5000 }
]
},
"mcpServers": {
"my-server": {
"command": "node",
"args": ["./mcp-server.js"]
}
}
}
Arrays (allowRules, denyRules, hooks.pre, hooks.post) concatenate across layers. Scalars override.
Commands
| Command | Description |
|---|---|
/btw | Quick side question without derailing main conversation |
/clear | Reset conversation |
/commit | Generate commit message and commit staged changes |
/compact | Compress conversation context to reduce token usage |
/context | Show context window analysis (tokens by category, capacity bar) |
/cost | Show session token usage and USD cost |
/doctor | System health check (git, node, API, settings, working dir) |
/exit | Save session and quit |
/help | Show command list and keyboard shortcuts |
/init | Scan project and generate CLAUDE.md |
/model [name] | Show or switch model |
/pr | Generate PR title/body and create via gh |
/review | Code review current git diff |
/sessions | List saved sessions |
/settings | Show settings file hierarchy and merged config |
/theme | Cycle through three output themes |
/quit | Quit (alias for /exit) |
Input
| Key | Action |
|---|---|
Enter | Submit input |
Ctrl+J / Shift+Enter | Insert newline (multi-line input) |
Up / Down | Command history (single-line) / cursor navigation (multi-line) |
Tab | Complete / commands or @file references |
Ctrl+R | Reverse history search |
Ctrl+A / Ctrl+E | Move to start / end of line |
Ctrl+W | Delete word backward |
Ctrl+K | Kill to end of line |
Ctrl+U | Kill to start of line |
Ctrl+Y | Yank (paste from kill ring) |
Ctrl+Z | Undo last input change |
Ctrl+Shift+Z | Redo |
Ctrl+L | Clear screen |
Ctrl+O | Toggle verbose mode |
Shift+Tab | Cycle permission mode (default β auto β plan) |
Ctrl+Left/Right | Move by word |
Home / End | Move to start / end of line |
Escape | Cancel generation or close menu |
Escape Escape | Rollback last checkpoint (undo Write/Edit changes) |
Ctrl+C | Cancel input or interrupt running request |
Ctrl+D | Exit (on empty line) |
| Paste | Multi-line paste auto-detected |
Tools
| Tool | Category | Description |
|---|---|---|
| Read | safe | Read files with line numbers, offset/limit support |
| Glob | safe | Fast file pattern matching with head_limit/offset pagination |
| Grep | safe | Regex search with output_mode, head_limit, context lines, type/glob filter, multiline, case-insensitive |
| WebFetch | safe | Fetch URLs, HTML auto-stripped to text (50k char default) |
| WebSearch | safe | DuckDuckGo web search with configurable result limit |
| AskUserQuestion | safe | Prompt user for input during agent execution |
| EnterPlanMode | safe | Switch to read-only mode for exploration |
| ExitPlanMode | safe | Restore previous permission mode |
| TaskCreate | safe | Create a task for progress tracking |
| TaskUpdate | safe | Update task status or add progress note |
| TaskList | safe | List all tasks with statuses |
| TaskGet | safe | Get task details including progress messages |
| Skill | safe | Execute a built-in or plugin skill |
| ToolSearch | safe | Search and load deferred tool schemas on demand |
| TeamCreate | safe | Create an agent team with named members |
| TeamDelete | safe | Delete an agent team |
| SendMessage | safe | Send a message to another agent in a team |
| Write | write | Create/overwrite files (auto-creates parent dirs) |
| Edit | write | Exact string replacement with uniqueness check |
| Bash | dangerous | Execute shell commands (120s timeout, 10MB buffer, 500-line truncation) |
| Agent | dangerous | Spawn sub-agents with optional worktree isolation and background execution |
Permission modes:
defaultβ Safe tools auto-allowed, dangerous/write tools prompt Y/n/aautoβ All tools auto-allowed (no prompts), with deny rule enforcementplanβ Safe tools allowed, dangerous/write silently denied
Allow/Deny rules match Bash commands with glob patterns:
clio --allow "npm *" --allow "git status" --deny "rm -rf *"
Custom Agents
Define reusable agent configurations in .clio/agents/:
<!-- .clio/agents/reviewer.md -->
---
tools: Read, Grep, Glob
model: claude-sonnet-4-20250514
max_iterations: 10
---
You are a code reviewer. Analyze the codebase for bugs, security issues, and style problems.
Use via the Agent tool with subagent_type: "reviewer".
MCP Servers
Configure Model Context Protocol servers in settings.json:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-filesystem"]
}
}
}
MCP tools appear with mcp__<server>__<tool> prefix and are automatically discovered at startup.
Hooks
Configure in settings.json to run shell commands before/after tool execution:
{
"hooks": {
"pre": [
{ "command": "./validate.sh", "tools": ["Write", "Edit"], "timeout": 5000 }
],
"post": [
{ "command": "echo done >> /tmp/clio.log" }
]
}
}
- Pre-hooks: Non-zero exit blocks tool execution
- Post-hooks: Non-zero exit logged as warning, doesn't block
- Environment:
CLIO_TOOL_NAME,CLIO_TOOL_INPUT(JSON),CLIO_HOOK_PHASE - Scope:
toolsarray limits which tools trigger the hook (empty = all)
Connection Modes
# Direct Anthropic API (default)
export CLIO_API_KEY=sk-ant-xxx
clio
# OpenAI-compatible endpoint
clio --api-url https://my-proxy.com --api-key sk-xxx --api-format openai
# Custom gateway
clio --api-url http://localhost:3000 --api-key sk-xxx
# Codex Proxy β use OpenAI Codex models via local relay
# See https://github.com/icebear0828/codex-proxy
clio --api-url http://localhost:8080/v1 --api-key <your-dashboard-key> --api-format openai --model codex
Sessions
Conversations auto-save to ~/.clio/sessions/{id}.json after each turn.
# List recent sessions
clio # then type /sessions
# Resume a session
clio --resume a1b2c3d4
# Fork from existing session
clio --fork-session a1b2c3d4
Project Structure
src/
βββ index.ts Entry point, REPL, command routing (17 slash commands)
βββ types.ts Shared TypeScript types
βββ core/
β βββ agent.ts Core agent loop with prompt caching + model-aware context
β βββ client.ts SSE streaming client (Anthropic + OpenAI format)
β βββ compact.ts Conversation summarization via API
β βββ context.ts System prompt (environment, git, CLAUDE.md upward traversal)
β βββ permissions.ts Permission system (3 modes, allow/deny rules, auto classifier)
β βββ pricing.ts Per-model USD cost estimation
β βββ session.ts Session persistence + fork (~/.clio/sessions/)
β βββ settings.ts 4-level settings hierarchy + merge
β βββ system-prompt.ts Section-based system prompt assembly (static + dynamic)
β βββ section-cache.ts Session-level section caching for system prompt
β βββ billing.ts Billing header generation (x-anthropic-billing-header)
β βββ prompts.ts Prompt templates
β βββ normalize.ts Message normalization (tool pairing, image/doc management)
β βββ adaptive-thinking.ts Dynamic thinking budget adjustment
β βββ sandbox.ts Sandboxing (path/env/network/resource restrictions)
β βββ llm-classifier.ts Two-stage auto classifier (pattern + LLM Haiku)
βββ tools/
β βββ index.ts 21 tool definitions + local execution + truncation
β βββ checkpoint.ts File snapshot + rollback for Write/Edit
β βββ hooks.ts Pre/post tool execution hooks
β βββ mcp.ts MCP client (JSON-RPC 2.0 over stdio)
β βββ lsp.ts LSP client/manager (Content-Length framing, diagnostics)
β βββ subagent.ts Sub-agent execution with iteration limit
β βββ tasks.ts Task store for progress tracking
β βββ teams.ts Agent teams (TeamCreate/Delete/SendMessage)
β βββ worktree.ts Git worktree create/cleanup for isolated agents
βββ ui/
β βββ render.ts ANSI colors, spinner, diff display, tool-specific rendering
β βββ input.ts Raw-mode terminal input (history, paste, tab, undo/redo)
β βββ markdown.ts Streaming markdown β ANSI renderer
β βββ highlight.ts Syntax highlighting (10 languages)
β βββ statusbar.ts Configurable bottom status bar
β βββ image.ts Image file detection + base64 encoding
β βββ keybindings.ts Customizable keyboard shortcuts
β βββ file-completions.ts @file Tab completion (fast-glob scan)
βββ plugins/
β βββ types.ts Plugin type definitions
β βββ manifest.ts plugin.json schema and validation
β βββ loader.ts Plugin discovery and loading
β βββ index.ts Plugin system entry point
βββ skills/
β βββ index.ts Skills system entry point
β βββ loader.ts Skill discovery and loading
β βββ builtins/index.ts Built-in skill definitions
βββ commands/
βββ git-commands.ts /commit, /pr, /review implementations
βββ doctor.ts /doctor system health checks
βββ init.ts CLAUDE.md generation from project scan
βββ custom-agents.ts .clio/agents/*.md loader with front-matter parsing
Benchmark
See A/B Benchmark: Clio vs Claude Code for a detailed comparison of latency, token usage, cache efficiency, and correctness across 5 task types.
License
MIT
