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

CommandWhat 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 configShow or change the gateway connection: URL, API key, default model.
latentcode models [provider]List the models you can use.
latentcode agent create | listCreate a custom agent, or list agents.
latentcode mcp add | list | auth | logout | debugManage MCP servers and their OAuth logins.
latentcode session list | deleteList or delete saved sessions.
latentcode export [sessionID]Print a session as JSON.
latentcode statsShow 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 serveStart a headless LatentCode server.
latentcode acpStart an Agent Client Protocol server on stdin/stdout, for editors that speak ACP.
latentcode db pathPrint where the local sessions database is.
latentcode debug …Troubleshooting tools. See below.
latentcode upgrade [target]Update LatentCode.
latentcode uninstallRemove LatentCode and its files.
latentcode completionPrint a shell completion script.

Global flags

These work with every command.

FlagDescription
-h, --helpShow help for the command.
-v, --versionPrint the version.
--print-logsWrite logs to stderr as well as to the log file.
--log-level <level>DEBUG, INFO, WARN or ERROR. Default INFO.
--pureRun without external plugins.

latentcode [project]

Starts the TUI. project is the directory to work in; the default is the current directory.

Bash
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"
FlagDescription
-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, --continueContinue the most recent session.
-s, --session <id>Continue the session with this ID.
--forkContinue 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.
--miniStart 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-replayWith --mini: don't replay earlier messages on resume or after a resize.
--replay-limit <n>With --mini: replay only the newest n messages.
--fusionTurn 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.

Bash
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
FlagDescription
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, --continueContinue the most recent session.
-s, --session <id>Continue the session with this ID.
--forkFork 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.
--thinkingPrint the model's reasoning. On by default with --interactive.
-i, --interactiveKeep 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-replayWith --interactive: don't replay history on resume or after a resize.
--auto, --dangerously-skip-permissionsApprove 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, --usernameBasic-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.
Warning
Permissions without a TUI
Nobody is there to answer approval prompts, so 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.

CommandWhat it does
config · config showPrint 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 models

Fetches 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.

FlagDescription
providerOnly list this provider's models, for example latentrouter.
--verbosePrint each model's metadata as JSON.
--refreshRefresh the cached model catalog first.
--org, --teamScope for this command only, as for run.

latentcode agent

CommandWhat it does
agent createDescribe what you want; a model writes the agent's prompt and saves it as a Markdown file. See Create an agent.
agent listList every agent with its mode and resolved permission rules.
FlagDescription
--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>, --toolsComma-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

CommandWhat it does
mcp add [name]Add a server interactively, or directly with flags (below).
mcp list · mcp lsList 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 listList OAuth-capable servers and their login status.
mcp logout [name]Remove stored OAuth credentials.
mcp debug <name>Diagnose a server's OAuth connection.
Bash
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 /srv

With 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

FlagDescription
-n, --max-count <n>Only the N most recent sessions.
--format <table|json>Default table, shown in a pager when output is a terminal.

session delete <sessionID>

Deletes the session.

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.json

stats

FlagDescription
--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, --teamScope for this command only.

latentcode pr

$latentcode pr 128

Runs 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
FlagDescription
modulenpm package name.
-g, --globalAdd it to your global config instead of the project's.
-f, --forceReplace 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.

Bash
export LATENTCODE_SERVER_PASSWORD=choose-a-password
latentcode serve --port 4096
# in another terminal
latentcode attach http://localhost:4096
FlagDescription
--port <n>Port. Default 0, a free port.
--hostname <host>Interface. Default 127.0.0.1.
Warning
Without 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

CommandWhat it shows
debug configThe fully merged configuration LatentCode is using.
debug pathsWhere config, data, logs, cache and state live.
debug infoVersion, OS, terminal and loaded plugins. Include it in bug reports.
debug agent <name>One agent's resolved configuration.
debug skillEvery 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.

FlagDescription
-c, --keep-configKeep your configuration.
-d, --keep-dataKeep sessions and snapshots.
--dry-runShow what would be removed and stop.
-f, --forceDon'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.