> 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/survey-programming-decipher/legacy-flow/ai-rules.md).

# AI Rules

#### **Overview**

AI Rules allow you to define and organise programming logic that guides Metaforms’ for survey XML generation. Each folder contains one or more AI Rules, along with shared instructions that help the Metaforms to generate accurate XML for your hosting platform. These Folders help you define and set AI rules into categories that an individual survey programmer, a client or a team may need.

#### **What an AI Rule Folder Includes**

* Folder-level instructions
* A collection of AI Rules
* Hosting platform selection
* Usage insights
* Version history for each rule

#### **AI Rule Folder Types**

| Folder Type     | Behavior                                                                                                    |
| --------------- | ----------------------------------------------------------------------------------------------------------- |
| **Always**      | Applied to every project. Cannot be removed during project creation.                                        |
| **If Selected** | Optional. Can be checked or unchecked during project creation. Pre-selected only when linked to a Template. |

#### **Creating an AI Rule Folder**

1. **On Survey Programming** Dashboard go to **AI Rules**
2. Click **Create**
3. Enter a **Folder Name**
4. Select **When to Use** (Always or If Selected)
5. Choose **Who Can Edit** the folder
6. Choose the **Survey Hosting Platform**
7. Click **Create**

<figure><img src="/files/5oKiewhqhFcRDEYSxZLy" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
"Always" Folders would be applied to every project and cannot be removed unless archived (deleted).
{% endhint %}

#### **Adding AI Rules to a Folder**

1. Open the folder from the AI Rules list
2. Click **Create Rule**
3. Enter a **Rule Name**
4. Add:
   * **Explanation**
   * **Examples**
   * **XML instructions**
5. Save the rule

<figure><img src="/files/xttDWpQ8BwmvgQ7kRdAG" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/x8avwp4D2zlNF6wnulq6" alt=""><figcaption></figcaption></figure>

**AI Rules** should be Clear, detailed instructions that guide how questions should be interpreted and generated.

* **XML Examples** – Sample question structures that demonstrate the expected output.
* **Explanations** – Supporting notes that clarify how rules should be applied.
* **Instructions** - An explanation on how AI should generate code when this template is used.

The better defined your rules and examples, the more accurate and consistent your outputs will be.

#### **Applying AI Rule Folders in a Project**

When creating a new project:

1. Select a **Template** (optional)
2. On the AI Rules screen:
   * *"Always" folders* are auto-applied
   * *"If Selected" folders* can be checked or unchecked
3. Continue to project creation

<figure><img src="/files/8mlVIiQeSCDiDeApas3G" alt=""><figcaption></figcaption></figure>

After the project is created, you can still:

* Add or remove folders from the **AI Rule Folders** button in the project

![](/files/O8l9kY3jDtAQRZlsnfb4) ![](/files/nsb9HxSGWljTxb7qsU2i)

## **Improving AI Rules (Continuous Tuning Process)**

To update an AI rule effectively:

1. **Check if the rule already exists.**
   * If it does but isn’t working well, identify the failing part and update the explanation.
2. **Look for conflicting examples.**
   * Remove or reword anything that contradicts your intended logic.
3. **Improve clarity.**
   * If a rule works but isn’t well documented, add it as a distinct entry under AI Rules.
4. **Add new rules as needed.**
   * Clearly define any missing logic and support it with relevant examples and explanations.
5. **Test changes.**
   * Save the updated AI rule, refresh the survey, and re-generate the same questions to confirm that the behaviour has been fixed.

{% hint style="info" %}
This is a **continuous improvement** process. Every refinement reduces future manual intervention and speeds up programming.
{% endhint %}


---

# 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:

```
GET https://help.metaforms.ai/survey-programming-decipher/legacy-flow/ai-rules.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
