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.

Tip
Use 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.

bash
codecli tui [options]
codecli # identical to codecli tui
FlagTypeDefaultDescription
--model MODELstringautoModel to use (e.g. claude-sonnet-4-20250514, gpt-4o)
--agent NAMEstring---Load a saved agent configuration by name
--variant VARIANTstring---Model variant preset (fast, smart, reasoning)
--thinkingbooleanfalseEnable extended thinking / chain-of-thought mode
--continuebooleanfalseResume the most recent session
--session IDstring---Resume a specific session by ID
--resumebooleanfalseAlias for --continue
--title TITLEstring---Set a title for the new session
--add-dir PATHstring---Add a directory to the workspace (repeatable)
--append-system-prompt TEXTstring---Append text to the system prompt
--barebooleanfalseSkip project config and default plugins
--enable-auto-modebooleanfalseEnable automatic tool execution without confirmation
--mainframebooleanfalseLaunch in mainframe mode (multi-terminal control)
--compact-threshold NnumberautoToken threshold for auto-compaction
--preset NAMEstring---Load a preset configuration profile
--remotebooleanfalseConnect to a remote codecli server
--backgroundbooleanfalseRun 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.

bash
codecli chat [options]
echo "Explain this function" | codecli chat
codecli chat --model gpt-4o --raw
FlagTypeDefaultDescription
--model MODELstringautoModel to use
--rawbooleanfalseOutput raw text without formatting
--stream / --no-streambooleantrueStream response tokens in real time
--format FORMATstringtextOutput format: text, json, markdown
--continuebooleanfalseContinue the most recent session
--session IDstring---Resume a specific session
--title TITLEstring---Set session title
--append-system-prompt TEXTstring---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.

bash
codecli run "Explain what this project does"
codecli run --model gpt-4o --format json "List all TODO comments"
cat error.log | codecli run "Diagnose this error"
FlagTypeDefaultDescription
--model MODELstringautoModel to use
--rawbooleanfalseOutput raw text without formatting
--stream / --no-streambooleanfalseStream response (default off for run)
--format FORMATstringtextOutput format: text, json, markdown
--timeout MSnumber120000Timeout in milliseconds
--max-turns NnumberunlimitedMaximum 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.

bash
codecli repl [options]
codecli repl --model deepseek-v3
FlagTypeDefaultDescription
--model MODELstringautoModel to use
--continuebooleanfalseContinue the most recent session
--session IDstring---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.

bash
codecli auth login
codecli auth login --token sk-poly-abc123...
codecli auth login --provider github
FlagTypeDefaultDescription
--token TOKENstring---Authenticate with an API token directly
--provider PROVIDERstringautoOAuth provider: github, google
--no-openbooleanfalsePrint the auth URL instead of opening browser

codecli auth logout

Clear stored authentication credentials.

bash
codecli auth logout

codecli auth list

Show the current authentication status and stored credentials.

bash
codecli auth list

codecli provider add

Add an AI provider with its API key. The provider becomes available for model routing.

bash
codecli provider add openai --api-key sk-...
codecli provider add anthropic --api-key sk-ant-...
codecli provider add ollama --base-url http://localhost:11434
FlagTypeDefaultDescription
--api-key KEYstring---API key for the provider
--base-url URLstring---Custom base URL (for self-hosted providers)
--name NAMEstring---Custom name for this provider instance

codecli provider list

List all configured AI providers and their status.

bash
codecli provider list

codecli provider models

List all available models across configured providers.

bash
codecli provider models
codecli provider models --provider openai
FlagTypeDefaultDescription
--provider NAMEstringallFilter models by provider
--format FORMATstringtableOutput 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.

bash
codecli agent create
codecli agent create --name "code-reviewer" --model claude-sonnet-4-20250514
FlagTypeDefaultDescription
--name NAMEstring---Agent name (required in non-interactive mode)
--model MODELstringautoDefault model for this agent
--system-prompt TEXTstring---System prompt for this agent
--tools LISTstringallComma-separated list of enabled tools
--permission MODEstringaskDefault permission mode: ask, auto, deny

codecli agent list

List all saved agent configurations.

bash
codecli agent list

MCP Commands

Manage Model Context Protocol server connections.

codecli mcp add

Add an MCP server to the configuration. Supports stdio and HTTP (SSE) transports.

bash
codecli mcp add my-server --command "npx -y @some/mcp-server"
codecli mcp add remote-server --url https://example.com/mcp
codecli mcp add filesystem --command "npx @modelcontextprotocol/server-filesystem /path" --env ROOT=/path
FlagTypeDefaultDescription
--command CMDstring---Command to launch the MCP server (stdio transport)
--url URLstring---URL for HTTP/SSE transport
--transport TYPEstringautoTransport type: stdio, http, sse
--env KEY=VALUEstring---Environment variable (repeatable)
--header KEY:VALUEstring---HTTP header for SSE transport (repeatable)
--disabledbooleanfalseAdd the server in disabled state

codecli mcp list

List all configured MCP servers and their connection status.

bash
codecli mcp list

codecli mcp auth

Authenticate with an MCP server that requires OAuth or token-based auth.

bash
codecli mcp auth my-server

codecli mcp logout

Clear authentication credentials for an MCP server.

bash
codecli mcp logout my-server

codecli mcp debug

