Non-interactive and CI

Flux provides two one-shot modes. Quote prompts that contain spaces. In print mode, put flags such as --stream and --output-schema before -P, because the argument immediately after -P is treated as the prompt.

Both modes also accept piped stdin. When stdin is present, Flux wraps it as:

<stdin>
...
</stdin>

and prepends it to the prompt it sends to the model.

Command Intent
flux -P "<prompt>" Run one agent turn and write only the final answer to stdout.
flux --stream -P "<prompt>" Stream response text while preserving stderr for tool progress and errors.

flux -P runs one agent turn, writes the final answer to stdout, writes tool progress and errors to stderr, and exits:

flux -P "summarize this repository"
cat error.log | flux -P "explain the failure"
flux --stream -P "review the current diff"

Print mode accepts cwd-relative @file mentions, but it does not add dynamic repository context such as git state, project instructions, memories, or skills.

#Run mode

Command Intent
flux run "<prompt>" Run a one-shot, repository-aware agent task with streamed output.
flux run --max-turns <count> "<prompt>" Limit the number of internal model/tool iterations available to the task.
flux run --permission '<json>' "<prompt>" Supply an explicit JSON tool-permission policy.

flux run includes dynamic repository context and streams output, making it suitable for agent-style CI work:

flux run "review src for security issues"
flux run --max-turns 20 "fix the type errors"

Non-interactive runs auto-accept tools by default, so use --permission or FLUX_PERMISSION to narrow what CI jobs can do.

Control tools with JSON permissions or FLUX_PERMISSION:

flux run --permission '{"*":"deny","read_file":"allow","grep_search":"allow"}' "audit the code"

An explicit "*":"deny" creates a true allowlist. If a policy contains deny rules without "*":"deny", Flux falls back to broad deny-writes-style blocking rather than fine-grained per-tool deny behavior. --permission and FLUX_PERMISSION apply to flux run only, not to flux -P.

You can also use the normal selection flags in non-interactive mode, including --provider, --model, --effort, --openai-api, and the Ollama connection flags.

#Structured output

Command Intent
flux --output-schema @<path> -P "<prompt>" Require the final answer to match a JSON Schema file in the current directory.
flux --output-schema '<json>' -P "<prompt>" Require the final answer to match an inline JSON Schema.

Require final stdout to match JSON Schema:

flux --output-schema @schema.json -P "list risky dependencies"
flux --output-schema '{"type":"object","required":["summary"]}' -P "summarize"

--output-schema is print-mode only. Schema mode buffers output even when --stream is present. Flux validates JSON, retries once with correction instructions, then prints only the validated JSON value. Invalid schemas, provider errors, or output that remains invalid return exit code 1; success returns 0.

Keep secrets in environment variables and use an appropriately narrow tool policy for CI jobs.