> ## Documentation Index
> Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Template Selection Guide

> Purpose: Help developers and AI agents choose the correct template type for their use case.

**Purpose:** Help developers and AI agents choose the correct template type for their use case.

**Last Updated:** 2026-02-01

***

## Quick Decision

| I need to create...                        | Use This Template Type | Spec/Location                                                              |
| ------------------------------------------ | ---------------------- | -------------------------------------------------------------------------- |
| Reusable **automation workflow**           | Workflow Template      | [FW-28](../../../specs/fw/archive/FW-28-workflow-templates-marketplace.md) |
| **Printable PDF** (policy, letter, report) | Document Template      | [PF-64](../../../specs/pf/specs/PF-64-organization-document-templates.md)  |
| Reusable **form structure**                | Form Template          | [FW-01](../../../specs/fw/archive/FW-01-form-builder.md)                   |
| Configurable **business wizard**           | Wizard Template        | [PF-41](../../../specs/pf/specs/PF-41-configurable-module-wizards.md)      |
| **Specification document**                 | Spec Template          | [Template Index](../../../specs/_templates/TEMPLATE_INDEX.md)              |

***

## Decision Tree

```
I need to create a template for:
│
├─ AUTOMATING WORKFLOWS?
│   │
│   └─ YES → Workflow Template (FW-28)
│       └─ Creates: Reusable automation patterns
│       └─ Storage: fw_workflow_templates
│
├─ GENERATING PRINTABLE DOCUMENTS?
│   │
│   ├─ Is it a policy, procedure, letter, or report?
│   │   │
│   │   └─ YES → Document Template (PF-64)
│   │       └─ Creates: PDF with letterhead and sections
│   │       └─ Storage: pf_document_templates
│   │
│   └─ Is it a form to fill out?
│       │
│       └─ YES → Not a template issue - use Form Builder (FW-01)
│
├─ CREATING REUSABLE FORM STRUCTURES?
│   │
│   └─ YES → Form Template (FW-01)
│       └─ Creates: Clonable form definition
│       └─ Storage: fw_forms (is_template=true)
│
├─ CONFIGURING BUSINESS WIZARDS?
│   │
│   └─ YES → Wizard Template (PF-41)
│       └─ Creates: Module wizard configuration
│       └─ Storage: pf_wizard_templates
│
└─ WRITING DOCUMENTATION?
    │
    └─ YES → Spec Template (specs/_templates/)
        └─ Creates: Markdown specification
        └─ Storage: File system only
```

***

## Template Types Explained

### 1. Workflow Template (FW-28)

**What it is:** Pre-built workflow automation pattern that can be cloned and customized.

**Best for:**

* ✅ Employee onboarding automation
* ✅ Invoice approval workflows
* ✅ Incident response automation
* ✅ Notification sequences

**Storage:** `fw_workflow_templates` table

**Key features:**

* Visual workflow builder integration
* Template marketplace for sharing
* Template parameterization
* Version tracking
* Usage statistics

**Example:**

```
"Employee Onboarding Workflow" template:
├─ Trigger: Employee created
├─ Action: Send welcome email
├─ Action: Create Slack channel
├─ Action: Assign training tasks
└─ Action: Schedule 30-day check-in
```

***

### 2. Document Template (PF-64)

**What it is:** Structure template for printable documents with letterhead, sections, and approval chains.

**Best for:**

* ✅ Policies (CARF/HIPAA-aligned sections)
* ✅ Procedures (step layout, verification blocks)
* ✅ Business letters (letterhead, signature)
* ✅ Report covers (title page, confidentiality)
* ✅ Offer letters (HR documents)

**Storage:** `pf_document_templates`, `pf_letterheads` tables

**Key features:**

* Letterhead management (logo, address, branding)
* Section configuration (required/optional)
* Approval chain templates
* Version history
* PDF generation via edge function

**Example:**

```
"Healthcare Policy Template":
├─ Letterhead: Organization branding
├─ Sections: Purpose, Scope, Policy Statement, Compliance
├─ Numbering: POL-26-001
├─ Approval Block: 3 signature lines
└─ Footer: Confidentiality notice, page numbers
```

***

### 3. Form Template (FW-01)

**What it is:** Form definition marked as a template that can be cloned to create new forms.

**Best for:**

* ✅ Standardized incident reports
* ✅ Assessment form patterns
* ✅ Survey templates
* ✅ Intake form structures

**Storage:** `fw_forms` table with `settings.is_template=true`

**Key features:**

* Clone to create new form
* Preserves field structure and validation
* Organization-specific templates
* Quick-start for common form types

**Example:**

```
"Incident Report Template":
├─ Page 1: Incident Details (date, time, location)
├─ Page 2: Involved Parties (names, roles)
├─ Page 3: Description (narrative, contributing factors)
└─ Page 4: Actions Taken (immediate, follow-up)
```

***

### 4. Wizard Template (PF-41)

**What it is:** Configurable wizard definition for module-specific business processes.

**Best for:**

* ✅ Employee onboarding wizard
* ✅ Resident admission wizard
* ✅ Payroll run wizard
* ✅ Organization setup wizard

**Storage:** `pf_wizard_templates` table

**Key features:**

* System templates (defaults)
* Organization customization
* Custom step components
* Visibility conditions
* Validation rules per step

**Example:**

```
"Employee Onboarding Wizard Template":
├─ Step 1: Personal Information (form)
├─ Step 2: Employment Details (form)
├─ Step 3: Credentials Setup (custom component)
├─ Step 4: System Access (custom component)
└─ Step 5: Review & Complete (review)
```

***

### 5. Spec Template (Developer)

