How to Reference Another Variable in Brim
Variables in Brim can reference other variables directly inside their instructions. This lets you build more precise, layered logic, and makes your instructions easier to read and maintain.
Why Reference Another Variable?
When you're writing instructions for a complex variable, you often need to describe how a value should be interpreted in relation to another piece of data you're already collecting. Rather than repeating that definition inline, you can reference the variable directly.
Referencing another variable helps in three key ways:
Layered reasoning. Variables can make decisions based on values that Brim has already extracted. For example, a variable determining "Postoperative Complication" might need to consult the value of "Procedure Type" to apply the right criteria. Referencing the variable creates an explicit, traceable connection between them.
Clarity on input variables. When you reference a variable in your instructions, it's immediately clear the LLM as well as to anyone reading or editing the variable what inputs matter, and how they should be used.
Complete, concrete examples. You can write examples in your instructions that cite specific values from the referenced variable (e.g., "If {Procedure Type} is 'CABG', then..."), making the logic unambiguous for both the AI and your human reviewers.
How to Add a Reference
When editing a variable's instructions, type " { " (open curly bracket, using Shift + the [ key) anywhere in the instruction text. A dropdown will appear showing all variables available in your project. Select the one you want to reference.
The reference will appear inline in your instructions with a green tag.
Input Variables Are Added Automatically
If you reference a variable that isn't already listed as an input variable for the one you're editing, Brim will automatically add it as an input when you save. You don't need to manually manage the input variable list when using references.
Using References When Creating Variables via AI
References work when you use Brim's AI to automatically create a variable or dependent variable as well. Just use the open curly bracket "{" and choose a variable from the dropdown, and Brim will recognize it as an input and incorporate it into the generated instruction.
This is especially useful when setting up complex dependent variable chains: describe the logic you want in plain language, mention the relevant variables with explicit references, and Brim will wire up the relationships for you.
References in Library Variables
Variables in the Brim Variable Library also use references. When you add a library variable that references other variables, those referenced variables will either be matched to existing variables in your project or added automatically. This means library variables can be dropped into a project while preserving the full logic they depend on.