LatentCodeReference
CLI reference
Every latentcode command and flag. Run latentcode with no command to open the TUI; add a command to script it, manage configuration or inspect state.
Commands
| Command | What it does |
|---|---|
| latentcode [project] | Start the TUI in the current directory, or in project. |
| latentcode run [message..] | Send one message and print the result, without the TUI. |
| latentcode config | Show or change the gateway connection: URL, API key, default model. |
| latentcode models [provider] | List the models you can use. |
| latentcode agent create | list | Create a custom agent, or list agents. |
| latentcode mcp add | list | auth | logout | debug | Manage MCP servers and their OAuth logins. |
| latentcode session list | delete | List or delete saved sessions. |
| latentcode export [sessionID] | Print a session as JSON. |
| latentcode stats | Show token usage and cost. |
| latentcode pr <number> | Check out a GitHub pull request, then start LatentCode on it. |
| latentcode plugin <module> | Install a plugin and add it to your config. Alias plug. |
| latentcode attach <url> | Open the TUI against a running LatentCode server. |
| latentcode serve | Start a headless LatentCode server. |
| latentcode acp | Start an Agent Client Protocol server on stdin/stdout, for editors that speak ACP. |
| latentcode db path | Print where the local sessions database is. |
| latentcode debug … | Troubleshooting tools. See below. |
| latentcode upgrade [target] | Update LatentCode. |
| latentcode uninstall | Remove LatentCode and its files. |
| latentcode completion | Print a shell completion script. |
Global flags
These work with every command.
| Flag | Description |
|---|---|
| -h, --help | Show help for the command. |
| -v, --version | Print the version. |
| --print-logs | Write logs to stderr as well as to the log file. |
| --log-level <level> | DEBUG, INFO, WARN or ERROR. Default INFO. |
| --pure | Run without external plugins. |
latentcode [project]
Starts the TUI. project is the directory to work in; the default is the current directory.
latentcode # new session in the current directory
latentcode ~/src/api # new session in another directory
latentcode -c # continue the most recent session
latentcode -s ses_abc123 --fork # branch off an existing session
latentcode --prompt "explain the build system"| Flag | Description |
|---|---|
| -m, --model <provider/model> | Model for the session, for example latentrouter/bedrock-anthropic/anthropic/claude-sonnet-5. See Models. |
| --agent <name> | Agent to start with, for example plan. |
| -c, --continue | Continue the most recent session. |
| -s, --session <id> | Continue the session with this ID. |
| --fork | Continue in a copy of the session, leaving the original untouched. Needs --continue or --session. |
| --prompt <text> | Submit this prompt when the TUI opens. Text piped on stdin is added in front of it. |
| --mini | Start the minimal interface instead of the full-screen TUI: the same split-footer prompt as run --interactive, with output printed into your normal terminal scrollback. |
| --no-replay | With --mini: don't replay earlier messages on resume or after a resize. |
| --replay-limit <n> | With --mini: replay only the newest n messages. |
| --fusion | Turn on the Fusion harness for this session. |
| --sidekick-model <provider/model> | Fusion sidekick model. Implies --fusion. |
latentcode run
Sends one message, prints the agent's answer and exits when the session goes idle. Use it in scripts and CI.
latentcode run "summarize what changed in the last commit"
git diff | latentcode run "review this diff"
latentcode run -f src/app.ts -f README.md "does the README match the code?"
latentcode run --format json "list the TODOs in src/" > events.jsonl
latentcode run --command review main # run a slash command with arguments| Flag | Description |
|---|---|
| message.. | The message. Words are joined with spaces. Text piped on stdin is sent too. |
| --command <name> | Run a slash command instead of a plain message; message becomes its arguments. |
| -c, --continue | Continue the most recent session. |
| -s, --session <id> | Continue the session with this ID. |
| --fork | Fork the session before continuing. Needs --continue or --session. |
| -m, --model <provider/model> | Model to use. |
| --agent <name> | Agent to use. |
| --effort <level> | Reasoning effort, for example low, high or max. With --model, the run stops with an error if that model doesn't offer the level. |
| -f, --file <path> | Attach a file or directory. Repeat for more. |
| --title [text] | Title for a new session. With no value, the first 50 characters of the message. |
| --format <default|json> | json prints one JSON event per line, each with type, timestamp and sessionID. Types: step_start, text, tool_use, step_finish, error, and reasoning with --thinking. |
| --thinking | Print the model's reasoning. On by default with --interactive. |
| -i, --interactive | Keep the session open in a split-footer prompt instead of exiting after one answer. Needs a terminal. |
| --replay-limit <n> | With --interactive: replay only the newest n messages on resume. |
| --no-replay | With --interactive: don't replay history on resume or after a resize. |
| --auto, --dangerously-skip-permissions | Approve every permission request that isn't explicitly denied. Has no effect with --interactive. |
| --dir <path> | Directory to run in. With --attach, a path on the server. |
| --attach <url> | Send the message to a running server (see serve) instead of starting one. |
| -p, --password / -u, --username | Basic-auth credentials for --attach. Default to LATENTCODE_SERVER_PASSWORD and LATENTCODE_SERVER_USERNAME (or latentcode). |
| --port <n> | Port for the local server. Random by default. |
| --org <id|name> | LatentStack organization for this run only. "" uses your default organization. |
| --team <id|name> | LatentStack team within the organization, for this run only. "" uses no team. |
run rejects any action that would ask and prints permission requested: … auto-rejecting. The agent also can't ask you questions or switch into plan mode. Allow what the task needs in your permission config, or pass --auto in a sandbox you trust.Press Ctrl+C once to cancel the run cleanly (exit code 130); press it again to exit at once. The exit code is 1 if the request fails.
latentcode config
Manages the connection to your LatentStack gateway. Values are written to your global config file, ~/.config/latentcode/latentcode.jsonc.
| Command | What it does |
|---|---|
| config · config show | Print the connection: config file, gateway URL, masked API key, default model, imported models. |
| config set api-key <key> | Save your API key, import the models your tier allows, and fix the default model if it isn't among them. |
| config set base-url <url> | Save the gateway URL. It should end in /v1; you get a warning if it doesn't. |
| config set default-model <model> | Set the model new sessions use. The latentrouter/ prefix is added if you leave it out. |
| config get <field> | Print api-key, base-url or default-model as plain text. Prints nothing if unset. |
| config models [--refresh] | List imported models (● marks the default). --refresh re-imports them from the gateway. |
| config clear <field> | api-key, base-url, default-model, models, or all to remove the whole connection. |
latentcode models
latentcode modelsFetches the current model list for your organization and team, then prints one provider/model ID per line. If the gateway can't be reached, it prints a warning and the last known list.
| Flag | Description |
|---|---|
| provider | Only list this provider's models, for example latentrouter. |
| --verbose | Print each model's metadata as JSON. |
| --refresh | Refresh the cached model catalog first. |
| --org, --team | Scope for this command only, as for run. |
latentcode agent
| Command | What it does |
|---|---|
| agent create | Describe what you want; a model writes the agent's prompt and saves it as a Markdown file. See Create an agent. |
| agent list | List every agent with its mode and resolved permission rules. |
| Flag | Description |
|---|---|
| --path <dir> | Write the agent to <dir>/agents/ instead of asking. |
| --description <text> | What the agent should do. |
| --mode <all|primary|subagent> | How the agent can be used. |
| --permissions <list>, --tools | Comma-separated permissions to allow; the rest are denied. Pass "" to allow all. |
| -m, --model <provider/model> | Model that generates the agent. |
With all four of --path, --description, --mode and --permissions, it runs without prompts and prints the new file's path.
latentcode mcp
| Command | What it does |
|---|---|
| mcp add [name] | Add a server interactively, or directly with flags (below). |
| mcp list · mcp ls | List servers and whether each is connected, disabled, failed or needs authentication. |
| mcp auth [name] | Log in to an OAuth server. Without a name, pick from a list. |
| mcp auth list | List OAuth-capable servers and their login status. |
| mcp logout [name] | Remove stored OAuth credentials. |
| mcp debug <name> | Diagnose a server's OAuth connection. |
latentcode mcp add docs --url https://example.com/mcp --header "Authorization=Bearer $TOKEN"
latentcode mcp add files --env ROOT=/srv -- npx -y @modelcontextprotocol/server-filesystem /srvWith a name, give either --url (remote) or a command after -- (local). --header only applies to remote servers and --env only to local ones; both take KEY=VALUE and repeat. Servers added this way go in your global config. See MCP servers.
latentcode session, export and stats
session list
| Flag | Description |
|---|---|
| -n, --max-count <n> | Only the N most recent sessions. |
| --format <table|json> | Default table, shown in a pager when output is a terminal. |
export [sessionID]
Prints the session and all its messages as JSON on stdout. Without an ID, you pick a session from a list. --sanitize redacts transcript text and file contents so you can share the structure.
latentcode export ses_abc123 ,>, session.jsonstats
| Flag | Description |
|---|---|
| --days <n> | Only the last N days. Default: all time. |
| --tools <n> | How many tools to list. Default: all. |
| --models [n] | Show per-model statistics, optionally only the top N. |
| --project <path> | Filter by project. "" means the current project. |
| --session <id> | One session, including what its subagents spent. Needs the gateway. |
| --org, --team | Scope for this command only. |
latentcode pr
latentcode pr 128Runs gh pr checkout 128 into a local branch named pr/128 (replacing it if it exists), adds the fork as a remote for pull requests from forks, then starts the TUI. Needs the GitHub CLI, logged in, and must be run inside a git repository.
latentcode plugin
latentcode plugin my-plugin --global| Flag | Description |
|---|---|
| module | npm package name. |
| -g, --global | Add it to your global config instead of the project's. |
| -f, --force | Replace a version that's already installed. |
serve, attach and acp
latentcode serve runs LatentCode as a headless HTTP server. attach opens the TUI against it, and run --attach sends it one message.
export LATENTCODE_SERVER_PASSWORD=choose-a-password
latentcode serve --port 4096
# in another terminal
latentcode attach http://localhost:4096| Flag | Description |
|---|---|
| --port <n> | Port. Default 0, a free port. |
| --hostname <host> | Interface. Default 127.0.0.1. |
LATENTCODE_SERVER_PASSWORD the server has no authentication and prints a warning. Set it before binding to anything other than localhost.attach <url> takes --dir, -c/--continue, -s/--session, --fork, -p/--password, -u/--username and --mini, with the same meaning as above. acp takes --port, --hostname and --cwd.
latentcode debug
| Command | What it shows |
|---|---|
| debug config | The fully merged configuration LatentCode is using. |
| debug paths | Where config, data, logs, cache and state live. |
| debug info | Version, OS, terminal and loaded plugins. Include it in bug reports. |
| debug agent <name> | One agent's resolved configuration. |
| debug skill | Every skill LatentCode found. |
latentcode db
Sessions and messages are stored in a local database. latentcode db path prints where it is, for example so you can back it up.
upgrade and uninstall
upgrade [target]
Downloads the latest version, or target (for example 0.1.48), from the LatentStack deployment you're connected to.
uninstall
Removes LatentCode's data, cache, config and state directories and, for a script install, the binary and the PATH line the installer added. It lists everything first and asks to confirm.
| Flag | Description |
|---|---|
| -c, --keep-config | Keep your configuration. |
| -d, --keep-data | Keep sessions and snapshots. |
| --dry-run | Show what would be removed and stop. |
| -f, --force | Don't ask for confirmation. |
Other commands
latentcode completion prints a shell completion script to add to your shell's startup file, for example latentcode completion >> ~/.bashrc.