CLI Reference

Every agentty subcommand and flag.

agentty is one binary with a handful of subcommands and flags.

Running

agentty                                # run in the current directory
agentty -w ~/code/project              # run against another workspace
agentty -m claude-opus-4-5             # pick a model for the session
agentty --provider openai -m gpt-4o    # run against a different backend
agentty --provider kimi                # sign in with Kimi (no API key)
agentty --provider deepseek -m deepseek-v4-pro   # DeepSeek (DEEPSEEK_API_KEY)
agentty --provider ollama              # local model, no key, no cloud
agentty -k sk-ant-…                     # single-session key, never written to disk
agentty --sandbox on                   # require an OS sandbox for bash/diagnostics

Subcommands

CommandWhat it does
agenttyStart an interactive thread in the workspace.
agentty loginAuthenticate non-interactively (useful over SSH).
agentty logoutClear stored credentials.
agentty statusPrint which auth source will be used.
agentty airgap user@hostRun the agent on a remote host through an SSH SOCKS tunnel.
agentty acpRun headless as an Agent Client Protocol agent for Zed (JSON-RPC over stdio).
agentty run [prompt]Run one prompt with tools and print only the answer. For scripts and CI; see below.
agentty mcp-serveServe agentty's native tools over MCP (stdio). Point any MCP client at it.
agentty mcp-login <server>Authorize an OAuth-gated MCP server from mcp.json (OAuth 2.1 + PKCE via your browser).
agentty mcp-logout <server>Remove a stored MCP server token.
agentty mcp-statusList configured MCP servers and their authorization state.
agentty plugin add|list|remove|approveManage plugins — a plugin is an MCP server (any language). e.g. agentty plugin add today --python today.py, --uvx pkg, --npx pkg, --http <url>, or -- cmd args; --project targets the repo config. Plugins never run until approved.
agentty hooks [list]Show configured lifecycle hooks + approval state. agentty hooks approve inspects and approves the active hooks file (hooks never run unapproved; any change re-gates).
agentty skillsList discovered Agent Skills with spec-lint diagnostics (exit 1 on warnings — CI-friendly).
agentty diagnosticsCollect a redacted bug-report bundle (build info, provider, log tail) to ~/.agentty/logs/agentty-diagnostics.txt. See Logging.
agentty configEvery folder agentty reads or writes, where it is, and how big. agentty config <name> (e.g. threads, mcp) shows one in detail. See Storage.
agentty config envEvery storage variable and its current value.
agentty config move <dir> <path>Move a folder's data (refuses while agentty runs, verifies the copy), then print the export line to add. default moves it back.
agentty config doctorCheck every folder is usable, secrets are private, and storage variables are valid. Exit 1 if something needs fixing.
agentty config clean [--yes]List files older versions left behind; --yes deletes them.
agentty rag-bench [dir]Benchmark search_docs retrieval on your own corpus — recall@k / MRR / nDCG per pipeline stage. Defaults to the auto-discovered docs folder; pass a directory to override.
agentty updateUpdate agentty in place to the latest release. --check reports whether an update is available without installing it.
agentty --versionPrint agentty <version> and exit.
agentty --helpPrint usage and exit.

agentty run

Runs one prompt through the agent loop (tools, sandbox, no UI) and prints the answer to stdout. Errors go to stderr, so stdout is safe to capture. When a run fails, stderr ends with one agentty run: <status>: <reason> line saying why.

agentty run "add a --dry-run flag to the cli"
git diff | agentty run "review this"          # piped input is added to the prompt
agentty run --agent reviewer -o review.md "review src/"
agentty run --json --timeout 10m --max-turns 40 "fix the failing test"
agentty run --read-only --no-network "review this repo for secrets"   # safe on untrusted code
agentty run --save "plan the migration" && agentty run --resume last "now do step 1"
FlagEffect
--agent <type>Role: general (default), explorer, reviewer, tester, coder, or one of your own subagents.
--jsonPrint one JSON object: status, result, error, model, turns, tool_calls, tool_errors, usage (tokens, plus last_input_tokens and context_window), duration_ms.
-o, --output <file>Write the answer (or the JSON) to a file instead of stdout.
--max-turns <n>Stop after n model turns (default 80, or 32 for read-only roles).
--timeout <d>Stop after 90, 90s, 5m or 1h (default 15m). A running tool is killed when time is up.
--effort <level>Let the model think: low, medium, high, xhigh, max or auto. Clamped to what the model supports. Off by default.
--read-onlyOnly tools that read. Writes, commands and network tools are hidden from the model and refused if it asks anyway.
--no-networkCommands run with no network at all (an empty network namespace), and network tools are refused. Needs the claybin sandbox; without it the run won't start.
--saveSave the conversation as a thread. The id is in --json output and in -v.
--resume <id|last>Continue a saved thread with a new prompt. last is the newest. Saves the result back to the same thread.
-v, --verboseStats on stderr at the end, including how full the context window got.
--events jsonlOne JSON line per event on stderr (see below).

