fabro/docs/workflows/variables.mdx
Bryan Helmkamp 7505cb4ce1 Fill in Agents, Human-in-the-Loop, Stylesheets, Variables pages
- Agents: agent loop, built-in tools, prompts, sub-agents, skills, hooks
- Human-in-the-Loop: gates, accelerators, freeform input, auto-approve
- Stylesheets: selectors, specificity, properties, cascading, full examples
- Variables: run config vars, $goal expansion, variable merging
- Remove model stylesheets section from core workflows page (now dedicated page)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 17:42:19 -05:00

68 lines
2.1 KiB
Text

---
title: "Variables"
description: "Using variables in workflows"
---
Arc supports `$variable` placeholders that let you parameterize workflows without editing the DOT file.
## Run config variables
Define variables in the `[vars]` section of a run config TOML file:
```toml
version = 1
goal = "Run tests for $repo_name"
graph = "check.dot"
[vars]
repo_name = "arc"
repo_url = "https://github.com/qltysh/arc"
language = "rust"
```
These variables are expanded into the DOT source **before** the graph is parsed. You can use `$variable` anywhere in the DOT file — goals, prompts, labels, scripts, or any other attribute:
```dot
digraph Check {
graph [goal="Run tests for $repo_name"]
start [shape=Mdiamond, label="Start"]
exit [shape=Msquare, label="Exit"]
clone [label="Clone", shape=parallelogram, script="git clone $repo_url repo"]
test [label="Test", prompt="Run the $language test suite in the repo/ directory."]
start -> clone -> test -> exit
}
```
When launched with `arc run start run.toml`, Arc replaces `$repo_name`, `$repo_url`, and `$language` with their values before parsing the graph.
### Undefined variables
If a `$variable` in the DOT file has no matching entry in `[vars]`, Arc raises an error. This catches typos early — a misspelled `$langauge` fails immediately rather than passing a literal `$langauge` to the LLM.
A bare `$` not followed by an identifier character (e.g. `costs $5`) is left as-is.
## The `$goal` variable
Inside agent and prompt node prompts, Arc automatically expands `$goal` to the workflow's `goal` attribute. This happens at runtime, after graph parsing:
```dot
digraph Example {
graph [goal="Implement the login feature"]
plan [label="Plan", prompt="Create a plan for: $goal"]
}
```
The plan node's prompt becomes `"Create a plan for: Implement the login feature"`.
## Variable merging
When using server-level run defaults alongside a run config TOML, variables are merged. Task config vars override default vars when keys collide:
| Source | Priority |
|---|---|
| Run config TOML `[vars]` | Highest — wins on collision |
| Server defaults `[vars]` | Lowest — provides fallback values |