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

# Knowledge Prompts: Reusable Agent Instruction Templates

> Create and manage reusable prompt templates in Layest. Share prompts across agents, use variables for dynamic content, and build a team prompt library.

Knowledge prompts are reusable instruction templates stored centrally in your Layest workspace. Instead of writing the same system instructions from scratch in every agent, you compose a prompt once, store it in the prompt library, and attach it to as many agents as you need. When the underlying instructions need to change—a new company policy, a refined tone, an updated process—you update the prompt in one place and every agent that references it picks up the change automatically.

## Create a new prompt template

<Steps>
  <Step title="Navigate to the prompt library">
    In the left sidebar, click **Knowledge → Prompts**, then click **+ New Prompt**.
  </Step>

  <Step title="Name and describe the prompt">
    Give the prompt a clear, specific name (for example, `Customer Support – Tone Guide`) and add an optional description so teammates understand when to use it.
  </Step>

  <Step title="Write the prompt content">
    Type or paste your instructions into the editor. Use plain prose, markdown, or a mix—the editor renders a live preview as you type.
  </Step>

  <Step title="Add tags">
    Apply one or more tags to help your team find the prompt later (for example, `support`, `tone`, `onboarding`).
  </Step>

  <Step title="Save the prompt">
    Click **Save Prompt**. The prompt is now available to attach to any agent in the workspace.
  </Step>
</Steps>

## Use variables in prompts

Variables let you inject dynamic values into a prompt at runtime, turning a static template into a flexible instruction set. Wrap any variable name in double curly braces:

```text theme={null}
You are a support agent helping {{customer_name}} from {{company_name}}.
Their current plan is {{plan_tier}}. Always address them by first name
and tailor your responses to their plan level.
```

When an agent runs with this prompt attached, Layest substitutes each `{{variable}}` with the corresponding value from the agent's input or from the trigger payload. If a variable is missing at runtime, Layest leaves a warning in the run trace so you can identify gaps in your data mapping.

**Rules for variable names:**

* Use lowercase letters, numbers, and underscores only.
* No spaces: use `customer_name`, not `customer name`.
* Keep names descriptive—`{{ticket_subject}}` is clearer than `{{ts}}`.

## Attach a prompt to an agent

<Steps>
  <Step title="Open the agent editor">
    Navigate to **Agents**, select the agent you want to configure, and click the **Prompts** tab.
  </Step>

  <Step title="Add a prompt">
    Click **+ Add Prompt** and search for the prompt by name or tag. Select it from the results.
  </Step>

  <Step title="Set the prompt role">
    Choose where the prompt is injected into the agent's context:

    * **System** – Prepended as the system message, setting the agent's overall persona and rules.
    * **Pre-task** – Injected before each task or user message, providing task-specific instructions.
    * **Post-task** – Appended after the agent's response, useful for formatting rules or sign-off instructions.
  </Step>

  <Step title="Map variable values">
    If the prompt contains variables, the editor shows a variable mapping panel. Bind each variable to an agent input, a trigger payload field, or a static value.
  </Step>

  <Step title="Save the agent">
    Click **Save**. The prompt is active on the next run.
  </Step>
</Steps>

## Organize prompts with tags and categories

As your prompt library grows, tags and categories keep it navigable. From **Knowledge → Prompts**:

* **Filter by tag** – Click any tag chip in the sidebar to show only prompts with that tag.
* **Sort** – Sort by name, last modified date, or number of agents using each prompt.
* **Archive** – Archive prompts that are no longer in active use. Archived prompts remain attached to agents that already reference them but are hidden from the browsing view.

Establishing a tagging convention early—by function (`tone`, `rules`, `persona`), by team (`support`, `sales`, `engineering`), or by status (`draft`, `approved`, `deprecated`)—saves significant time as the library scales.

## Share prompts across the workspace

Every prompt you create is automatically visible to all members of your Layest workspace. There are no per-prompt sharing settings—the library is intentionally shared to encourage reuse and consistency.

To control who can create or edit prompts, use workspace roles:

* **Editor** and above can create, edit, and delete prompts.
* **Viewer** can browse and attach prompts to agents but cannot modify them.

## Example prompt template

Here is a complete example of a prompt template using variables and structured instructions:

```text theme={null}
You are {{agent_name}}, a friendly and professional support specialist for {{company_name}}.

## Your responsibilities
- Answer questions about {{product_name}} clearly and accurately.
- Escalate issues you cannot resolve to the human support team.
- Never speculate about pricing, roadmap, or legal matters—direct those
  questions to the appropriate team.

## Tone
- Use plain language. Avoid jargon unless the user uses it first.
- Be concise. Aim for responses under 150 words unless detail is necessary.
- Always end your first response by asking if there is anything else you can help with.

## Constraints
- Do not discuss competitors.
- Do not share internal documentation links.
- If the user appears frustrated, acknowledge their experience before
  offering a solution.
```

<Tip>
  Layest keeps a full version history for every prompt. Click **Version History** on any prompt to see a timestamped list of every saved revision, who made the change, and a diff of what changed. You can restore any previous version with one click—making it safe to experiment and iterate without fear of losing a prompt that was working well.
</Tip>
