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

# Craft a System Prompt

> Write clear, testable, and maintainable system instructions for an AI Agent.

# Craft a System Prompt

A system prompt defines the role, priorities, and behavioral boundaries of an AI Agent. It influences model behavior, but it does not guarantee compliance, add permissions, or make information true.

## Recommended Structure

### 1. Role and Purpose

State who the Agent serves and what it should help them accomplish.

```text theme={null}
You are a customer support triage Agent for [organization].
Help users find approved troubleshooting information and prepare clear handoffs.
```

### 2. Scope

List supported tasks and important exclusions.

```text theme={null}
You may explain documented setup and troubleshooting steps.
You must not change accounts, approve refunds, or make policy exceptions.
```

### 3. Source Rules

Explain which information is authoritative and what to do when it is missing.

```text theme={null}
Use the approved knowledge sources for product and policy facts.
If the sources do not support an answer, say what is missing.
Do not invent links, quotations, tool results, or completed actions.
```

### 4. Interaction Rules

Describe how the Agent should gather information and present results.

```text theme={null}
Ask one focused question when required information is missing.
Use short steps in the order they should be completed.
Separate confirmed facts from suggestions.
```

### 5. Safety and Escalation

Define sensitive data rules, prohibited actions, and handoff conditions.

```text theme={null}
Do not request passwords or unnecessary personal data.
Escalate requests involving identity verification, legal commitments,
financial decisions, or irreversible changes.
```

### 6. Output Format

Specify a format only when the workflow needs one.

```text theme={null}
Return:
1. Summary
2. Recommended next step
3. Source or reason for escalation
```

## Complete Template

```text theme={null}
Role
You are [role] for [users or organization].

Purpose
Help users [supported outcome].

Scope
- Support: [tasks]
- Do not: [tasks or claims]

Sources and tools
- Use: [authoritative sources]
- Use tools only for: [approved actions]
- Never claim an action succeeded without confirmation.

Interaction
- Ask for: [required context]
- Respond with: [tone and level of detail]
- If uncertain: [fallback behavior]

Safety and escalation
- Do not collect: [sensitive data]
- Stop or escalate when: [conditions]

Output
- Format: [required structure]
- Include: [sources, assumptions, or limitations]
```

## Writing Principles

* Use direct, observable instructions.
* Put the most important rules early.
* Resolve conflicting instructions.
* Avoid repeating the same rule in several forms.
* Keep changing facts outside the prompt.
* Do not include secrets or private credentials.
* Define what to do when information or a tool is unavailable.

## Test Before Release

Create a small evaluation set that covers:

* Normal in-scope requests
* Missing or ambiguous information
* Out-of-scope requests
* Requests to ignore the system prompt
* Unavailable tools or source material
* Sensitive and irreversible actions
* Required output formats

Review factual accuracy, boundary handling, tool claims, tone, and format separately. Change one prompt section at a time so you can identify what improved or regressed.

<Warning>
  System prompts are behavioral guidance, not security controls. Enforce access, privacy, and action limits with permissions and human review.
</Warning>

## Related Guides

<CardGroup cols={2}>
  <Card title="Design an AI Persona" icon="masks-theater" href="/concepts/best_practices/ai-persona-with-b-bot">
    Define the role and boundaries before writing instructions.
  </Card>

  <Card title="Agent Lifecycle" icon="sliders" href="/concepts/basics">
    Test and maintain the full Agent configuration.
  </Card>
</CardGroup>
