Run one task
midas run "review the diff on this branch for security issues"
midas run "add tests for src/billing.ts and run them"
midas run "summarize this log and name the first failure" --file ./build.logThe task is the message. Everything the interactive agent can do is available, subject to the same permissions. Add --auto to auto-approve actions that are not explicitly denied.
If Claude Code, Codex, or another agent runs Midas for you, add the rule set so it does not pin a model or tell Midas which one to use.
Machine output
midas run "list the endpoints that lack auth" --format jsonThe JSON format emits structured events instead of formatted text, so a script can read the result without parsing ANSI output. Use --title to name the session and make it easier to find later.
When a permission is blocked
A headless run has nobody to answer a permission prompt, so Midas rejects the request. The run can stop without an answer and still exit 0, so do not treat exit 0 as proof the work finished. Check the output. Midas prints auto-rejecting to stderr when this happens.
Pipes and files
cat error.log | midas run "find the first exception and explain it"
midas run "compare these two configs" --file a.json --file b.jsonA file is attached to the message. Piped stdin works the way it does with any other command, so you can put midas run in a pipeline.
Continue a session
midas run "now add the missing cases" --continue
midas run "finish the migration" --session SESSION_IDA headless run is still a session. It shows up in midas session list and the dashboard, and you can continue it later.
Run against a server
midas serve
midas run --attach http://127.0.0.1:4096 "run the tests"
midas attach http://127.0.0.1:4096Use midas serve to run the server alone, then attach a headless run or an interactive terminal to it. This is useful on a remote machine, in a container, or when two clients should share one session.
Sandboxing
On macOS and Linux, a headless run is sandboxed by default. The local OS sandbox bounds what the agent can do to the workspace and lets actions inside it run without stopping for prompts. Interactive runs are not sandboxed by default. Set MIDAS_EXPERIMENTAL_SANDBOX=false to opt out.
Related
- Permissions explains what
--autooverrides and what it does not. - Using Midas from another harness gives the calling agent a rule set that leaves model choice to Midas.
- Git worktrees gives a headless run its own checkout.
- Cloud sandboxes runs one task on a remote machine and opens a draft pull request.