Overview
Variables make runbooks reusable. Define them once, and reference them in step values with{{variableName}} syntax. Values can come from interactive prompts, environment variables, context files, secrets, or static values.
Variable sources
Variables are defined in the runbook with asource that determines how their value is resolved:
| Source | Description | Example use case |
|---|---|---|
prompt | Asks the user at execution time (CLI only) | Login credentials, one-time values |
fixed | Hardcoded static value | Base URLs, constants |
context | AI extracts from the --context markdown file | Values described in documentation |
env | Read from an environment variable | AWS_REGION, APP_URL |
expression | Evaluate a template expression | {{Date.now()}}, computed values |
data | Read from a data file | Row-specific values in batch workflows |
Examples
Resolution priority
At execution time, variables are resolved in this order. The first match wins:| Priority | Source | Description |
|---|---|---|
| 1 | secrets | Values from --secrets flag or SDK secrets option |
| 2 | data | Values from data files |
| 3 | context | AI extraction from --context markdown |
| 4 | env | Environment variables |
| 5 | expression | Template expression evaluation |
| 6 | fixed | Static value from the definition |
| 7 | prompt | Interactive prompt (CLI only) |
--secrets, it overrides any other source.
Secrets handling
Secrets are sensitive values that should never appear in logs or reports. There are two ways to provide them:Via --secrets flag
Create a JSON file with key-value pairs:
Via sensitive: true flag
Mark individual variables as sensitive in the runbook:
Context-based resolution
When a variable hassource: context, AI reads the --context markdown file and extracts the value based on the variable’s description. This is useful when values are documented but not hardcoded:
adminUrl to https://admin.example.com/dashboard.
Template syntax
Reference variables in any string field using double curly braces:- Simple references:
{{variableName}} - Dot notation for captured objects:
{{captured.field}} - Nesting up to 3 levels deep
Best practices
- Use
promptfor credentials — Never hardcode passwords in runbooks - Use
envfor environment-specific values — Base URLs, API endpoints, regions - Use
contextfor documented values — Keepcontext.mdas the source of truth - Mark sensitive values — Use
sensitive: trueor--secretsto ensure masking - Keep secrets out of version control — Add
secrets.jsonto.gitignore