Global variables
Use global variables to store and reuse credentials and generic values across all of your flows. Global variables are typically used by components in a flow, and you can use them in any field with the global variable icon.
In contrast, environment variables, like SKILLFLAW_PORT or SKILLFLAW_LOG_LEVEL, are generally for broader settings that configure how SkillFlaw runs.
However, SkillFlaw can also source global variables from environment variables.
SkillFlaw stores global variables in its configured application database, and it encrypts the values using a secret key.
Create a global variable
To create a new global variable, follow these steps.
-
In the SkillFlaw header, click your profile icon, and then select Settings.
-
Click Global Variables.
-
Click Add New.
-
In the Create Variable dialog, enter a name for your variable in the Variable Name field.
-
Optional: Select a Type for your global variable. The available types are Generic (default) and Credential.
SkillFlaw encrypts both Generic and Credential type global variables. However, Generic variables aren't masked in the visual editor, whereas Credential variables are masked. Session ID fields don't accept Credential (masked) variables.
-
Enter the Value for your global variable.
-
Optional: Use the Apply To Fields menu to select one or more fields that you want SkillFlaw to automatically apply your global variable to. For example, if you select OpenAI API Key, SkillFlaw automatically applies the variable to any OpenAI API Key field.
-
Click Save Variable.
You can now select your global variable from any text input field that displays the Globe icon.
Edit a global variable
-
In the SkillFlaw header, click your profile icon, and then select Settings.
-
Click Global Variables.
-
Click on the global variable you want to edit.
-
In the Update Variable dialog, you can edit the following fields: Variable Name, Value, and Apply To Fields.
-
Click Update Variable.
Delete a global variable
Deleting a global variable permanently deletes the value from the database. Flows that reference the deleted global variable will fail.
-
In the SkillFlaw header, click your profile icon, and then select Settings.
-
Click Global Variables.
-
Click the checkbox next to the global variable that you want to delete.
-
Click Delete.
The global variable is deleted from the database.
Add custom global variables from the environment
SkillFlaw can source custom global variables from your runtime environment. For information about how SkillFlaw detects and applies environment variables, see Environment variables.
SkillFlaw automatically generates global variables based on constants.py if it detects any matching environment variables.
For example, if you set OPENAI_API_KEY in your runtime environment, SkillFlaw automatically generates a global variable using that value.
You can declare additional variables in SKILLFLAW_VARIABLES_TO_GET_FROM_ENVIRONMENT.
For example, SKILLFLAW_VARIABLES_TO_GET_FROM_ENVIRONMENT=WATSONX_PROJECT_ID,WATSONX_API_KEY creates global variables named WATSONX_PROJECT_ID and WATSONX_API_KEY in SkillFlaw's database.
Then, you can use these variables wherever they are needed in your component settings.
- Local
If you installed SkillFlaw locally, set SKILLFLAW_VARIABLES_TO_GET_FROM_ENVIRONMENT in your SkillFlaw .env file:
-
Create or edit your SkillFlaw
.envfile. -
Add the
SKILLFLAW_VARIABLES_TO_GET_FROM_ENVIRONMENTenvironment variable as follows:You can specify the variables either as a comma-separated string with no spaces, or as a JSON list:
_10# Option 1: Comma-separated string (no spaces)_10SKILLFLAW_VARIABLES_TO_GET_FROM_ENVIRONMENT=VARIABLE1,VARIABLE2_10_10# Option 2: JSON list format_10SKILLFLAW_VARIABLES_TO_GET_FROM_ENVIRONMENT=["VARIABLE1", "VARIABLE2"]Replace
VARIABLE1,VARIABLE2with your additional variables that you want SkillFlaw to source from the environment, such asCUSTOM_API_KEY,INTERNAL_SERVICE_URLor["CUSTOM_API_KEY", "INTERNAL_SERVICE_URL"]. -
Save and close the file.
-
Start SkillFlaw with the
.envfile:_10uv run skillflaw run --env-file .envAlternatively, you can set environment variables directly in the command line:
_10VARIABLE1="VALUE1" VARIABLE2="VALUE2" uv run skillflaw run --env-file .envThe command-line variables override matching variables in the
.envfile. Expose your environment variables to SkillFlaw in a manner that best suits your own environment. -
Confirm that SkillFlaw successfully sourced the global variables from the environment:
-
In the SkillFlaw header, click your profile icon, and then select Settings.
-
Click Global Variables, and then make sure that your environment variables appear in the Global Variables list.
-
After starting SkillFlaw, go to your SkillFlaw Settings to confirm that the variables were created.
Only the Name and Value are taken from the environment. You can edit the variables in your SkillFlaw Settings if you want to configure additional options, such as the Apply To Fields option.
Global variables sourced from the environment are assigned the Credential type, which masks the values in the visual editor. However, SkillFlaw automatically encrypts all global variables stored in the database.
Disallow global variables from the environment
If you want to explicitly prevent SkillFlaw from sourcing global variables from the environment, set SKILLFLAW_STORE_ENVIRONMENT_VARIABLES=False in your .env file.
Use environment variables for missing global variables
If you want to automatically set fallback values for your global variables to environment variables, set SKILLFLAW_FALLBACK_TO_ENV_VAR=True in your .env file.
When this setting is enabled, if a global variable isn't found, SkillFlaw attempts to use an environment variable with the same name as a backup.
For example, assume you have the following SkillFlaw .env configuration, and your flow has a component that expects a WATSONX_API_KEY global variable:
_10SKILLFLAW_FALLBACK_TO_ENV_VAR=True_10WATSONX_PROJECT_ID=your_project_id_10WATSONX_API_KEY=your_api_key
When you run the flow, if there is no global variable named WATSONX_API_KEY, SkillFlaw looks for an environment variable named WATSONX_API_KEY.
In this example, SkillFlaw uses the WATSONX_API_KEY value from the .env to run the flow.