Run an MCP server in debug mode. Shows all JSON-RPC messages exchanged.

bash
codecli mcp debug my-server

codecli mcp-server

Start codecli itself as an MCP server, exposing 36+ tools to other applications. Supports stdio (default) and HTTP transports.

bash
codecli mcp-server # stdio transport
codecli mcp-server -t http -p 4097 # HTTP transport on port 4097
FlagShortTypeDefaultDescription
--transport-tstringstdioTransport: stdio, http, sse
--port-pnumber4097Port for HTTP transport
--hostname-hstringlocalhostBind hostname
--mdnsbooleanfalseAdvertise 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.

bash
codecli acp
codecli acp --port 4517
codecli acp --stdio
FlagTypeDefaultDescription
--port Nnumber4517TCP port for ACP server
--stdiobooleanfalseUse stdio transport instead of TCP
--hostname HOSTstringlocalhostBind hostname

Session Commands

Manage persistent sessions with history, context, and export capabilities.

codecli session

List all sessions with metadata (title, model, date, turn count).

bash
codecli session
codecli session --limit 20
FlagTypeDefaultDescription
--limit Nnumber50Maximum sessions to list
--format FORMATstringtableOutput format: table, json

codecli export

Export a session to a file. Supports multiple formats for archival or sharing.

bash
codecli export SESSION_ID
codecli export SESSION_ID --format json --output ./session.json
codecli export --latest --format markdown
FlagTypeDefaultDescription
--format FORMATstringjsonOutput format: json, markdown, html, txt
--output PATHstringstdoutOutput file path
--latestbooleanfalseExport the most recent session
--include-tool-outputbooleanfalseInclude full tool call results

codecli import

Import a session from a previously exported file.

bash
codecli import ./session.json

codecli stats

Show usage statistics: total sessions, turns, tokens used, tool calls, and cost breakdown.

bash
codecli stats
codecli stats --since 2026-04-01
codecli stats --by-model
FlagTypeDefaultDescription
--since DATEstring---Show stats since date (ISO 8601)
--by-modelbooleanfalseBreak down usage by model
--by-daybooleanfalseBreak down usage by day
--format FORMATstringtableOutput format: table, json

Advanced Commands

codecli serve

Start codecli as a persistent HTTP/WebSocket server. Other codecli instances can connect to it with --remote.

bash
codecli serve
codecli serve --port 8090 --hostname 0.0.0.0
FlagTypeDefaultDescription
--port Nnumber8090Server port
--hostname HOSTstringlocalhostBind hostname
--mdnsbooleanfalseAdvertise via mDNS/Bonjour for discovery
--auth-token TOKENstring---Require this token for connections

codecli connect

Connect to a running codecli server (started with codecli serve).

bash
codecli connect http://192.168.1.50:8090
codecli connect --mdns # auto-discover via mDNS
FlagTypeDefaultDescription
--auth-token TOKENstring---Auth token for the remote server
--mdnsbooleanfalseAuto-discover servers via mDNS

codecli attach

Attach to a running background codecli process. Useful when codecli was started with --background.

bash
codecli attach
codecli attach PID

codecli secrets

Manage secrets from the Polysystems vault directly in the CLI. Supports listing, getting, setting, and importing secrets.

bash
codecli secrets list
codecli secrets get DATABASE_URL
codecli secrets set API_KEY "sk-abc123"
codecli secrets import .env
FlagTypeDefaultDescription
--vault IDstringdefaultTarget vault ID or name
--format FORMATstringtableOutput format: table, json, env

codecli github

GitHub integration commands for managing repositories, issues, and pull requests.

bash
codecli github issues
codecli github pr list
codecli github pr checkout 123
SubcommandDescription
issuesList and manage repository issues
pr listList pull requests
pr checkout NCheckout a pull request branch
pr createCreate a new pull request
repo clone URLClone a repository

codecli datasets

Manage datasets for RAG (Retrieval-Augmented Generation) and fine-tuning.

bash
codecli datasets list
codecli datasets create --name "api-docs" --source ./docs
codecli datasets search "authentication flow"
FlagTypeDefaultDescription
--name NAMEstring---Dataset name
--source PATHstring---Source directory or file for ingestion
--format FORMATstringjsonlDataset format: jsonl, csv

codecli debug

Start an interactive debugging session. Shows verbose logging, tool execution traces, model request/response payloads, and performance metrics.

bash
codecli debug
codecli debug --verbose --trace-tools
FlagTypeDefaultDescription
--verbosebooleanfalseShow all internal logging
--trace-toolsbooleanfalseLog full tool call parameters and results
--trace-modelbooleanfalseLog raw model API requests and responses
--log-file PATHstring---Write debug logs to file

codecli upgrade

Check for and install the latest version of codecli.

bash
codecli upgrade
codecli upgrade --check # only check, do not install
FlagTypeDefaultDescription
--checkbooleanfalseOnly check for updates, do not install
--forcebooleanfalseForce reinstall even if already up to date
--version VERSIONstringlatestInstall a specific version

codecli uninstall

Remove codecli from the system. Optionally clean up configuration and session data.

bash
codecli uninstall
codecli uninstall --purge # remove all config and session data too
FlagTypeDefaultDescription
--purgebooleanfalseRemove all config files, sessions, and cached data
--yesbooleanfalseSkip confirmation prompt
PreviousContext & CompactionNextTools