Skip to content

Variable Reference

Archon substitutes variables in command files, inline prompts, and bash scripts before execution. There are three categories of variables: workflow variables (substituted by the workflow engine), positional arguments (substituted by the command handler), and node output references (DAG workflows only).

These variables are substituted by the workflow executor in all node types (command:, prompt:, bash:, loop:).

VariableResolves toNotes
$ARGUMENTSThe user’s input message that triggered the workflowPrimary way to pass user input to commands
$USER_MESSAGESame as $ARGUMENTSAlias
$WORKFLOW_IDUnique ID for the current workflow runUseful for artifact naming and log correlation
$ARTIFACTS_DIRPre-created external artifacts directory (~/.archon/workspaces/<owner>/<repo>/artifacts/runs/<id>/)Always exists before node execution; stored outside the repo to avoid polluting the working tree
$BASE_BRANCHBase branch for git operationsAuto-detected from the repository’s default branch, or set via worktree.baseBranch in .archon/config.yaml. Throws an error if referenced in a prompt but cannot be resolved
$DOCS_DIRDocumentation directory pathConfigured via docs.path in .archon/config.yaml. Defaults to docs/ when not set. Never throws
$CONTEXTGitHub issue or PR context, if availablePopulated when the workflow is triggered from a GitHub issue/PR. Replaced with empty string when unavailable
$EXTERNAL_CONTEXTSame as $CONTEXTAlias
$ISSUE_CONTEXTSame as $CONTEXTAlias
$LOOP_USER_INPUTUser feedback from an interactive loop approval gateOnly populated on the first iteration of a resumed interactive loop. Empty string on all other iterations
$REJECTION_REASONReviewer feedback from an approval node rejectionOnly available in on_reject prompts. Empty string elsewhere

The three context aliases ($CONTEXT, $EXTERNAL_CONTEXT, $ISSUE_CONTEXT) all resolve to the same value. When no issue context is available, they are replaced with an empty string to avoid sending the literal $CONTEXT text to the AI.

If issue context is present but no context variable appears in the prompt, the context is appended to the end of the prompt automatically. This prevents duplicate context when a command explicitly uses $CONTEXT.

Unlike other variables, $BASE_BRANCH will cause the workflow to fail immediately if:

  • The variable is referenced in a prompt, AND
  • Auto-detection from git fails, AND
  • worktree.baseBranch is not set in .archon/config.yaml

If the variable is not referenced, no error occurs even if the base branch cannot be determined.

These variables are substituted by the command handler when commands are invoked directly (outside workflows). They are processed before workflow variables.

VariableResolves toNotes
$1First positional argumentSplit by whitespace from the user’s input
$2Second positional argument
$3$9Third through ninth positional arguments
$ARGUMENTSAll arguments as a single stringSame variable, available in both contexts
\$Literal $ characterEscape a dollar sign to prevent substitution

In DAG workflows, nodes can reference the output of any completed upstream node. These are substituted after workflow variables.

PatternResolves toNotes
$nodeId.outputFull output string of the referenced nodeThe node must be a declared dependency (in depends_on)
$nodeId.output.fieldA specific JSON field from the node’s outputRequires the upstream node to use output_format for structured JSON
nodes:
- id: classify
command: classify-issue
output_format:
type: object
properties:
type: { type: string, enum: [BUG, FEATURE] }
required: [type]
- id: fix
prompt: |
The issue was classified as: $classify.output.type
Full classification: $classify.output
User's original request: $USER_MESSAGE
depends_on: [classify]

Variables are substituted in a defined order:

  1. Workflow variables$WORKFLOW_ID, $USER_MESSAGE, $ARGUMENTS, $ARTIFACTS_DIR, $BASE_BRANCH, $DOCS_DIR, $LOOP_USER_INPUT, $REJECTION_REASON
  2. Context variables$CONTEXT, $EXTERNAL_CONTEXT, $ISSUE_CONTEXT
  3. Node output references$nodeId.output, $nodeId.output.field

Positional arguments ($1 through $9) are substituted separately by the command handler and are only available when commands are invoked directly, not through workflow nodes.

VariableWorkflow nodesDirect command invocationwhen: conditions
$ARGUMENTS / $USER_MESSAGEYesYes (as $ARGUMENTS)No
$1$9NoYesNo
$WORKFLOW_IDYesNoNo
$ARTIFACTS_DIRYesNoNo
$BASE_BRANCHYesNoNo
$DOCS_DIRYesNoNo
$CONTEXT / aliasesYesNoNo
$LOOP_USER_INPUTYes (loop nodes)NoNo
$REJECTION_REASONYes (on_reject only)NoNo
$nodeId.outputYes (DAG nodes)NoYes