TeXRA CLI
The TeXRA CLI brings TeXRA's assistant to the terminal: a local texra command for chatting with it, running long autonomous attempts at a problem, and running programs over your project. It is published to npm as @texra-ai/cli.
Install
Install the CLI globally from npm (requires Node.js 22.22.2 or later in 22.x, or Node.js 24.15 or later):
npm install -g @texra-ai/cliOr with Homebrew on macOS and Linux, which installs Node.js for you if needed:
brew install texra-ai/tap/texraVerify the command:
texra --help
texra version
texra configRun texra with no model connected and the chat still opens, with a Connect a model panel in front: sign in with a ChatGPT or Grok subscription, or add a provider API key. A message typed before you connect is sent as soon as you do.
For a guided first run, use texra setup. It walks you through sign-in (a ChatGPT or Grok subscription, or an API key), checks your environment, and starts your first task:
texra setupWorking from an Overleaf or ShareLaTeX project? Clone it into a directory first, by URL, git URL, or 24-character project id:
texra clone <project> ./projectRunning programs
texra run <program> runs one of the programs over --input files, without a chat: annotate and transcribe for LaTeX, and the Lean programs prove, lean-simplify, blueprint and lean-search. Every program works on the project's files in place and needs at least one --input. Run one from a project directory:
texra run annotate --input paper.tex --instruction "Read as a first-time reader" --printThe run prints its progress on stderr and its reply on stdout: the check's verdict and what the helper agent reported. There is no output file to collect: the program edited the files you passed, so git diff shows the result.
The instruction says what the program should do, for example which point of view annotate reads from. Pass it with --instruction <text> or --instruction-file <file>. When both are set, the file contents are passed first:
texra run annotate --input paper.tex --instruction "Check every derivation in Section 3"
texra run annotate --input paper.tex --instruction-file notes.mdSupported media files passed with --input are attached to the model instead of being read as text. Audio transcription requires a model with native audio support:
texra run transcribe --input recording.m4a --instruction "Write talk.tex" --model google/gemini-4-neon --printYou can combine text and media with repeated --input flags. Pass read-only context files with repeated --context flags: the program reads them and does not change them.
texra run annotate --input appendices.tex --context Draft0.tex --context refs.bibPass multiple inputs with repeated --input flags, a directory, or a glob. Directory inputs expand recursively to .tex files:
texra run annotate --input Draft0.tex --input appendices.tex
texra run annotate --input 'sections/**/*.tex'JSON and NDJSON output carry the run's result: its runId, its canonical outcome, and output.response, the program's reply. To polish or rewrite a document headlessly, give chat the instruction:
texra run chat --instruction "Polish paper.tex for clarity; keep the math. Compile it with latexmk." --printFinal run result objects report their terminal state through outcome and name the run through runId. A texra run result also records the plugins it ran with: plugins lists the installed plugins that loaded when it started or resumed, enabled and trusted (name, source, and for a fetched plugin its ref and pinned commit). The tools a run offered can change between its model requests when a plugin is switched on or off; the run records each change in its history.
NDJSON contract, version 3
Every --output-format ndjson line is one JSON object whose first key is kind, followed by the record's own fields, a ts timestamp, and contract: 3 (the 1.0 contract version):
kind: "progress"carries a session event verbatim, witheventset to the event'stype(run.start,run.activate,run.end,usage,tool.start,run.description,run.removed, and so on) andpayloadholding the remaining fields:- Identity & outcomes: Run events identify their run via
payload.aggregateId(plugin-owned events use aplugin:key instead). Parent edges appear onrun.startaspayload.parent; terminal outcomes appear onrun.endasoutcome. - Spend: Each
usageevent represents one priced model turn, so total run spend is the sum of itsusageevents. - Turns & scripts: Run turns appear as
run.positionevents (turn.begin,turn.end). Tool calls made inside a script carry astageIdmatching the enclosingscriptcard'slogId, which closes with its owntool.end. - Live children (
event: "run.children"): The one synthetic progress event (no underlying session row) reports a parent's active children as{ runId, children }, where each entry carrieschildRunId,identity,agentName, andstatus(running,waiting, orreadybefore first activation). Completed children leave this list and report their outcome onrun.end.
- Identity & outcomes: Run events identify their run via
kind: "agent-result"andkind: "result"carry the run result described above underresult, withrunId.- History records (
history-entry,history-detail) carry the run'soutcome(completed,cancelled,failed, ornullwhen none was recorded) and, separately, whethertexra resumecontinues it (continues).
Authentication
Model calls run on your own provider API keys, or on a provider subscription you already pay for. There is no TeXRA account: everything ships bundled.
Bring your own provider keys. Set the environment variable for the provider you want to use (ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_API_KEY, …), then run the CLI normally:
export ANTHROPIC_API_KEY=sk-…
texra run annotate --input paper.texClaude Max/Team and ChatGPT Pro/Business plans also include monthly API credits that a standard Anthropic or OpenAI API key can spend; see Getting API keys.
A project's .env file is read by every task of that project. A key set only in this terminal (OPENAI_API_KEY=… texra chat) travels with the tasks this terminal starts, wherever they run.
Use a provider subscription. Kimi Code and the GLM Coding Plan are paid through the plan's own key, added like any provider key. A ChatGPT or Grok (xAI) subscription can serve model calls in place of an API key:
texra auth chatgpt login # OpenAI models through your ChatGPT plan
texra auth grok login # Grok models through an xAI subscriptionInside a chat, /login manages the same preferences: its form signs you in or out and sets which subscription serves each provider's models, and /login status prints how each model will be paid for.
CI pipelines. Headless pipelines can't sign in interactively. Store the provider API key as a CI secret and export it in the pipeline environment. With a provider key set, texra run … needs no other credentials.
Subscriptions sign in through texra auth <provider> login:
texra auth chatgpt login # browser sign-in
texra auth chatgpt login --no-browser # print the loopback sign-in URL
texra auth chatgpt status
texra auth chatgpt logout
texra auth grok login --device # device code: approve from a browser on any devicegrok takes the same verbs. --no-browser still uses a local callback server. Open the printed URL in a browser that can reach the terminal session; SSH and container sessions may need callback port forwarding.
ChatGPT sign-in is OpenAI's "Sign in with ChatGPT" for open-source agents, and it is browser-only: OpenAI returns the sign-in to 127.0.0.1 on the machine running TeXRA, and --device signs in through the browser too. On SSH, WSL2 or a container, forward port 1455 from the machine with the browser. On the consent page, allow TeXRA to use your ChatGPT plan; without it, sign-in stops with an error. ChatGPT plan usage is shown in ChatGPT's own settings.
Grok's --device needs no callback at all: the CLI prints a short code and a verification URL. Open the URL in a browser on any device, including your phone, and approve the code. This is the recommended path for Grok on SSH, WSL2, and containers.
Run texra doctor at any time to see which dependencies are detected and which models the CLI can reach with the current credentials.
Interactive chat
texra chat opens an interactive chat in the terminal. It streams reasoning, tool calls, and diffs, and writes to the same run history as the VS Code extension. Running bare texra in a terminal opens this same session. While a run is working, pressing Enter delivers your message at its next model step, while Shift-Tab holds it until the end of the current turn.
Reading the section, then tightening the opener.
- ●read_file(sections/intro.tex)⎿In this paper we present a novel approach to… 41 lines hidden
- ●edit_file(sections/intro.tex)
A texra chat session streams reasoning and tool calls inline, shows diffs as the agent edits, and lists its key hints at the bottom.
texra chat # default model
texra chat --model deepseek/deepseek-flash@high # override the session model and effort
# one headless answer for scripts and CI
texra run chat --input main.tex --instruction "Check the proof of Lemma 2." --printSlash commands inside the session:
/login: sign in and choose which provider subscriptions serve their models (/login statusprints how each model is billed)./approval: set the approval policy and revoke grants given withaon an approval card (/statuslists active grants)./config: open settings and integrations./model: switch to another model from the same provider mid-session (applies immediately and persists on resume)./skills: list available skills and apply one to your next request./resume: restore a stored execution (/resume allcontinues every interrupted task)./rename <title>: rename the focused task./help: list every slash command, including/models,/key,/status,/plan,/plugins,/compact,/fork,/clear, and/exit./tasks: list tasks running in the background service across every project. Picking one attaches to it live: Enter sends a follow-up, approval requests appear inline, and Esc detaches while the task keeps running.
texra chat requires an interactive terminal. For scripts and CI, use texra run <program | chat> with --print or --output-format json|ndjson:
chatgives the assistant one instruction (--instruction,--instruction-file, or both; required) with optional--inputand--contextfiles, and prints its answer.- A program runs over
--inputfiles (required), edits them in place, and prints its reply. A name that is neither a program norchatprints the program names.
Helper agents
For a larger job the assistant hands pieces of the work to helper agents it sets up for each piece, or starts programs, and can fan them out in parallel as a scripted multi-agent workflow:
texra run chat --instruction "Profile scripts/simulate.py, then speed up its hot loops without changing its results" --print- 1●optimize-loopcompleted48s · 6 tool callsoptimized the inner loop in scripts/simulate.py
- 2●regression-testsrunning21s · 2 tool callspytest -q · 17 passed, 3 to go
Helper agents stream below the assistant as numbered rows. Focus any helper agent to view its own transcript.
Focusing a helper agent shows only its own transcript, which persists across sessions and can be resumed where it left off.
Skills
Skills are reusable instruction folders the assistant can apply to a request. Enable Enable skills for agents (texra.skills.enabled) via texra config or Settings → Agents → Skills. List available skills or attach extra folders with --source (-s, repeatable):
texra skills list
texra run annotate --input paper.tex --source ~/my-skillsImported skill folders (.agents, .claude, .codex, .gemini) start disabled by default; toggle them under texra config → Skills or Settings → Agents → Skills (texra.skills.disabledSources). Project skills live in .texra/skills/ and override user skills (--source overrides both). In chat, pick a skill with /skills.
Plugins
TeXRA installs plugins published for Claude Code and Codex. It reads the plugin's own manifest, .claude-plugin/plugin.json or .codex-plugin/plugin.json, and the folders beside it: skills from skills/, commands from commands/, agents from agents/, MCP servers from .mcp.json, plus any of these paths the manifest declares. A plugin can also carry programs for TeXRA in programs/ and a native harness.mjs entry that adds in-process tools, layers, or prompt sections once explicitly trusted at its file digest (loaded from a snapshot of the trusted files). In chat, /plugins add installs a plugin interactively, and the assistant can also list, install, or toggle plugins (always prompting you before trusting, disabling, or removing one) through the plugin_manager tool.
texra plugin install github.com/LionSR/AgenticPublicationProtocol
texra plugin install github.com/<owner>/<repo>@v1.0.0
texra plugin install https://example.org/plugins.git --ref main
texra plugin install ./my-plugin
texra plugin show paper-protocol
texra plugin enable paper-protocol
texra plugin list
texra plugin update
texra plugin disable paper-protocol
texra plugin remove paper-protocolAn installed plugin stays off until you enable it:
- Trust on enable:
texra plugin enableshows what the plugin declares (skills, commands, agents, and each MCP server's command line) and asks you to trust it. Trust covers that version, every file in the plugin folder, and the MCP servers' commands, arguments, and environment values. External binaries a server runs (such asnode) are trusted by path, size, and modification time. If any covered file or setting changes, the plugin stops loading until you re-enable and re-trust it. - Names and unsupported features: A plugin's name uses lowercase letters, digits and single hyphens, at most 32 characters, and cannot be
own, which names the programs an agent writes for itself. Plugins with LSP servers cannot be enabled yet; output styles and apps are not loaded. - Hooks: Claude Code hooks run as processes in the project folder. A
Stophook that blocks (decision: "block", or exit code 2) continues the task for one extra turn using its reason as the next instruction, even undertexra run. The stop after that turn passesstop_hook_active: trueand cannot block again.
Once enabled and trusted, a plugin's components load under its namespace:
- Names: Skills, commands, agents and programs become
<plugin>:<name>, and MCP tools are offered to top-level chat runs asmcp__plugin_<plugin>_<server>__<tool>. - Tool inheritance: The assistant starts a plugin agent by name with the
agenttool. One that liststoolsreceives exactly those. One that omitstoolsreceives the file, shell and web tools and, as a top-level run does, the tools the enabled plugins add, including installed plugins' MCP tools. - Runtime changes: Each MCP server runs as its own process in the plugin folder, with tool calls approved like shell commands. Enabling, disabling, or modifying a plugin takes effect at the next model request in a running conversation; calls to removed tools are refused, while earlier history is preserved.
Fetched plugins are stored in ~/.texra/v1/global-storage/plugins/<name>/, pinned to the resolved commit. texra plugin update re-fetches the branch or tag and pins the new commit. Local folders are used in place without copying, so edits take effect immediately and texra plugin remove only unregisters them (if removing a fetched plugin fails to delete its folder, run texra plugin remove again).
A repository with a marketplace file (.claude-plugin/marketplace.json or .agents/plugins/marketplace.json) and no plugin manifest installs the plugin it lists; if it lists several, pass --plugin <name> (repeatable).
The CLI, VS Code extension, and desktop app share installed plugins and trust decisions. In the extension and desktop app, manage them under Settings → Plugins.
Programs in a plugin
A plugin is also where your own programs live: a folder with a manifest and a programs/ directory is enough. Each programs/<name>.js is one program, started as <plugin>:<name>:
// my-programs/programs/todo-list.js
export const description = 'List the TODO lines of each input file.';
export const uses = ['read_file'];
export default async (args, { inputFiles }) => {
const found = [];
for (const file of inputFiles) {
const { output } = await tools.read_file({ path: file });
for (const line of output.split('\n'))
if (line.includes('TODO')) found.push(file + ': ' + line.trim());
}
return found.join('\n') || 'No TODO lines.';
};mkdir -p my-programs/.claude-plugin
echo '{ "name": "my-programs", "version": "0.1.0" }' > my-programs/.claude-plugin/plugin.json
texra plugin install ./my-programs
texra plugin enable my-programs
texra run my-programs:todo-list --input paper.tex- Header declarations: Each file must begin with
export const description = '...';(single line, at most 300 characters) andexport const uses = ['...'];, in either order. Both must be quoted literals ending in;, with only comments before or between them. TeXRA parses them statically without executing the file; a computed value, template string, or leading statement causes that file to be rejected while the plugin's other programs still load. (usesis named so it never shadows thetoolsobject inside the sandbox.) - Program body: The default export is
async (args, launch) => result, wherelaunchcarriesinstruction,inputFiles,contextFiles, andmediaFiles, and the return value becomes the program's output. It runs in the same QuickJS sandbox as a model-written script—no filesystem, network, timers, orDate.now(), only the tools named inuses(tools.<name>(...), plusagent(...)andprogram(...)when listed). It may alsoimportbuilt-in modules and programs from enabled plugins. - Naming: The filename is the program name (lowercase letters, digits, and hyphens). TeXRA does not follow symbolic links inside
programs/. - Trust and approvals:
texra plugin enablelists each program with its description, declared tools, and any rejected files. A program can only invoke the tools inuses, and unlike built-in programs, those tools are withheld while their owning plugin is off. Individual calls that require approval (shell commands, file edits) follow your approval policy, while agents and programs launched by a trusted plugin program are not re-prompted one by one. Editing any file in the plugin withdraws all of its programs until you re-enable and re-trust it. - Discovery:
texra plugin listand Settings → Plugins list a plugin's programs;texra run <plugin>:<name>starts one directly, and the assistant sees it alongside the built-in programs.
Programs an agent writes for itself
The assistant can also author reusable project programs. Any file it writes at programs/<name>.js in the project's memory folder becomes available as own:<name> on the next step—no restart or installation needed—and persists across conversations in the same project. It uses the same header declarations and default export as a plugin program, and can also be started directly with texra run own:<name> --input paper.tex.
- Storage: These files live in project memory alongside saved notes, not in your repository, so cloning a repo never brings them in. The Memory tab's Open this project's memory folder reveals the files; delete one to remove its program. Self-written programs load even when memory is switched off (that setting controls only whether a chat gets the memory folders and their indexes).
- Trust and approvals: Self-written programs run in the same sandbox with only the tools listed in
uses, subject to plugin switches and your approval policy. Unlike plugin programs, every helper agent or nested program they start still prompts for approval (and under--approval-policy never, tools that require approval are withheld). No plugin may use the reserved nameown. - Listing: The first 20 self-written programs are listed to the assistant by name; any beyond that can still be invoked by name. Malformed files are rejected individually without blocking the rest.
Shell completion
TeXRA can print completion scripts for Bash, Zsh, and Fish:
texra completion bash >> ~/.bashrc
texra completion zsh > "${fpath[1]}/_texra"
texra completion fish > ~/.config/fish/completions/texra.fishRestart the shell, or source the file you updated. Completion includes subcommands, flags, enum values such as --output-format text|json|ndjson, and model names for --model <TAB>.
Model completion calls back into texra models list. Disable that dynamic lookup in slow shells with:
export TEXRA_COMPLETION_DYNAMIC=0Task history
TeXRA stores every task in the project task store. List recent tasks:
texra history list
texra history list --limit 10 # only the most recent tasks (alias: -n)
texra history list --output-format ndjsonText output prints one tab-separated row per task, with no header line:
<id> <timestamp> <name> <status> <subject>The name is the task's label (a program's name, or the chat's), and the subject is its first input file's name, else its title, else -.
The NDJSON form is stable for scripts under the version 3 contract above. Each line has kind history-entry and contains the same task entry object used by JSON output, with the terminal outcome spelled as completed, cancelled, or failed (null when none was recorded) and continues saying whether texra resume continues it. The text status column matches the Tasks view (Completed, Stopped, Error, or No outcome), plus (can continue) or (can resume) when resumable.
Inspect, export, or delete tasks:
texra history show <id> # summary (--full for full conversation)
texra history show <id> --export html # export standalone HTML or Markdown (md)
texra history delete <id> # delete one task (--all --yes deletes all)
texra doctor --prune-storage # review and remove orphaned project stores and corrupt backupsContinue a stored task on its saved model:
texra resume <id>
texra --resume <id>How texra resume handles each kind of run:
- Interactive chats: Reopens in the interactive chat UI and waits for your next message. Without a TTY, it exits with a usage error pointing scripts at
texra run. - One-shot
texra run chattasks: If stopped mid-turn, resumes in chat to finish that turn. Once ended,texra resumeexits with code 2 and suggeststexra history show <id>ortexra resume <id> --fork. - Program runs: Resumes headlessly under the original execution ID and honors
--print,--output-format, and--no-input. - Approval policy: A resumed run keeps its original approval policy (passing
--approval-policyprints a notice that it does not apply to the resumed turn, though new messages in chat use it). - In-chat commands: Inside
texra chat,/resumelists recent tasks by title,/resume <id>continues one,/resume allcontinues every interrupted task, and/rename <title>renames the focused task. A missing or malformed ID exits with code 2.
Fork a conversation as you continue it:
texra resume <id> --fork # a new task holding the conversationInside the chat, /fork continues a new task holding the conversation (the original stays in /resume).
A fork holds the conversation as it stood at the end of its last turn and leaves the original task unchanged. Forking continues in an interactive chat, so it needs a terminal, and a program run cannot be forked.
When texra chat opens, interrupted tasks stay paused until you resume them with /resume or /resume all. texra run never auto-resumes either.
If another TeXRA process still holds a task, resume refuses with that process's PID and host. If the original process is gone and cannot be verified (for example on another machine), delete the task from history and start a new one.
Background service
On macOS and Linux, the CLI, VS Code extension, and desktop app share a local background service (started automatically by texra chat, texra tasks, VS Code, or the desktop app; it exits after 10 minutes idle). Tasks keep running if you close the terminal, and any open VS Code or desktop window for the same project handles window-only actions like diff previews and diagnostics.
If the service cannot start (or TEXRA_NO_SERVICE=1 is set, or on Windows), texra chat runs locally in its own process. texra run, -p, and --output-format ndjson always run locally.
texra tasks list # tasks across projects (* = running)
texra tasks start --instruction "<text>" # start a task in the service
texra tasks attach <id> # follow live (Ctrl-C detaches)
texra tasks send <id> "<text>" # send a follow-up or resume
texra tasks stop <id> # stop a running taskYou can shorten any <id> to a unique prefix. Multiple terminals can attach to the same task; attach is read-only, so answer pending approvals in texra chat via /tasks. Per-command approval settings (--approval-policy, TEXRA_APPROVAL_POLICY) apply only to that task and set ask or yolo for it. With --no-input, the task follows the same approval policy without prompting.
Manage the service directly:
texra service status # pid, version, socket, clients, running tasks
texra service stop # stop the service (running tasks can be resumed)
texra service restart # reload shell PATH, keys, or config.json changes
texra serve # run in the foregroundThe service listens on a user-only socket in ~/.texra/run/ (logs in ~/.texra/run/serve.log) and inherits PATH and keys from your login shell. When a newer TeXRA version starts, it asks any older service to finish active tasks and exit before starting the updated one.
Tools and integrations
In the interactive TUI, /plugins lists TeXRA's plugins, including the external agent integrations shown in the extension settings, with installed plugins and MCP servers beside them, and switches the ones that can be switched on or off. Plugins you install yourself are also managed from the shell with texra plugin (see above).
Models and memories
List the models TeXRA knows about, and manage which ones appear in the model pickers:
texra models list
texra models show deepseek/deepseek-v4-pro
texra models enabled
texra models enable xai/grok-4.7
texra models disable xai/grok-4.7Project defaults
Run texra config in a terminal, or /config in a chat, to open the configuration view; texra config show prints the settings for scripts.
The CLI reads optional, non-secret defaults from .texra/config.json in the current project. Scaffold one with texra init (add --yes to accept defaults non-interactively, or --gitignore to add .texra/ to .gitignore). Command-line flags override environment variables, environment variables override the project file, the project file overrides your user configuration file (~/.texra/v1/global-storage/config.json), and that file overrides built-in defaults.
- 1CLI flagshighest priority--model deepseek/deepseek-flashwins
- 2Environment variablesshell exportsTEXRA_MODELTEXRA_AGENTTEXRA_OUTPUT_FORMAT
- 3Workspace file.texra/config.json"texra.model": …
- 4User configuration file~/.texra/v1/global-storage/config.json"texra.model": …
- 5Built-in defaultlowest prioritydeepseek/deepseek-v4-pro
Approval policy: --approval-policy, TEXRA_APPROVAL_POLICY and --no-input only narrow the stored texra.approvalPolicy, which a project file cannot set.
Resolution order, highest priority on top: a CLI flag beats its TEXRA_* env var, which beats the .texra/config.json key (and, below it, your user configuration file), which beats the built-in default (deepseek/deepseek-v4-pro).
{
"texra.model": "deepseek/deepseek-v4-pro",
"texra.outputFormat": "text",
"texra.chat": {
"model": "deepseek/deepseek-v4-pro"
},
"texra.run": {
"model": "deepseek/deepseek-v4-pro"
}
}Supported top-level keys are texra.model and texra.outputFormat; texra.chat and texra.run may each set a command-specific model default. Shared TeXRA settings the CLI honors, such as texra.telemetry.enabled (which a project file can only turn off), are also accepted. The built-in CLI model default is deepseek/deepseek-v4-pro.
The approval policy (texra.approvalPolicy) is never read from .texra/config.json, because a repository you clone can carry that file. Set it with /config or the settings view: it is kept in your own storage for the current project, and a value in your user configuration file is the default for every project. A project file that sets it is ignored and texra doctor reports the key.
The corresponding environment variables are TEXRA_MODEL, TEXRA_OUTPUT_FORMAT, and TEXRA_APPROVAL_POLICY. The approval policy a command asks for (--approval-policy or TEXRA_APPROVAL_POLICY) does not replace the stored one: it applies to that command's tasks only. Run texra doctor to see which project config file was loaded and whether any keys were ignored.
Two more switches live in the environment:
| Variable | Effect |
|---|---|
TEXRA_NO_TELEMETRY / DO_NOT_TRACK | Turn off usage logging (Usage logging) |
TEXRA_NO_UPDATE_CHECK | Skip the daily check for a newer texra release (environment-only) |
Usage logging can also be turned off with "texra.telemetry.enabled": false in your user configuration file, ~/.texra/v1/global-storage/config.json (texra doctor prints this hint). The environment variables override a stored true, but not the reverse: they can only switch logging off.
Both take 1, true, or any other value; 0, false, no, off, empty, and unset mean "leave it on".