Ctrl-C or SIGTERM stops the run and kills the tool it's running; a second Ctrl-C exits at once.

Events

With --events jsonl stderr gets one JSON object per line while the run goes, and stdout still gets only the answer:

{"ev":"turn","turn":1,"seq":0}
{"ev":"reasoning","turn":1,"text":"the test fails because…","seq":1}
{"ev":"tool","tool":"read","ms":3,"ok":true,"args_sha":"1a2b3c4d","seq":2}
{"ev":"text","turn":2,"text":"Fixed it by…","seq":3}

reasoning lines appear when the provider streams the model's thinking. Models that reason on their own (deepseek-r1 and similar, which send reasoning_content) show it without any flag; for Claude add --effort so it thinks at all. Text is batched per paragraph, so join the fields of one kind in order to get the whole thing.

agentty run --effort high --events jsonl "fix the flaky test" 2> events.jsonl
jq -r 'select(.ev=="reasoning") | .text' events.jsonl
Exit codeMeaning
0Finished with an answer.
1The agent failed or ran out of turns. Any partial answer is still printed.
2Bad usage (unknown flag, bad value, no prompt).
3Provider or auth problem.
4--resume found no such thread.
5The model's context window filled up. stderr says how big the window was and how big the last prompt got.
124Hit --timeout.
130 / 143Stopped by Ctrl-C / SIGTERM.

Command palette

Inside a thread there are no typed /command literals — press ^K (or / on an empty composer) to open a fuzzy command palette. The fixed command set:

CommandWhat it does
New threadStart a fresh conversation.
Compact contextReplace history with a structured summary to reclaim the context window. Runs on the cheapest capable model on the active provider, not the flagship you're chatting with, so a compaction costs a fraction of a normal turn.
Compaction depthCycle how full the context window gets before agentty auto-compacts in the background: 75% Aggressive → 90% Balanced → 95% Deep. Higher rides deeper into the window before summarizing — useful on a 1M-context model (see Providers). Persists across restarts.
Review changesOpen the diff review pane (also ^R).
Accept all / Reject all changesApply or discard every pending hunk.
Rewind to checkpointJump to an earlier turn's worktree snapshot via a diff-preview picker (git repo + idle session; see Checkpoints).
Cycle profileWrite → Ask → Minimal (also S-Tab).
Open model picker / Switch providerChange the active model (^/) or backend (^P).
Open threads / Open planBrowse saved conversations (^J) or view the todo plan (^T).
Run code blockRun a fenced block from the last reply (^G).
Login / QuitSign in, or exit agentty.

Options

These mirror agentty --help exactly.

FlagEffect
-k, --key <key>API-key override for this session; never written to disk.
-m, --model <id>Model id for the session (e.g. claude-opus-4-5).
--provider <p>LLM backend: anthropic (default) or an OpenAI-compatible one — openai · chatgpt · copilot · kimi · deepseek · gemini · xai · mistral · groq · openrouter · together · cerebras · fireworks · ollama, a raw host:port, or a full URL https://host/path for servers with a custom path prefix. Persisted like -m; switch live with ^P. See Providers & Models.
-p, --profile <mode>ACP permission tier (Zed shows the prompts): ask (default) · minimal (also prompt reads) · write (never prompts — fully autonomous).
-w, --workspace <dir>Sandbox filesystem tools to this directory (default: cwd). Tools refuse paths outside it. Pass --workspace / to disable the gate.
--sandbox <mode>Wrap bash/diagnostics in an OS-native sandbox. auto (default) · on (require a backend) · off (disable).
--log-file <path>Write the diagnostic log here instead of ~/.agentty/logs/agentty.log. What gets captured is AGENTTY_LOG (default: warnings and errors). See Logging.
--events jsonlHeadless run only: one JSON object per line on stderr while the run goes: turn, reasoning and text as the model writes them, and tool per tool call ({"ev":"tool","seq":3,"tool":"read","ms":12,"ok":true,"args_sha":"a3f1c09d"}). stdout keeps the answer, so a script can capture both. args_sha is a hash, not the arguments: it answers "were these two calls identical" without putting paths or command lines in your logs. See Events.
-V, --versionPrint the agentty version and exit.
-h, --helpShow usage and exit.

Air-gap flags

Passed to agentty airgap — see agentty airgap --help.

FlagEffect
--setupCopy credentials to the remote on first run.
--acpPrint a ready-to-paste Zed agent_servers config that tunnels agentty acp over ssh stdio. Flags after it are forwarded to the remote agent. See Zed / ACP.
--remote-agentty <path>Path to agentty on the remote if it isn't on PATH.