# Prompt Engineering

Prompt engineering is how you turn your expertise into **reliable outputs**. In FormWise, that means writing instructions the model can follow every time.

Use this page as your checklist before you publish a SmartForm or CoPilot.

### The mental model

Every generation is the same loop:

1. **Inputs** (form fields or the chat conversation)
2. **Context** (datasets, backend data sources, crawled URLs, search results)
3. **Instructions** (your prompt)
4. **Output** (what the user sees)

Your job is to control steps 2 and 3.

### SmartForms vs CoPilots (what changes)

#### SmartForms

SmartForms shine when you want **structured input → structured output**. You control the user inputs and the format.

Typical prompt goals:

* Generate a doc, plan, or checklist
* Produce content in a specific format
* Run multi-step workflows using prompt chaining

#### CoPilots

CoPilots shine when you want **guided conversation**. You control the assistant’s role, boundaries, and behavior.

Typical prompt goals:

* Ask smart follow-ups
* Diagnose a situation before answering
* Keep the user on a specific workflow

### Prompt anatomy that works

Use this structure in both SmartForms and CoPilots:

1. **Role**: who the assistant is
2. **Goal**: what “success” looks like
3. **Inputs**: what the model will receive
4. **Process**: how to think (steps, checks, constraints)
5. **Output format**: exact structure, headings, bullets, JSON-like blocks, etc.

{% hint style="info" %}
If you care about consistency, over-specify the **output format**. Format beats “be helpful” every time.
{% endhint %}

### The 80/20 rules (use these everywhere)

* **Write for a junior assistant.** No implied steps.
* **One task per step.** Split big jobs into multiple prompt steps.
* **Provide context before variables.** Tell the model what `@step_1` represents.
* **Add constraints.** Length, tone, audience, and do/don’t lists.
* **Force a structure.** Headings and bullets reduce randomness.

### Prompt chaining (SmartForms)

Prompt chaining lets you break a workflow into steps. Each step can use the output of earlier steps.

Common pattern:

* Step 1: extract or summarize
* Step 2: generate the main output
* Step 3: rewrite, format, or repurpose

{% hint style="warning" %}
Each step is a separate AI call. More steps means more tokens and more timeout risk.
{% endhint %}

### Quick links

<table data-view="cards"><thead><tr><th>Guide</th><th data-card-target data-type="content-ref">Open</th></tr></thead><tbody><tr><td><strong>Intro to Prompt Chaining</strong></td><td><a href="/spaces/0Lugni2T5TewiPeYs1ka/pages/uw83VHOaqGJUHroCW8Gh">/spaces/0Lugni2T5TewiPeYs1ka/pages/uw83VHOaqGJUHroCW8Gh</a></td></tr><tr><td><strong>Advanced Prompt Chaining</strong> (tokens, structure, strategy)</td><td><a href="/spaces/0Lugni2T5TewiPeYs1ka/pages/VBON8jjIK3yCIbUTpwZj">/spaces/0Lugni2T5TewiPeYs1ka/pages/VBON8jjIK3yCIbUTpwZj</a></td></tr></tbody></table>

### Practical templates (copy, then adapt)

#### SmartForm prompt template

```
You are a [role].

Goal:
- Create [output] for [audience] that achieves [objective].

Inputs:
- [Field 1]: @q1answer
- [Field 2]: @q2answer

Rules:
- Use a [tone] tone.
- Avoid [things to avoid].
- If critical info is missing, ask 1–3 clarifying questions.

Output format:
## Summary
- ...

## Recommendations
1. ...
```

#### CoPilot behavior template

```
Role: You are a [role] CoPilot.

Workflow:
1) Ask questions until you have [required info].
2) Confirm the goal in one sentence.
3) Produce the output in the format below.

Boundaries:
- Do not guess facts you cannot verify.
- If unsure, say what you need next.

Output format:
- Short answer
- Step-by-step plan
- Next action
```

### Debugging prompts (fast)

* **Bad structure?** Tighten the output format first.
* **Wrong assumptions?** Add required inputs and clarifying questions.
* **Too long?** Add limits (bullets, word count, “no more than 5 items”).
* **Inconsistent tone?** Define tone + add 1–2 short examples.
* **Hallucinations?** Add data sources, web intelligence, or “cite your source”.


---

# Agent Instructions: 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://manual.formwise.ai/formwise/advanced-features/prompt-engineering.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.
