Commands Reference
Complete reference for every codecli command. Commands are organized into categories: core interactions, authentication, agent management, MCP integration, session management, and advanced utilities.
codecli COMMAND --help at any time to see inline help for a specific command.Core Commands
These are the primary interaction modes. If no subcommand is given, tui is the default.
codecli tui
Launch the full terminal UI. This is the default command when codecli is run with no subcommand. The TUI provides a rich interactive interface built with Solid.js, including 19 context providers, a kanban board, obsidian vault integration, split-panel management views, and more.
| Flag | Type | Default | Description |
|---|---|---|---|
| --model MODEL | string | auto | Model to use (e.g. claude-sonnet-4-20250514, gpt-4o) |
| --agent NAME | string | --- | Load a saved agent configuration by name |
| --variant VARIANT | string | --- | Model variant preset (fast, smart, reasoning) |
| --thinking | boolean | false | Enable extended thinking / chain-of-thought mode |
| --continue | boolean | false | Resume the most recent session |
| --session ID | string | --- | Resume a specific session by ID |
| --resume | boolean | false | Alias for --continue |
| --title TITLE | string | --- | Set a title for the new session |
| --add-dir PATH | string | --- | Add a directory to the workspace (repeatable) |
| --append-system-prompt TEXT | string | --- | Append text to the system prompt |
| --bare | boolean | false | Skip project config and default plugins |
| --enable-auto-mode | boolean | false | Enable automatic tool execution without confirmation |
| --mainframe | boolean | false | Launch in mainframe mode (multi-terminal control) |
| --compact-threshold N | number | auto | Token threshold for auto-compaction |
| --preset NAME | string | --- | Load a preset configuration profile |
| --remote | boolean | false | Connect to a remote codecli server |
| --background | boolean | false | Run in background / daemon mode |
codecli chat
Start an interactive chat session in the terminal (no TUI). Useful for scripting, pipes, and minimal environments. Reads from stdin if input is piped.
| Flag | Type | Default | Description |
|---|---|---|---|
| --model MODEL | string | auto | Model to use |
| --raw | boolean | false | Output raw text without formatting |
| --stream / --no-stream | boolean | true | Stream response tokens in real time |
| --format FORMAT | string | text | Output format: text, json, markdown |
| --continue | boolean | false | Continue the most recent session |
| --session ID | string | --- | Resume a specific session |
| --title TITLE | string | --- | Set session title |
| --append-system-prompt TEXT | string | --- | Append to system prompt |
codecli run
Execute a single prompt non-interactively. Prints the response and exits. Ideal for scripting, CI pipelines, and batch processing.
| Flag | Type | Default | Description |
|---|---|---|---|
| --model MODEL | string | auto | Model to use |
| --raw | boolean | false | Output raw text without formatting |
| --stream / --no-stream | boolean | false | Stream response (default off for run) |
| --format FORMAT | string | text | Output format: text, json, markdown |
| --timeout MS | number | 120000 | Timeout in milliseconds |
| --max-turns N | number | unlimited | Maximum agent turns before stopping |
codecli repl
Start a Read-Eval-Print Loop with a simpler interface than the TUI. Supports multi-line input with Shift+Enter.
| Flag | Type | Default | Description |
|---|---|---|---|
| --model MODEL | string | auto | Model to use |
| --continue | boolean | false | Continue the most recent session |
| --session ID | string | --- | Resume a specific session |
Auth Commands
Manage authentication credentials for Polysystems and AI providers.
codecli auth login
Authenticate with the Polysystems platform. Opens a browser for OAuth flow or accepts an API token directly.
| Flag | Type | Default | Description |
|---|---|---|---|
| --token TOKEN | string | --- | Authenticate with an API token directly |
| --provider PROVIDER | string | auto | OAuth provider: github, google |
| --no-open | boolean | false | Print the auth URL instead of opening browser |
codecli auth logout
Clear stored authentication credentials.
codecli auth list
Show the current authentication status and stored credentials.
codecli provider add
Add an AI provider with its API key. The provider becomes available for model routing.
| Flag | Type | Default | Description |
|---|---|---|---|
| --api-key KEY | string | --- | API key for the provider |
| --base-url URL | string | --- | Custom base URL (for self-hosted providers) |
| --name NAME | string | --- | Custom name for this provider instance |
codecli provider list
List all configured AI providers and their status.
codecli provider models
List all available models across configured providers.
| Flag | Type | Default | Description |
|---|---|---|---|
| --provider NAME | string | all | Filter models by provider |
| --format FORMAT | string | table | Output format: table, json |
Agent Commands
Manage agent configurations for specialized workflows.
codecli agent create
Create a new agent configuration. Opens an interactive prompt to set the system prompt, model, tools, and permissions.
| Flag | Type | Default | Description |
|---|---|---|---|
| --name NAME | string | --- | Agent name (required in non-interactive mode) |
| --model MODEL | string | auto | Default model for this agent |
| --system-prompt TEXT | string | --- | System prompt for this agent |
| --tools LIST | string | all | Comma-separated list of enabled tools |
| --permission MODE | string | ask | Default permission mode: ask, auto, deny |
codecli agent list
List all saved agent configurations.
MCP Commands
Manage Model Context Protocol server connections.
codecli mcp add
Add an MCP server to the configuration. Supports stdio and HTTP (SSE) transports.
| Flag | Type | Default | Description |
|---|---|---|---|
| --command CMD | string | --- | Command to launch the MCP server (stdio transport) |
| --url URL | string | --- | URL for HTTP/SSE transport |
| --transport TYPE | string | auto | Transport type: stdio, http, sse |
| --env KEY=VALUE | string | --- | Environment variable (repeatable) |
| --header KEY:VALUE | string | --- | HTTP header for SSE transport (repeatable) |
| --disabled | boolean | false | Add the server in disabled state |
codecli mcp list
List all configured MCP servers and their connection status.
codecli mcp auth
Authenticate with an MCP server that requires OAuth or token-based auth.
codecli mcp logout
Clear authentication credentials for an MCP server.
codecli mcp debug
Run an MCP server in debug mode. Shows all JSON-RPC messages exchanged.
codecli mcp-server
Start codecli itself as an MCP server, exposing 36+ tools to other applications. Supports stdio (default) and HTTP transports.
| Flag | Short | Type | Default | Description |
|---|---|---|---|---|
| --transport | -t | string | stdio | Transport: stdio, http, sse |
| --port | -p | number | 4097 | Port for HTTP transport |
| --hostname | -h | string | localhost | Bind hostname |
| --mdns | boolean | false | Advertise via mDNS/Bonjour |
ACP
Agent Communication Protocol for IDE integration.
codecli acp
Start the ACP adapter that enables IDE integration (VS Code, JetBrains, Neovim). The ACP protocol bridges between the IDE and the codecli agent.
| Flag | Type | Default | Description |
|---|---|---|---|
| --port N | number | 4517 | TCP port for ACP server |
| --stdio | boolean | false | Use stdio transport instead of TCP |
| --hostname HOST | string | localhost | Bind hostname |
Session Commands
Manage persistent sessions with history, context, and export capabilities.
codecli session
List all sessions with metadata (title, model, date, turn count).
| Flag | Type | Default | Description |
|---|---|---|---|
| --limit N | number | 50 | Maximum sessions to list |
| --format FORMAT | string | table | Output format: table, json |
codecli export
Export a session to a file. Supports multiple formats for archival or sharing.
| Flag | Type | Default | Description |
|---|---|---|---|
| --format FORMAT | string | json | Output format: json, markdown, html, txt |
| --output PATH | string | stdout | Output file path |
| --latest | boolean | false | Export the most recent session |
| --include-tool-output | boolean | false | Include full tool call results |
codecli import
Import a session from a previously exported file.
codecli stats
Show usage statistics: total sessions, turns, tokens used, tool calls, and cost breakdown.
| Flag | Type | Default | Description |
|---|---|---|---|
| --since DATE | string | --- | Show stats since date (ISO 8601) |
| --by-model | boolean | false | Break down usage by model |
| --by-day | boolean | false | Break down usage by day |
| --format FORMAT | string | table | Output format: table, json |
Advanced Commands
codecli serve
Start codecli as a persistent HTTP/WebSocket server. Other codecli instances can connect to it with --remote.
| Flag | Type | Default | Description |
|---|---|---|---|
| --port N | number | 8090 | Server port |
| --hostname HOST | string | localhost | Bind hostname |
| --mdns | boolean | false | Advertise via mDNS/Bonjour for discovery |
| --auth-token TOKEN | string | --- | Require this token for connections |
codecli connect
Connect to a running codecli server (started with codecli serve).
| Flag | Type | Default | Description |
|---|---|---|---|
| --auth-token TOKEN | string | --- | Auth token for the remote server |
| --mdns | boolean | false | Auto-discover servers via mDNS |
codecli attach
Attach to a running background codecli process. Useful when codecli was started with --background.
codecli secrets
Manage secrets from the Polysystems vault directly in the CLI. Supports listing, getting, setting, and importing secrets.
| Flag | Type | Default | Description |
|---|---|---|---|
| --vault ID | string | default | Target vault ID or name |
| --format FORMAT | string | table | Output format: table, json, env |
codecli github
GitHub integration commands for managing repositories, issues, and pull requests.
| Subcommand | Description |
|---|---|
| issues | List and manage repository issues |
| pr list | List pull requests |
| pr checkout N | Checkout a pull request branch |
| pr create | Create a new pull request |
| repo clone URL | Clone a repository |
codecli datasets
Manage datasets for RAG (Retrieval-Augmented Generation) and fine-tuning.
| Flag | Type | Default | Description |
|---|---|---|---|
| --name NAME | string | --- | Dataset name |
| --source PATH | string | --- | Source directory or file for ingestion |
| --format FORMAT | string | jsonl | Dataset format: jsonl, csv |
codecli debug
Start an interactive debugging session. Shows verbose logging, tool execution traces, model request/response payloads, and performance metrics.
| Flag | Type | Default | Description |
|---|---|---|---|
| --verbose | boolean | false | Show all internal logging |
| --trace-tools | boolean | false | Log full tool call parameters and results |
| --trace-model | boolean | false | Log raw model API requests and responses |
| --log-file PATH | string | --- | Write debug logs to file |
codecli upgrade
Check for and install the latest version of codecli.
| Flag | Type | Default | Description |
|---|---|---|---|
| --check | boolean | false | Only check for updates, do not install |
| --force | boolean | false | Force reinstall even if already up to date |
| --version VERSION | string | latest | Install a specific version |
codecli uninstall
Remove codecli from the system. Optionally clean up configuration and session data.
| Flag | Type | Default | Description |
|---|---|---|---|
| --purge | boolean | false | Remove all config files, sessions, and cached data |
| --yes | boolean | false | Skip confirmation prompt |