# define

Learn how to set variables in the current scope.

This action sets variables in the current scope, accessible through the `this` keyword in [expressions](/reference/cli/templates/expressions).

## Example

The following template defines a variable and uses it in a subsequent action:

**template.json5**

```json5
{
  "$schema": "https://schema.croct.com/json/v1/template.json",
  "title": "Define example",
  "description": "Defines a variable and prints it.",
  "actions": [
    {
      "name": "define",
      "variables": {
        "greeting": "Hello, world!"
      }
    },
    {
      "name": "print",
      "semantics": "info",
      "message": "${this.greeting}"
    }
  ]
}
```

Variables remain available to all subsequent actions in the template.

## Properties

These are the supported properties:

- `name`: `string`

  The action identifier. Always `define` for this action.

- `variables`: `object`

  A map of variable names to values.

  Keys are variable names and values can be literals or [expressions](/reference/cli/templates/expressions).

## Explore

- [Test](/reference/cli/templates/actions/test): Learn how to use variables in conditions.
- [Repeat](/reference/cli/templates/actions/repeat): Learn how to iterate over a defined list.
- [Import](/reference/cli/templates/actions/import): Learn how to import and execute another template.
- [Prompt](/reference/cli/templates/actions/prompt): Learn how to prompt the user for a value.
