# clai

> Command-line AI for people and agents: query OpenAI, Anthropic, Google, Mistral, DeepSeek, xAI, Ollama, and OpenRouter from your terminal with unix pipes, profiles, Agent Skills, and MCP tools. Share and rate configs on the clai.chat community hub.

Canonical URL: https://www.clai.chat/

Full site index: https://www.clai.chat/llms.txt

Agents as Unix commands: swap agents like aliases, chain them like pipes.
A clai run reads stdin, answers once, and exits, so each agent can live in
a profile, an alias, a script, or a swarm.

clai is a command-line AI toolkit for people and agents: one Go binary for
OpenAI, Anthropic, Google, Mistral, DeepSeek, xAI, Ollama, and OpenRouter.
Run one-shot queries (`clai q`), manage conversations (`clai chat`),
generate images and videos (`clai photo`, `clai video`), transcribe audio
(`clai audio transcribe`), load Agent Skills (`-s '*'`), and connect MCP
servers. The [community config hub](/hub/) on `clai.chat` is where readers
publish and rate profiles, MCP servers, shell contexts, skills, themes and
prompts. See [Architecture overview](/docs/concepts/architecture/).

A diff on stdin, a review on stdout:

```sh
diff -u internal/client/client.old.go internal/client/client.go \
  | clai -i q "Review this change, two lines: {}"
```

```text
This adds an unbounded busy-retry loop on any error: can spin CPU, hang forever, and hide real failures; also retries non-idempotent requests.
Add max attempts + backoff + context cancellation, and only retry safe/idempotent methods and retryable errors (e.g., temp net errors/5xx), otherwise return err.
```

## Keep every agent session

Tokens are expensive, and the sessions they bought are scattered across
Claude Code, Codex, OpenCode, Gemini CLI, Qwen and Antigravity, each in its
own format. clai reads them all, keeps them safe in one place, and picks any
of them up again on the model you choose:

- `clai chat list` lists the sessions the other agents left on this
  machine, beside clai's own.
- `clai cloud commit --imports` keeps them in your conversation store on
  `clai.chat`, images and all, and on every machine you pull from.
  Conversation sync is $1 per GB a month; see [Pricing](/pricing/).
- `clai chat continue <n>` continues one in clai, on any model you
  configure.

See [Multi-vendor transcripts](/docs/concepts/multi-vendor-transcripts/).

## How clai works

Each example below is a session captured from the CLI: the command, then
what came back.

### Query any vendor from your shell, and pipe into it

`clai q` sends a prompt and piped `stdin` to OpenAI, Anthropic, Google,
Mistral, DeepSeek, xAI, Ollama, or OpenRouter. `-i` replaces `{}` with
`stdin`; `-r` prints raw output for the next pipe; `-cm` switches model for
one run. See [Queries and unix pipes](/docs/guides/queries-and-pipes/).

```sh
rg "ERROR|panic" api.log | clai -i q "Name the first error, one line: {}"
```

```text
sql: database is locked
```

### Keep prompt, model, tools, and skills in one flag

A profile in `~/.config/.clai/profiles/` bundles a system prompt, a default
model, MCP servers, and tool filters under one `-p` flag. Pair it with
`SKILL.md` skills and `shell_context` templates. See
[Profiles and setup](/docs/guides/profiles/).

```sh
clai profiles
```

```text
Name: reviewer
Model: gpt-5.2
Tools: [rg cat file_tree]
First sentence prompt: You are a terse staff engineer.
---
```

### Run builtin tools and MCP servers in the agent loop

`-t` enables builtin tools (`rg`, `cat`, `file_tree`, `find`, `write_file`,
`apply_patch`, `cmd`) and configured MCP servers. Oversized tool output is
truncated, so a single call cannot fill the context window. See
[MCP servers and builtin tools](/docs/guides/mcp-and-tools/).

```sh
clai -t rg q "List every TODO in this repo. Answer with just the file and the TODO text."
```

```text
Call: 'rg', inputs: [ 'pattern': 'TODO','line_number': 'true','hidden': 'true' ]
internal/handler/handler.go:3:// TODO: validate the request body before decoding.
internal/handler/handler.go:6:// TODO: return 404 when the row is missing.

internal/handler/handler.go: // TODO: validate the request body before decoding.
internal/handler/handler.go: // TODO: return 404 when the row is missing.
```

### Continue a conversation, or one another tool started

`-re` replies to the last query; `-dre` continues the conversation bound to
the current directory; `clai chat` lists and resumes threads. A session
started in Claude Code, Codex, OpenCode, Gemini CLI, Qwen, or Antigravity
can be imported and continued on any vendor. See
[Multi-vendor transcripts](/docs/concepts/multi-vendor-transcripts/).

```sh
clai -re q "Show the smallest fix, two lines max."
```

```text
if err := tx.Commit(); err != nil { _ = tx.Rollback(); return err }
```

### Download a config someone published, and rate it

Publish a profile, MCP server, shell context, `SKILL.md` skill, theme, or
prompt to the hub; anyone can read and download it. A signed-in reader rates
a config from one to five stars, and the list ranks by the mean. Nothing
syncs on its own, no key is uploaded, and the hub never runs a config. See
[Community config hub](/docs/guides/community-hub/).

```sh
curl -fsSL 'https://www.clai.chat/hub/<slug>/raw' \
  -o "$(clai confdir)/profiles/reviewer.json"
clai -p reviewer q "One line: what should a caller do when tx.Commit() fails?"
```

```text
Treat transaction outcome unknown; rollback, retry idempotently, reconcile externally.
```

## Two ways to start

Run the open-source `clai` CLI on your machine, or join the community hub at
`clai.chat` to publish and rate configs.

- **Share and rate configs.** The public hub: profiles, MCP servers, shell
  contexts, skills, themes and prompts. Read and download any config without
  an account. [Sign in](/login) with GitHub or Google to publish one or rate
  what you use. Free. See [Pricing](/pricing/) and
  [Share and rate configs](/docs/guides/community-hub/).
- **Run it yourself.** One static Go binary. Install `clai` with Go or Nix,
  set your vendor API key (or point at local Ollama), and keep every config
  and conversation on your own disk.

## Install locally

Install `clai` with Go and run your first query:

```text
go install github.com/baalimago/clai@latest
clai setup
rg "ERROR|panic" api.log | clai -i q "Name the first error, one line: {}"
```

See [Installation](/docs/installation/) and
[Quickstart](/docs/quickstart/) for a full walkthrough, or
[Configuration](/docs/reference/configuration/) for every config file and
environment variable.
