Skip to content

Non-interactive execution (run) ​

mogick run submits a task to the agent and exits when the run completes. Use it in CI, Git hooks, scheduled jobs, and other workflows that do not require the TUI. The root mogick command does not accept a prompt; non-interactive tasks must use run explicitly.

bash
mogick run "fix all lint errors in src/"
mogick run - < error.log                 # Read the prompt from a file
cat error.log | mogick run -             # Read the prompt from a pipe

Input and output ​

A prompt can be passed as an argument or read from standard input with -. Piped input automatically enables non-interactive behavior.

OptionDescription
--jsonOutput machine-readable JSON events
-o, --output-last-message <file>Write renderer output to a file (26.9.11)
--verboseOutput verbose tool trace
--logs-path <file>Specify diagnostic log file
--non-interactiveDisable interactive prompts
--resume <id>Resume in an existing session
--tool-call-permissions <policy>Select permission policy
--no-auto-upgradeSkip update check at startup

In 26.9.11, despite its name, --output-last-message redirects renderer output, which can include prompt, intermediate text and tool events. Do not treat this file as a clean final answer. --json emits newline-delimited JSON (JSONL), not a single JSON object or a complete protocol trace.

bash
mogick run --json -o run.jsonl "Summarize the repository"
mogick run --continue "Continue the previous task"

Event types include prompt, text.delta, thinking.open/delta/close, tool.start/done, step.start/finish, and error; consumers must tolerate optional fields and additional events. For historical records, use session export.

Execution mode and permissions ​

run always uses Agent mode and does not support --mode. When you need Plan mode, switch with Shift+Tab in the TUI or through an ACP host.

A non-interactive run cannot display an approval prompt and wait for user input. Configure permissions explicitly for the task. For each policy, see Tool permission policies. Under auto, operations that require confirmation are denied. For CI, prefer workspace, keep the task narrowly scoped, and use yolo only in a fully isolated environment.

bash
mogick run --tool-call-permissions read "Review the source code without changing files"

Exit code ​

Exit codeMeaning
0Completed normally
1Execution failed
130Interrupted, for example by Ctrl+C or SIGINT
143SIGTERM received

Scripts should treat any nonzero exit code as a failed or interrupted run and retain the logs for troubleshooting.

Working directory and configuration ​

Mogick uses the current shell working directory as the workspace. Do not use -C / --cd or -c / --config:

bash
cd /path/to/repository
mogick run "Run the test suite"

To select a configuration file, set MOGICK_CONFIG_FILE. See Data directories and environment variables.

Script integration ​

Check the exit code and retain the output. A successful model run does not prove tests passed: execute the project's documented test command separately and check its result. workspace does not automatically approve arbitrary shell commands; operations requiring confirmation are denied non-interactively. Review changes before committing or publishing.