> For the complete documentation index, see [llms.txt](https://help.metaforms.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.metaforms.ai/templates.md).

# 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="/files/vEEIRSAlpmQpBiD9Sx0U" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/97q0UT7aIjNT5B2pBi7n" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/C88LWllOpREZcUnz6SSL" 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="/files/EFRVhPGOKmazwDegm5NK" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.metaforms.ai/templates.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
