fx ask

fx ask runs one noninteractive request and exits. Use it in scripts, continuous integration, or whenever you do not need the interactive shell.

$fx ask "explain what this repository does"

Pass a prompt to fx ask

Pass the prompt as command arguments. In a shell script, printf can send generated prompt text to fx ask through standard input (stdin):

$printf "summarize src/core\n" | fx ask

Use --image <path> to attach an image. Repeat the flag to attach multiple images.

$fx ask --image ./ui.png "describe this interface"

See Vision for supported formats and image routing.

Use fx ask in scripts

For shell scripts and CI, redirect standard output (stdout) to receive raw assistant Markdown. Progress and diagnostics remain on standard error (stderr).

Use --json when a program needs structured fields instead of Markdown:

$fx ask --json "summarize the current changes"

The command returns one JSON object:

{
  "output": "Assistant Markdown",
  "exit_code": 0,
  "model": "provider/model-id",
  "session_id": "session-id",
  "steps": 1,
  "tool_calls": [
    {
      "name": "read_file",
      "status": "success"
    }
  ]
}

Failures use a nonzero exit_code and can include an error field. Tool calls always include name and status; some tools include additional result fields.

Parse stdout while keeping progress and diagnostics visible on stderr:

$fx ask --json "inspect this repository" | jq -r .output

Add --no-save for a run that should not create a session. In JSON output, session_id is an empty string. --no-save cannot be combined with --resume.

Continue a session with fx ask

Use --resume last to continue the latest session for the current workspace:

$fx ask --resume last "now add tests"

You can pass a session ID instead of last. See Sessions to inspect sessions or recover an interrupted response.

Handle permissions in noninteractive runs

fx ask cannot pause for an interactive approval. Saved permission rules still apply, and --auto reviews unresolved permission requests automatically. If a request remains unresolved, fx exits before running the tool.

--yolo disables fx permission checks and command sandboxing for the run. Use it only in an environment you trust.

An interrupted run exits with code 130. See Troubleshooting when a run ends before the tool executes.

Run fx ask --help for the complete flag reference.