Mermaid
An open-source AI coding assistant with computer use for the terminal. Multi-provider — Ollama (local), Anthropic, Gemini, OpenAI, Groq, OpenRouter, and any OpenAI-compatible endpoint — with native tool calling, subagents, computer-use tools, and a clean TUI.
Features
- Multi-Provider — Ollama (local/cloud), Anthropic Claude, Google Gemini, OpenAI, Groq, OpenRouter, Cerebras, DeepInfra, Together, plus fully-custom OpenAI-compatible endpoints
- Native Tool Calling — read, write, edit, delete, create directories, execute commands, search the web, spawn subagents, and call configured MCP tools
- Computer Use — screenshot, click, type, press keys, scroll, move the mouse, and list windows on supported interactive GUI backends
- Subagents — spawn parallel autonomous agents for independent tasks
- Agent Loop — model calls tools autonomously, sees results, and continues until done
- Image Paste — Ctrl+V to attach images for vision models (X11/Wayland/macOS/Windows)
- Reasoning Levels — seven tiers (
none/minimal/low/medium/high/xhigh/max); cycle with Alt+T or set via/reasoning; persisted per-model - Safety Modes —
read_only/ask/auto/full_access;autois classifier-backed (an LLM vets each borderline action against your intent, auto-running aligned ones and escalating risky ones); cycle live with Shift+Tab or/safety - Inline approvals — in
askmode (andautoescalations) a gated action pauses and prompts inline (1Yes ·2Yes, don't ask again ·3/Esc No); the agent waits for your answer instead of erroring out - Project Instructions — auto-loads
AGENTS.mdandMERMAID.md(MERMAID.md wins on conflict); edits take effect on the next turn - MCP Servers — stdio JSON-RPC client with a built-in registry of 16 popular servers (
mermaid add <name>) - Session Persistence — conversations auto-save and resume with
--continue - Message Queuing — type while the model generates, messages send in order
- Non-Interactive Mode — script with
mermaid run "prompt"for CI/automation
Architecture
Mermaid's runtime is an Elm/MVU pattern: one pure reducer (fn update(State, Msg) -> (State, Vec<Cmd>)), effects as data, structured concurrency per turn. Whole classes of bug the old architecture let slip — duplicate error display, 20-press Ctrl+C during tool execution, stale stream events corrupting a new turn — are statically impossible against the new types.
Read docs/architecture.md for the full tour. The adding a tool and adding a provider recipes are one file each; docs/replay_debugging.md covers record/replay for reproducing bugs.
Get started
No Rust or cargo required — the installer downloads a prebuilt binary for your platform from the latest GitHub Release, verifies its checksum, and puts mermaid on your PATH.
macOS / Linux
|
Windows (PowerShell)
irm https://noahsabaj.github.io/mermaid-cli/install.ps1 | iex
Then run mermaid to start, and mermaid update whenever you want the newest version. (Set MERMAID_INSTALL_DIR to change the install location, or MERMAID_VERSION=vX.Y.Z to pin a specific release.)
Prebuilt binaries (plus .deb/.rpm) are attached to every release; the crates.io release can lag the newest tag.
Local inference requires Ollama (models auto-pull if not found locally). Cloud providers are optional — see Remote Providers below.
First 10 Minutes
Then ask Mermaid to do normal coding-agent work:
- "read the repo and tell me where the test runner lives"
- "find the bug in this failing test and fix it"
- "add this small feature and run the relevant tests"
- "review the current branch for regressions"
Inside the TUI, use /help for grouped commands, /doctor for the current session readiness report, /context to inspect prompt budget and compaction status, /compact [focus] to create a handoff checkpoint, and Esc to interrupt the current agent loop.
Computer Use Dependencies (optional)
For full Linux GUI control via screenshot/click/type tools:
# Linux / X11
# Linux / Wayland
# Screenshot downscaling (optional, for high-res displays)
Computer-use registration is backend-gated: Linux/X11 and Linux/Wayland are the current full-control backends. macOS currently supports screenshot capture through screencapture plus clipboard image paste through pngpaste/osascript; click/type/scroll are not yet ported there. Windows clipboard paste uses PowerShell, but the computer-use backend is not wired yet. See src/providers/tool/computer_use/ for the implementation matrix.
Usage
mermaid add <name> resolves the name through a built-in registry of 16 popular MCP servers (context7, playwright, memory, git, fetch, time, filesystem, notion, slack, postgres, brave-search, supabase, perplexity, docker, sequential-thinking, everything), prompts for any required env vars, validates by spawning the server, and saves it to ~/.config/mermaid/config.toml.
Keyboard Shortcuts
| Key | Action |
|---|---|
| Enter | Send message (or queue while the model is generating) |
| Esc | Stop generation / dismiss command palette or attachment focus |
| Ctrl+C | Quit (auto-saves the session) |
| Alt+T | Cycle reasoning level: None → Minimal → Low → Medium → High → XHigh → Max → None |
| Shift+Tab | Cycle safety mode: read_only → ask → auto → full_access → read_only (session-scoped) |
| Ctrl+V | Paste image or text from clipboard |
| Ctrl+Click | Open image from chat history |
| Drag | Select chat text (highlights; does not copy) |
| Ctrl+Shift+C | Copy the selected chat text to the clipboard |
| Shift+Drag | Native terminal selection (bypasses Mermaid's mouse capture — useful for selecting across the whole window, including the input box and status bar) |
/ |
Open slash-command palette (filter-as-you-type) |
| Tab | In palette: complete highlighted command name |
| Up/Down | Navigate input history; palette and conversation-list navigation |
| Mouse Wheel | Scroll chat |
Slash Commands
Type / to open the command palette (shows all commands with live filter); type /<name> to invoke directly. /help shows the same commands grouped in the TUI.
Everyday:
/doctor— show current model, safety, prompt, instruction, and tool readiness/clear,/save [name],/load [id],/list— manage the conversation/cancel [id]— cancel the active turn or a durable task/handoff [id],/report [id]— write a current-context report or inspect a task report/help(/h),/quit(/q)
Model and context:
/model <name>— switch model; auto-pulls Ollama models if needed/reasoning <level>— set reasoning:none,minimal,low,medium,high,xhigh,max/visible-reasoning [on|off|toggle]— show or hide reasoning blocks in the transcript/usage,/context,/compact [instructions]/model-info <model>
Safety and recovery:
/safety [read_only|ask|auto|full_access](alias/permission) — show or set the session safety mode; Shift+Tab cycles it/approvals,/approve <id>,/deny <id>/checkpoint <path...>,/checkpoints,/restore <id>
Integrations:
/plugins,/cloud-setup
Advanced runtime:
/tasks,/task <id>,/pause <id>,/resume <id>/processes,/logs <id>,/stop <id>,/restart <id>,/open <target>,/ports
Reasoning choices persist per-model: setting /reasoning high on Claude Opus 4.7 and /reasoning low on Ollama is remembered across sessions.
Tools
The model uses these autonomously via native tool calling:
| Tool | Description |
|---|---|
read_file |
Read files (text, PDF, images) |
write_file |
Create or overwrite files (timestamped backup if file exists) |
edit_file |
Targeted text replacement with diff |
delete_file |
Delete files (timestamped backup) |
create_directory |
Create directories |
execute_command |
Run shell commands; background mode registers PID/log/URL metadata for GUI apps and dev servers |
web_search |
Search the web (Ollama Cloud) |
web_fetch |
Fetch URL content as markdown (Ollama Cloud) |
agent |
Spawn autonomous sub-agent for parallel tasks |
screenshot |
Capture the screen (fullscreen, focused window, monitor, region, or window by title) |
list_windows |
List visible window titles (X11-only discovery for window-mode screenshots) |
click |
Click at screen coordinates (auto-screenshot after) |
type_text |
Type text at cursor position (auto-screenshot after) |
press_key |
Press key combos (ctrl+s, alt+tab, etc.) |
scroll |
Scroll up or down |
mouse_move |
Move mouse cursor without clicking |
MCP servers contribute additional tools under the mcp__<server>__<tool> prefix when configured. Web tools are registered only when OLLAMA_API_KEY is set in the environment. Computer-use tools are advertised only in interactive TUI sessions when a usable GUI backend is detected.
Project Instructions
Create an AGENTS.md (the cross-tool open standard) and/or a MERMAID.md (mermaid-specific) at your project root with conventions, tool versions, naming patterns, and run commands. Both are loaded from the nearest matching directory — AGENTS.md first, then MERMAID.md, so MERMAID.md overrides on conflict. They auto-reload when the files change (one stat per turn, no filesystem watcher). The walk stops at the .git root or $HOME.
- --
-
File size is capped at ~10k tokens; oversized content is truncated with a marker so the model knows context was elided.
Runtime And Background Service
The CLI/TUI is the primary Mermaid app. mermaidd is optional advanced infrastructure for durable runtime state, remote attach, and long-running process ownership; normal chat, mermaid run, and mermaid self-test work without the user service.
mermaidd stores durable runtime state in ~/.local/share/mermaid/runtime.sqlite3 and exposes a local Unix-socket JSONL control surface at ~/.local/share/mermaid/mermaidd.sock. The socket is created mode 0600 and the data dir 0700, so only your user can reach it. A localhost TCP listener on 127.0.0.1:39871 is off by default — enable it with MERMAID_DAEMON_ENABLE_TCP=1. Mutating Unix-socket JSON commands require a pairing token; when TCP is enabled, every command (including health) requires a token. Create one with mermaid pair --label <device> and pass it as MERMAID_DAEMON_TOKEN or auth.token.
The CLI can inspect and manage the same store with mermaid tasks, mermaid task <id>, mermaid approvals, mermaid approve <id>, mermaid deny <id>, mermaid tool-runs, mermaid checkpoints, mermaid restore <id>, mermaid plugin list, mermaid plugin install <path-or-github>, mermaid plugin audit <path>, mermaid models, mermaid model-info <model>, mermaid processes, mermaid logs <process>, mermaid stop <process>, mermaid restart <process>, mermaid open <target>, mermaid ports, mermaid pair, and mermaid daemon. Installing a plugin from a Git URL (rather than a local path) requires an explicit full URL and MERMAID_ALLOW_PLUGIN_FETCH=1, since fetching and later running remote plugin code is a privileged operation.
On Linux, install a per-user systemd unit with mermaid daemon install --start. The installer writes ~/.config/systemd/user/mermaidd.service, points ExecStart at the discovered mermaidd binary, reloads systemd's user manager, and optionally enables/starts the service. Use mermaid daemon status, mermaid daemon logs [-f], mermaid daemon restart, mermaid daemon stop, mermaid daemon uninstall, or mermaid daemon print-unit for day-to-day service management. Set MERMAID_DAEMON_BIN=/absolute/path/to/mermaidd before installing if the background-service binary is not next to mermaid or on PATH.
Release builds keep the existing .tar.gz/.zip archives and add Linux .deb/.rpm artifacts for x86_64 and aarch64. The distro packages install mermaid, mermaidd, docs, and a reference systemd user unit at /usr/lib/systemd/user/mermaidd.service; they do not auto-enable or start the daemon.
Configuration
Config file: ~/.config/mermaid/config.toml (Linux) or platform equivalent via directories crate.
Run mermaid init to create a default config. Important fields in the current config schema:
# Last model picked via `--model` — used by bare `mermaid` on next start
= "ollama/qwen3-coder:30b"
[]
= "ollama"
= "qwen3-coder:30b"
= 0.7
= 4096
= "medium" # none | minimal | low | medium | high | xhigh | max
[]
= "localhost"
= 11434
# cloud_api_key = "your-key" # for :cloud models
# num_gpu = 10
# num_thread = 8
# num_ctx = 8192
# numa = false
[]
# Approval policy. Default is "ask": prompt before mutations / shell / network
# actions. "auto" runs an LLM classifier that vets each borderline action
# against your stated intent — aligned actions run automatically, risky ones
# escalate to an approval prompt. "full_access" auto-runs everything (the
# pre-0.8 default); "read_only" blocks all mutations. Change it live with
# Shift+Tab or `/safety <mode>` (session-scoped; this value is the persistent
# default each session starts from).
= "ask"
= true
# Model the "auto" classifier uses to vet actions. Omit to vet with the
# session's active model; set a smaller/faster model to cut latency and cost.
# auto_classifier_model = "anthropic/claude-haiku-4-5"
[]
# Current v0.8 run behavior is controlled by CLI flags:
# mermaid run "prompt" --format json --max-tokens 4096 --no-execute
# These fields remain in the schema for compatibility but are not the
# source of truth for `mermaid run`.
= "text"
= 4096
= false
# Per-model reasoning preferences (remembered across sessions)
[]
= "high"
= "low"
# Optional agent/plugin model profiles. A request for `--model fast` or
# `--model profile:fast` resolves through this table when present.
[]
= "ollama/qwen3-coder:14b"
= "openai/gpt-5"
= "anthropic/claude-opus-4-7"
= "gemini/gemini-3.1-pro-preview"
= "groq/qwen-qwq-32b"
# Remote providers — override env-var name, base URL, or extra headers
[]
# api_key_env = "MY_ANTHROPIC_KEY" # default: ANTHROPIC_API_KEY
[]
# api_key_env = "MY_GOOGLE_KEY" # default: GOOGLE_API_KEY; GEMINI_API_KEY is accepted as a legacy fallback
[]
# api_key_env = "MY_GROQ_KEY" # default: GROQ_API_KEY
# base_url = "https://api.groq.com/openai/v1"
# extra_headers = { "X-Custom-Header" = "value" }
# Custom OpenAI-compatible provider (e.g., self-hosted vLLM)
[]
= "http://192.168.1.42:8000/v1"
= "VLLM_KEY"
= "openai-effort" # openai | openai-effort | openrouter
# default_model = "Qwen/Qwen2.5-Coder-32B-Instruct"
# MCP servers — usually managed via `mermaid add <name>`
[]
= "npx"
= ["-y", "@upstash/context7-mcp"]
System prompt customization is runtime-only and is not saved to config:
Remote Providers
Set the appropriate environment variable (or override via [providers.<name>].api_key_env in config):
| Provider | Env var | Example model |
|---|---|---|
| Anthropic | ANTHROPIC_API_KEY |
anthropic/claude-opus-4-7 |
| Google Gemini | GOOGLE_API_KEY (GEMINI_API_KEY legacy fallback) |
gemini/gemini-3.1-pro-preview |
| OpenAI | OPENAI_API_KEY |
openai/gpt-5 |
| Groq | GROQ_API_KEY |
groq/qwen-qwq-32b |
| OpenRouter | OPENROUTER_API_KEY |
openrouter/anthropic/claude-3.7-sonnet |
| Cerebras | CEREBRAS_API_KEY |
cerebras/gpt-oss-120b |
| DeepInfra | DEEPINFRA_API_KEY |
deepinfra/deepseek-ai/DeepSeek-R1 |
| Together | TOGETHER_API_KEY |
together/deepseek-ai/DeepSeek-R1 |
| Ollama Cloud | OLLAMA_API_KEY |
ollama/kimi-k2-thinking:cloud |
Ollama Cloud models use OLLAMA_API_KEY or cloud_api_key under [ollama]. Web search and web fetch tool registration currently requires OLLAMA_API_KEY in the environment. Use mermaid cloud-setup from your shell to save the config key for cloud models; /cloud-setup in the TUI points back to that shell command.
License
MIT OR Apache-2.0
Built with Ratatui and Ollama. Inspired by Aider and Claude Code.