docs/task-failure-hooks.md
Flow can run a command automatically when a task fails. This is useful for opening a tailored prompt, collecting diagnostics, or launching a helper tool.
FLOW_DISABLE_TASK_FAILURE_HOOK is set.You can set the hook in either place:
export FLOW_TASK_FAILURE_HOOK='rise work --errors --diff --patch --focus --focus-app lin --target codex "fix $FLOW_TASK_NAME failure"'
~/.config/lin/config.ts and regenerate, or~/.config/flow/config.ts directly if you know it is safe to do so.Example entry in config:
export default {
flow: {
taskFailureHook: "rise work --errors --diff --patch --focus --focus-app lin --target codex \"fix $FLOW_TASK_NAME failure\""
}
}
/bin/sh -c.workdir (the repo or task cwd).Flow sets these environment variables when the hook runs:
FLOW_TASK_NAME (task name)FLOW_TASK_COMMAND (command string)FLOW_TASK_WORKDIR (absolute path)FLOW_TASK_STATUS (exit code, or -1 if unknown)FLOW_FAILURE_BUNDLE_PATH (path to the last failure bundle)FLOW_TASK_OUTPUT_TAIL (tail of task output, truncated)Flow writes a JSON failure bundle to one of these locations:
FISHX_FAILURE_PATH if setFLOW_FAILURE_BUNDLE_PATH if set~/.cache/flow/last-task-failure.json (default)The resolved path is passed to hooks via FLOW_FAILURE_BUNDLE_PATH.
Set the following env var:
export FLOW_DISABLE_TASK_FAILURE_HOOK=1
If your hook calls rise work, Flow automatically appends --no-open and strips
--focus / --focus-app unless you explicitly allow opening. This prevents Zed
or other apps from launching on every failure.
To allow the open behavior:
export FLOW_TASK_FAILURE_HOOK_ALLOW_OPEN=1
export FLOW_TASK_FAILURE_HOOK='rise work --errors --diff --patch --focus --focus-app lin --target codex "fix $FLOW_TASK_NAME failure"'
This will write prompts to .rise/prompts/ and focus the codex prompt without
opening Zed by default.