Headless runs
crystal run runs one task and exits. It does not open the alternate screen. Quote the task, or omit it and pipe the task on stdin. A task argument wins over stdin. Slash commands are rejected.
crystal run --workspace . --approval review --duration 600 "Fix the failing test."echo "Summarize the repository." | crystal run --model-calls 8 --tool-calls 32--format default prints a readable trace: the assistant reply, then each tool beside its result.
| Tool | What the trace keeps |
|---|---|
read, list, glob, grep, other successes |
A short head excerpt and how many lines were omitted |
edit, multi_edit, write, apply_patch |
The result |
bash |
The command, the exit status, and a short tail. The tail is longer when the command fails |
| Other failures | The result text |
Labels use square brackets, exit status uses parentheses, and omitted-line markers use angle brackets. Host text stays distinct from tool output.
--format json prints one JSON object per line and keeps the full tool output. Thinking is omitted unless --show-thinking is set. With that flag, thinking is under [Thinking] and the reply is under [Assistant]. The saved session id is printed at the end. Resume it with crystal --resume <id>.
text and reasoning each carry one segment, not stream deltas. A retry discards the failed attempt’s unsent segment. step_finish carries usage (the turn total, including children), lastRequestUsage (the final request), and cumulativeUsage (the session). Each has inputTokens, outputTokens, and optional reasoningTokens, and is omitted when the provider did not report it. Child Agent events reuse the parent shapes with a child_ prefix (child_text, child_reasoning, child_tool_use, child_error, child_note, child_retry) and add childSessionID and invocationID. child_status reports agent, label, status, modelCalls, toolCalls, images, and, once known, usage.
To serve a session over HTTP instead, see crystal server. To drive one from an editor over ACP, see Bridge.
Flags override the saved configuration for this process only. They are not written to config.json. Do not put secrets on the command line. An omitted flag keeps the saved value, or the product default when that is also unset. --workspace-trust does not: omitting it checks the directory. unlimited removes that one cap.
| Option | Meaning |
|---|---|
-p, --provider / -m, --model |
Provider and model for this process |
-w, --workspace / --home |
Workspace root and data directory |
--space |
Use the operator space {home}/space as the workspace. Creates it when missing. Cannot be combined with --workspace |
--approval <mode> |
default, edit, review, audit, or full |
--approval-model <on|off> |
Use the saved approval model, or turn it off for this process |
--approval-provider <provider> |
Approval-model provider for this process. Turns the switch on |
--approval-model-id <model> |
Approval-model id for this process. Turns the switch on |
--approval-thinking <effort> |
Reviewer thinking gear for this process. Same values as /approval thinking; an unsupported gear falls back to the provider default and a note is printed, and a value that is not an effort token exits 1. Does not write the file |
--approval-tier <token>, --approval-speed <token> |
Approval-model service tier and speed for this process. Must be listed by that model; otherwise exit 1. Does not write the file |
--approval-context <budget> |
Approval-model context budget for this process, such as 200k. Must be declared by that model. Does not write the file |
--extended-approval <on|off> |
Use the saved extended approval model, or turn it off for this process |
--extended-approval-provider <provider> |
Extended approval provider for this process. Turns the switch on |
--extended-approval-model-id <model> |
Extended approval model id for this process. Turns the switch on |
--extended-approval-thinking <effort> |
Extended reviewer thinking gear for this process |
--extended-approval-tier <token>, --extended-approval-speed <token> |
Extended reviewer service tier and speed for this process |
--extended-approval-context <budget> |
Extended reviewer context budget for this process |
--extended-approval-trigger <low|medium|high> |
Lowest primary risk level that runs the extended check, for this process |
--extended-approval-primary <on|off> |
Show the primary verdict to the extended reviewer, for this process |
--compaction-model <on|off> |
Use the saved compaction model, or turn it off for this process. on needs a saved selection, or --compaction-provider and --compaction-model-id on the same command. Does not write the file |
--compaction-provider <provider> |
Compaction-model provider for this process. Turns the switch on |
--compaction-model-id <model> |
Compaction-model id for this process. Turns the switch on |
--compaction-thinking <effort> |
Summarizer thinking gear for this process. Same values as /compact thinking. An unsupported gear falls back to the provider default and a note is printed. Does not write the file |
--compaction-tier <token>, --compaction-speed <token> |
Summarizer service tier and speed for this process. Must be listed by that model; otherwise exit 1. Does not write the file |
--compaction-context <budget> |
Summarizer context budget for this process. Must be declared by that model. Does not write the file |
--compaction-context <budget> |
Summarizer context budget for this process. Must be declared by that model. Does not write the file |
--topic <on|off> |
Topic naming for this process |
--topic-provider, --topic-model-id |
Topic model for this process; pass both. Without them the saved choice or the session model applies |
--topic-thinking, --topic-tier, --topic-speed, --topic-context |
Topic model gear and its own slots for this process. Does not write the file |
--pursue-provider, --pursue-model-id, --pursue-thinking, --pursue-tier, --pursue-speed, --pursue-context, --pursue-compaction-provider, --pursue-compaction-model-id, --pursue-compaction-thinking, --pursue-compaction-tier, --pursue-compaction-speed, --pursue-compaction-context, --pursue-limit <name=value> |
Pursue checker model, its compaction model, and limits for this process. Pass each provider and model id together. Not written to config.json |
--pursue |
Treat the task as the objective of /pursue. The run continues until the checker finds it met, is blocked, or a limit is reached. Checker model and limits come from pursueModel, pursueLimits, and the --pursue-* flags |
--image-model <on|off>, --audio-model <on|off>, --video-model <on|off>, --document-model <on|off> |
Use the saved resource description model, or turn it off for this process |
--image-provider, --image-model-id, and the same for audio, video, and document |
Resource description model for this process. Turns that switch on |
--image-thinking, --image-tier, --image-speed, --image-context, and the same for audio, video, and document |
That model’s gear, tier, speed, and context budget for this process. Does not write the file. Audio, video, and document description models have no runtime tool integration |
--plan / --work / --mode <name> |
Start in Plan, Work, or an enabled custom mode. The default is Work. An unknown or disabled mode name exits 1. Pass only one |
--thinking <effort> |
Same values as /thinking. An unsupported gear is ignored, a note is printed, and the request uses the provider default. A value that is not an effort token exits 1 |
--context <budget> |
Local context budget for the selected model when it declares more than one. Same text as /context. A model with one budget, or a budget it does not declare, exits 1. Does not write contextSelections |
--tier <token> |
Service-tier token the selected model lists. A model that does not list it exits 1. Does not write tierSelections |
--speed <token>, --fast <token> |
Speed token the selected model lists. A model that does not list it exits 1. Does not write speedSelections |
--prompt-set <name> |
Force one home prompt set for this process, even when its prompt.json says enabled false. default forces the built-in text. Does not write the file |
--prompt-attachments <on|off> |
on follows each attachment’s enabled flag and order. off appends nothing. Omitted means on. Does not write the file |
--prompt-attachment <name> |
Repeatable. Appends that attachment after the enabled set, even when enabled is false. A missing name exits 1. Cannot be combined with --prompt-attachments off. Does not write the file |
--skills, --external-tools, --mcp, --plugins |
on or off for this process |
--agents <on|off> |
Enable or disable child Agents for this process. Does not write config.json |
--agents-concurrency <count> |
Active child invocations for this process, from 1 to 8. Does not write the file |
--agents-model-calls <count>, --agents-tool-calls <count>, --agents-duration <seconds> |
Per-run child limits for this process. unlimited removes one. Does not write the file |
--rules <value> |
on or off for both rule-file sides, or comma-separated global=on|off and project=on|off. An assignment leaves the other side as saved. Does not write the file, and does not affect instructions.md or .crystal.md |
--workspace-trust <on|off> |
Directory trust for this process only. Omitted and on refuse an untrusted directory. off skips the check and does not record trust. This does not follow workspaceTrust |
--model-calls <count> |
Model rounds for this turn. Default 1024 |
--tool-calls <count> |
Tool calls for this turn. Default 8192. 0 allows none |
--duration <seconds> |
Wall-clock cap for this turn. Default 7 days. Pass a short value in CI |
--bash-timeout <seconds> |
Foreground per-command bash cap. Default 600. unlimited disables that timer |
--disable-tool <name> |
Repeatable. Omits that built-in tool for this process. An unknown name refuses to start. Does not write the file, and does not free the name |
--show-thinking |
Print reasoning text for this run, and label each reply [Assistant]. Independent of verboseThinking |
--format |
default for plain text, or json for one JSON object per line |
--approval-model off cannot be combined with --approval-provider or --approval-model-id. --approval-model on needs a saved approval model or --approval-model-id. --approval-thinking sets a gear for this process only. /approval model keeps the saved gear. /approval thinking is the command that writes one. The process gear is ignored while the switch is off. The --extended-approval flags follow the same rules, with --extended-approval-model-id in place of --approval-model-id. See Approval.
--workspace-trust does not inherit the saved setting. Leaving it out checks the directory even when workspaceTrust is false. An untrusted directory exits 4 before a session starts. Trust it from the interactive terminal, or pass --workspace-trust off. crystal run --space uses the operator space, which is already trusted.
There is no operator. In Review and Audit the reviewing model still judges calls that require review. Allow runs the tool. Deny returns the reviewer’s reason to the model. That model is the session model unless the approval-model switch is on. When extended approval is on, its model checks each review allow the same way: allow runs the tool, deny returns its reason, and ask is denied. Anything that would ask the operator, including Default and Edit prompts, is denied. Full auto-passes tool calls. The question tool is dismissed. Plan does not offer write, edit, multi_edit, apply_patch, or bash. Credential paths stay forbidden. crystal run has no /child. A child summary stays with the task result.
A reviewer denial is a tool error. If the model then finishes, the process exits 0. A denied operator prompt or a dismissed question does not. A call to a tool Plan does not offer fails the turn.
| Exit | Meaning |
|---|---|
| 0 | The turn completed, and no operator prompt was denied or dismissed |
| 1 | The command, configuration, credentials, workspace, or prompt set is invalid |
| 2 | The model request failed (including a request timeout or a turn that faulted before reporting a result), or the model stopped because of a content filter |
| 3 | A model-call, tool-call, or duration budget was reached, the context overflowed, or the model output was truncated |
| 4 | The turn finished after an operator prompt was denied or a question was dismissed |
| 5 | The run was interrupted |
A failure, a budget stop, or an interrupt is reported instead of a denial. Plain stdout then includes [Stopped] and the session id.
With --pursue, the exit codes are met 0, blocked 2 (4 if an operator prompt was denied), limit 3, and checker failure 2.
Each JSON line has type, a UTC timestamp, and sessionID.
type |
Extra fields |
|---|---|
tool_use |
callId, status (success or failure), output, and name and arguments only when a call with the same id was issued. output shows trusted image markers as [Image #N], and images lists those numbers |
step_finish |
reason, modelCalls, toolCalls, contextWindow, usage, lastRequestUsage, cumulativeUsage. A turn that faults before it reports a result still gets step_finish with reason failed and no counts |
child_status |
agent, label, status, modelCalls, toolCalls, images, usage |
reasoning |
Present only with --show-thinking |
stopped |
Present only when the process will exit non-zero |
session |
text is the same resume hint the plain format prints |
Other types are step_start, text, error, note, retry, pursue_check, and pursue, plus the child_ events above. With --pursue, pursue_check carries index, verdict, reason, and nextStep, and pursue is the final status with reasonCode. Invalid commands and missing credentials are still plain text on stderr.