mcode exec runs one task without starting the TUI. It is designed for automation, batch processing, and reproducible evaluations. Before running, sign in or configure a working API-key provider.Minimal invocation
Choose task instructions
Starting with 0.4.7, regularmcode exec tasks can select system instructions with --prompt-mode:exec tasks.When resuming with --session or --continue, the selected mode must match the saved session mode. Pass the same --prompt-mode again for a session using a non-default mode. Start a new session if an older session has no saved mode information.Set reasoning effort for one run
Starting with 0.4.9,mcode exec and mcode exec review accept --effort as a run-only override:--effort on its own or together with --model. The level must be supported by the selected model. Unsupported levels and models without effort support fail with a non-zero exit code before the task starts.The override is not saved to the session. Resuming later with --session or --continue and no --effort uses the session’s original level. #variant is part of a model identity: --model provider/model#high does not replace --effort high.Input
Positional prompt
Text from stdin
Read stdin only when explicitly requested with--input -:--input - with a positional prompt.JSON from stdin
--input-format json accepts a JSON string or an object such as { "prompt": "..." }:Attachments
Use--file for code, logs, images, videos, and other supported files. Paths resolve relative to --cwd:--file is provided.Options
--session and --continue cannot be combined. Headless rejects --permission ask because it has no interactive host; use the TUI or ACP when a human must approve an action.Output formats
Task results go to stdout and diagnostics go to stderr, so stdout can be passed safely tojq, CI artifacts, or another process.text
Prints the final answer for humans or simple Shell pipelines.json
Prints one stableExecResult JSON document:status can be succeeded, failed, timeout, cancelled, or limit_exceeded. The error, model, and usage fields are optional; check status first.stream-json
Prints newline-delimited, versioned events for live progress. Events includeschemaVersion, sequence, timestampMs, runId, sessionId, and turnId. Common types are:exec.startedandexec.completed;session.startedandsession.resumed;turn.started,turn.completed, andturn.failed;item.started,item.updated, anditem.completed.
sequence and preserve forward compatibility for unknown event types.Structured output
--output-schema accepts an inline JSON object or a Schema file. The final answer must be JSON matching the Schema:status: failed with error code STRUCTURED_OUTPUT_INVALID. --output-last-message writes atomically only after a successful run and Runtime shutdown; a write failure is reported as a failure.Sessions and recovery
Continue an existing session in a selected workspace:Timeouts, limits, and cancellation
SIGINT, SIGTERM, and SIGHUP cancel the current run. In CI, set a timeout and step limit, and preserve stdout and stderr separately.Exit codes
Check both the process exit code and the JSONstatus: