cli-agents
Build agentic apps on top of your users' existing AI subscriptions.
Instead of requiring API keys or managing token costs, cli-agents spawns
the AI CLI tools users already have installed — Claude Code, Codex, or
Gemini CLI — and provides a unified Rust interface for streaming events,
tool calls, cancellation, and structured results. Your app brings the UX;
the user brings their own subscription.
Features
- Single API —
run()works with any supported CLI backend. - Auto-discovery — finds installed CLIs in PATH, nvm, homebrew, etc.
- Streaming events — unified
StreamEventenum for text, thinking, tool calls, errors, and completion across all providers. - Timeouts & guardrails — idle timeout, total timeout, and consecutive tool-failure limits with automatic cancellation.
- MCP support — configure Model Context Protocol servers for all adapters.
- Async / Tokio — fully async with cancellation via
CancellationToken.
Quick start
use ;
use Arc;
async
Installation
As a Rust library
[]
= "0.2"
= { = "1", = ["rt-multi-thread", "macros"] }
As a CLI tool
# Via npm (recommended — prebuilt binaries, no Rust toolchain needed)
# Via cargo
# Or download a binary from GitHub Releases
# https://github.com/skoppisetty/cli-agents-rs/releases
Prerequisites
You need at least one supported AI CLI installed:
| CLI | Install |
|---|---|
| Claude Code | npm install -g @anthropic-ai/claude-code |
| Codex | npm install -g @openai/codex |
| Gemini CLI | npm install -g @google/gemini-cli |
Auto-discovery
Omit cli to auto-discover the first available agent (Claude > Codex > Gemini):
let opts = RunOptions ;
let handle = run;
You can also query what's installed:
use ;
let all = discover_all.await;
for in &all
Configuration
System prompts
let opts = RunOptions ;
MCP servers
use ;
use HashMap;
let mut servers = new;
servers.insert;
let opts = RunOptions ;
Timeouts and safety
let opts = RunOptions ;
Permission bypass
By default, the library does not bypass CLI permission prompts. Set
skip_permissions: true to pass flags like --dangerously-skip-permissions
(Claude) or --dangerously-bypass-approvals-and-sandbox (Codex).
Use with caution — the agent will execute tools without human confirmation.
Provider-specific options
use ;
let opts = RunOptions ;
Cancellation
let handle = run;
let cancel = handle.cancel.clone;
spawn;
let result = handle.result.await.unwrap.unwrap;
// result.success == false when cancelled
Why cli-agents?
AI APIs require API keys and charge per token. Most developers already pay for
Claude Pro, ChatGPT Plus, or Gemini — and those subscriptions come with CLI
tools. cli-agents lets you build desktop apps, dev tools, and automation
that run on the user's existing subscription with zero API cost to you.
This is especially powerful for Tauri desktop apps: your Rust backend spawns the agent, streams events to the frontend, and the user's own subscription handles the AI — no API keys to configure, no billing to manage.
Use cases
Desktop apps (Tauri)
The primary use case. Build rich agentic UIs that leverage whatever AI CLI
the user has installed. RunOptions is serde-compatible, so front ends pass
config as JSON and receive StreamEvents back via Tauri events.
See tauri-example/ for a
complete Tauri integration with streaming and cancellation.
Dev tools and CI
Build custom coding agents, review bots, or CI automation that piggyback on existing CLI installations — no API keys needed.
Multi-agent orchestration
Run multiple agents concurrently or route tasks to different providers based on availability or capability.
StreamEvent variants
| Variant | Description |
|---|---|
TextDelta |
Incremental text output |
ThinkingDelta |
Reasoning / thinking output |
ToolStart |
A tool call has started |
ToolEnd |
A tool call has completed |
TurnEnd |
A full agent turn has completed |
Error |
An error or warning |
Done |
Run completed with final RunResult |
Raw |
Provider-specific event (escape hatch) |
CLI binary
# Summarize a project (auto-discovers installed CLI)
# Point at a codebase (auto-discovers CLI)
# Code review with a system prompt
# Stream events as JSON lines (useful for piping into other tools)
# Verbose mode with Gemini (show tool calls, thinking, and token stats)
# List available CLIs on this system
Platform support
| Platform | Status |
|---|---|
| macOS (ARM64, x64) | Fully tested end-to-end |
| Linux (x64, ARM64) | Compiles and passes unit tests in CI — not yet tested end-to-end. Feedback welcome! |
| Windows (x64) | Compiles and passes unit tests in CI — CLI discovery and process groups use Unix APIs and need platform-specific implementations. Contributions welcome! |
If you run into issues on Linux or Windows, please open an issue. The main platform-specific code is in src/discovery.rs (binary lookup) and src/adapters/mod.rs (process group handling).
Contributing
Contributions are welcome! See CONTRIBUTING.md for details.
License
MIT