> 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/prompting-and-workflow-best-practices-decipher.md).

# Prompting & Workflow Best Practices (Decipher)

This document outlines prompting patterns and workflow practices that produce the most reliable programming output on Metaforms.

Many programmers initially approach Metaforms without being detailed in instruction. However, Metaforms performs best when instructions are explicit, scoped, and structured.

The prompt practices shared in this document are based on observations from real Metaforms users and are intended to help the teams improve programming accuracy, reduce debugging time, and increase speed.

#### Core Principle: Explicit Instructions, Including Constraints

Metaforms performs best when you describe the intended outcome clearly before generation. The clearer the instruction, the higher the accuracy of Metaforms output

| **Incorrect/Non-Ideal Workflow**         | **Ideal Workflow**                         |
| ---------------------------------------- | ------------------------------------------ |
| Generate everything and fix errors later | Generate limited questions in batches      |
| Short instructions                       | Explicit instructions                      |
| Debug code line-by-line                  | Edit with AI across XML for similar change |
| Edit with AI for very small changes      | Manually fix if takes less than 5 seconds  |
| Implicit assumptions                     | Explicit constraints                       |

#### Writing Good Prompts – Examples…&#x20;

**Task:** Generating the next 3–5 questions from the questionnaire and program them in the survey using the correct XML structure.<br>

1. **Constraints:**
   1. Follow the survey programming syntax.
   2. Maintain correct question numbering and labels.
   3. Ensure all XML tags are properly structured.
   4. Apply existing survey logic and formatting standards.
2. **Focus:**
   1. Only generate the next 3–5 questions from the questionnaire.
3. **Dont’s:**
   1. Aim to modify previously generated questions, logic, or earlier survey sections.
4. **Good Prompt:**
5. Generate the next 3 questions (Q12–Q14) using the questionnaire, maintaining the XML syntax, formatting, and the same numeric validation structure used earlier.

**Task:** Reviewing the recently generated questions and correct any syntax, validation, or tag errors so they do not repeat in later generations.<br>

1. **Constraints:**
   1. Ensure all XML tags are properly opened and closed.
   2. Remove unnecessary tags such as \</> within validation or exec blocks.
   3. Maintain the existing question logic and numbering.
2. **Focus:**
   1. Fix only the issues present in the selected generation.&#x20;
3. **Dont’s:**
   1. Do not regenerate the questions. Select and edit instead.&#x20;
4. **Good Prompt:**
   1. Review Q15–Q17 and fix XML syntax, ensuring tags are properly opened/closed and vector logic is used for validations without changing the question logic.

**Task:** Generating the JavaScript logic required for a question behavior basis on the provided structure.<br>

1. **Constraints:**
   1. Follow standard JavaScript practices.
   2. Use the correct question IDs or classes from the HTML structure.
   3. Ensure the script does not interfere with existing survey logic.
2. **Focus:**
   1. Only generate the JavaScript logic required for the specified question functionality.
3. **Dont’s:**
   1. Do not modify the HTML structure or other survey questions.
4. **Good Prompt:**
   1. Create JavaScript for Q39 so selecting the checkbox in column 2 automatically selects column 1, using the existing HTML classes without affecting other questions. (User Task: add the relevant HTML code using Inspect Element.)

**Task:** Creating the hidden variables and calculation logic needed to compute values based on provided rules or table.

1. **Constraints:**
   1. Use hidden variables for calculations where required.
   2. Ensure calculations match the rules provided in the questionnaire.
   3. Maintain consistent naming conventions for hidden variables.
2. **Focus:**
   1. Only implement the hidden variable logic for the specified question.
3. **Dont’s:**
   1. Do not modify question wording or answer options.
4. **Example Prompt:**
   1. Generate S7b using hidden variables hS7bx1 and hS7bx2, calculating values based on the scoring table without modifying the visible question. (User task: Also, explain the logic used for hS7bx1 and hS7bx2)

\ <br>

**Task:** Update the generated questions to ensure they follow the project’s programming standards and coding rules.

1. **Constraints:**
   1. Maintain existing question structure and numbering.
   2. Apply the required survey formatting and validation standards.
   3. Ensure no new syntax errors are introduced.
2. **Focus:**
   1. Apply the required updates only to the specified questions.
3. **Dont’s:**
   1. Do not regenerate questions or modify unrelated sections.
4. **Good Prompt:**
   1. Update Q21–Q23 to follow the project’s standard numeric validation and match the formatting and XML structure used in earlier numeric questions.


---

# 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/prompting-and-workflow-best-practices-decipher.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.
