Skip to main content
xbot
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Reference for the XBOT_* environment variables injected into script runtime plugin processes (plugin/script_runtime.go). Stdio plugins do not receive these — they use the NDJSON protocol instead.

Always Injected

VariableContent
XBOT_WORK_DIRThe session’s current working directory. The script’s cmd.Dir is also set to this value (if it exists).
XBOT_PLUGIN_CONFIGThe plugin’s merged config serialized as a JSON string (manifest defaults overlaid with user values).

Widget Runs

VariableContent
XBOT_WIDGET_IDSet only when the script runs on behalf of a specific widget. Multi-widget plugins branch on this value to produce different output per widget (absent when the plugin declares a single widget or for non-widget runs).

Hook-Triggered Runs

Available when the script runs as a hook trigger (values come from the hook payload):

VariableContent
XBOT_HOOK_EVENTThe hook event name (e.g. "PostToolUse").
XBOT_TOOL_NAMETool name (set only when non-empty).
XBOT_TOOL_OUTPUTTool output (set only when non-empty).
XBOT_TOOL_INPUTTool input (set only when non-empty).

Session Context (all hook events)

Populated from HookPayload.Extra, injected by the engine after each LLM call and compression (hooks.SessionContextplugin_bridge.goHookPayload.Extra → env vars):

VariableContent
XBOT_MODELThe model name of the current session.
XBOT_MAX_CONTEXTThe session’s max context token limit.
XBOT_TOKEN_USAGECombined prompt/completion tokens, format "<prompt>/<completion>" (e.g. "12345/678").
XBOT_PROMPT_TOKENSPrompt token count.
XBOT_COMP_TOKENSCompletion token count.

Command Runs

VariableContent
XBOT_COMMAND_NAMEThe slash command name (for command-handler scripts).
XBOT_COMMAND_ARGSEverything after the command name.

Notes

  • Variables are appended to the inherited environment (os.Environ()), so the script also sees the host process environment.
  • Optional variables are omitted entirely when their source value is empty — e.g. XBOT_WIDGET_ID is not set (rather than set to an empty string) when no widget ID applies.
  • Widgets can display model name, context usage bar, and token costs by reading these variables.