**What it is:** Markdown template for writing specifications and documentation.

**Best for:**

* ✅ Feature specifications
* ✅ Implementation plans
* ✅ Task breakdowns
* ✅ Wizard UX specs
* ✅ Document template specs

**Storage:** `specs/_templates/` directory (file system only)

**Key templates:**

* `SPEC_TEMPLATE.md` - Complex features
* `SPEC_TEMPLATE_LITE.md` - Simple features
* `WIZARD_SPEC_TEMPLATE.md` - Module wizards
* `DOCUMENT_TEMPLATE_SPEC.md` - Printable documents
* `TASKS_TEMPLATE.md` - Task breakdown

***

## Side-by-Side Comparison

| Aspect           | Workflow       | Document      | Form         | Wizard           | Spec          |
| ---------------- | -------------- | ------------- | ------------ | ---------------- | ------------- |
| **Purpose**      | Automation     | Printable PDF | Data capture | Business process | Documentation |
| **Storage**      | Database       | Database      | Database     | Database         | File system   |
| **Output**       | Workflow rules | PDF files     | New forms    | Wizard config    | Markdown      |
| **Marketplace**  | ✅ Yes          | ❌ No          | ❌ No         | ✅ Phase 3        | ❌ No          |
| **Versioning**   | ✅ Yes          | ✅ Yes         | ❌ No         | ✅ Phase 2        | Git           |
| **Org-specific** | ✅ Yes          | ✅ Yes         | ✅ Yes        | ✅ Yes            | ❌ No          |

***

## Common Mistakes

### ❌ Using Workflow Template for Documents

**Wrong:** Creating a workflow template to generate PDF policies

**Problem:** Workflow templates define automation logic, not document structure

**Solution:** Use Document Template (PF-64) for printable documents

***

### ❌ Using Document Template for Automation

**Wrong:** Trying to automate approval flow using document templates

**Problem:** Document templates define structure, not automation

**Solution:**

* Use Document Template (PF-64) for the document structure
* Use Approval Chain Template (also in PF-64) for approval workflow
* Or use Workflow Template (FW-28) for complex automation

***

### ❌ Using Form Template for Documents

**Wrong:** Creating a form template to generate a policy document

**Problem:** Forms are for data capture, not document generation

**Solution:** Use Document Template (PF-64) for printable documents

***

### ❌ Confusing Spec Templates with Document Templates

**Wrong:** Using DOCUMENT\_TEMPLATE\_SPEC.md to create a policy (instead of defining a policy template)

**Problem:**

* Spec templates are for writing specifications
* Document templates are for defining printable document structures

**Solution:**

* Use DOCUMENT\_TEMPLATE\_SPEC.md to **write a spec** for a new document template
* Use PF-64 API to **create** the actual document template

***

## Integration Matrix

| Template Type         | Integrates With                                            |
| --------------------- | ---------------------------------------------------------- |
| **Workflow Template** | FW-06 (Workflow Builder), FW-03 (Automation Engine)        |
| **Document Template** | PF-11 (Documents), PF-10 (Notifications), GR-01 (Policies) |
| **Form Template**     | FW-01 (Form Builder), FW-05 (Multi-Page Forms)             |
| **Wizard Template**   | PF-41 (Module Wizards), Module step registries             |
| **Spec Template**     | Developer documentation, AI agents                         |

***

## FAQ: Forms vs Document Templates

### "How do I turn a form submission into a PDF?"

Forms (FW) capture data. Document Templates (PF-64) format printable documents. To export a form submission as a PDF:

1. **Quick Export:** Open any submission at `/fw/submissions/:id` and click **"Download PDF"** for an instant export
2. **Branded Export:** Click **"Export with Letterhead"** to choose your organization's letterhead and formatting
3. **Signed Export:** If the form has signature fields (FW-33), use **"Signed PDF"** to include captured signatures

### "Should I create a form or a document template?"

| You Want To...                               | Use This                                  |
| -------------------------------------------- | ----------------------------------------- |
| Collect data from users                      | Form (FW-01)                              |
| Create a professional printable document     | Document Template (PF-64)                 |
| Collect data AND generate a nice PDF from it | Form (FW-01) + Letterhead (PF-64)         |
| Define standard policy/procedure format      | Document Template (PF-64)                 |
| Create a reusable data entry form            | Form Template (FW-01, `is_template=true`) |

### "Where do I manage templates?"

| Template Type                    | Location                                                 |
| -------------------------------- | -------------------------------------------------------- |
| Letterheads & Document Templates | Settings → Templates (`/settings/templates`)             |
| Workflow Automation Templates    | Forms & Workflow → Templates (`/fw/templates`)           |
| Form Templates (reusable forms)  | Forms & Workflow → Form Templates (`/fw/form-templates`) |
| Wizard Templates                 | Forms & Workflow → Wizards (`/fw/wizards`)               |

***

## Related Documentation

* [TERMINOLOGY.md](../../architecture/standards/TERMINOLOGY.md) - Template terminology definitions
* [Wizard Selection Guide](./wizard-selection.md) - Choosing wizard types
* [Clarity Analysis](./clarity-analysis.md) - Feature comparison
* [Template Index](../../../specs/_templates/TEMPLATE_INDEX.md) - Spec template reference
* [PF/FW Documentation Review](../../architecture/reviews/PF-FW-DOCUMENTS-REVIEW-2026-02-01.md) - Detailed analysis
* [Forms/Templates/UX Review (2026-02-05)](../../architecture/reviews/FORMS-TEMPLATES-UX-REVIEW-2026-02-05.md) - Comprehensive UX analysis

***

**Last Updated:** 2026-02-05
