# Templates

Templates in Metaforms help you apply **consistent data validation logic** across projects by defining how the AI should interpret variables and generate code.\
\
In the context of **Data Processing**, templates consist of two key components:

* **AI Rules** – Instructions that guide how the AI interprets questionnaire variables and generates validation logic.
* **Macros** – Predefined functions or code snippets used for applying common validation patterns across multiple variables or projects.

{% hint style="info" %}
Note : Macros are only available for SPSS Validations
{% endhint %}

### When to Use a Template

During DP project creation, you can select a template in the **Set Up** step. This will:

* Load AI rules and macros into the current project
* Influence how the AI builds validation checks
* Improve consistency and reduce repetitive prompt-writing

## How to create Templates?

* Navigate to Preferences -> Select Templates -> Create Template

<figure><img src="https://1402057010-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgtHd8o9ldznZ1hKHiZvc%2Fuploads%2FxURLdgxs16aax1r8tLmt%2Fimage.png?alt=media&#x26;token=1bf1ffab-e930-40d1-b046-83f4d11dca8c" alt=""><figcaption></figcaption></figure>

* Give your template a name and Choose the Validation Tool (Python/SPSS)

<figure><img src="https://1402057010-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgtHd8o9ldznZ1hKHiZvc%2Fuploads%2FBTlOEYldgWgPUXzpDmfE%2Fimage.png?alt=media&#x26;token=811f9dd3-e1bf-4d9a-99bb-006e2dc0f053" alt=""><figcaption></figcaption></figure>

* Once created, you can setup your AI rules and Macros for every template

<figure><img src="https://1402057010-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgtHd8o9ldznZ1hKHiZvc%2Fuploads%2F3lR7JsSCly6mZBIi01GB%2Fimage.png?alt=media&#x26;token=c4e1cd72-a3d2-40f1-87b3-a3f281f51055" alt=""><figcaption></figcaption></figure>

AI rules allow you to setup specific example scripts and explanations for these examples that can be used to cater specific use cases based on your requirements. Instructions allow you to setup guidelines for how Metaforms should consume these examples.

* You can also use Macros for setting up your validation logic.

<figure><img src="https://1402057010-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgtHd8o9ldznZ1hKHiZvc%2Fuploads%2F0BBTX91FZoXUWzFpZ8PV%2Fimage.png?alt=media&#x26;token=d18f8302-ab21-47b9-ad56-84d594909a0a" alt=""><figcaption></figcaption></figure>
