Lesson 1 of 4 Prompt Engineering for FMs

Writing System Prompts with an Instruction Framework

This lesson explains an instruction framework, a standard way of writing the instructions that control an FM's behaviour, and how templates and guardrails complete it.

Learning outcomes

After completing this lesson, you will be able to:

  • Write a system prompt with role, rules, format and boundaries.
  • Use shared templates for consistency.
  • Enforce what instructions cannot guarantee with guardrails.

Anatomy of a system prompt

The system prompt sets the context for the whole conversation and is passed separately from user messages (the system field in the Converse API). A complete system prompt defines the role ("You are a claims assistant for Example Insurance staff"), the task and audience, the rules (answer only from the provided documents, never give legal advice, ask for the policy number if it is missing), how to handle uncertainty ("If the documents do not contain the answer, say so"), the tone and the output format.

You are a claims assistant for Example Insurance adjusters.
Task: answer questions about policy coverage using only the documents in <documents>.
Rules:
- If the documents do not contain the answer, reply "Not found in the provided policies."
- Do not give legal advice or predict claim outcomes.
- Cite the document title for every statement.
Format: at most 120 words, then a "Sources:" line listing document titles.

The following diagram shows the parts of a system prompt with an example of each.

The parts of a complete system prompt: the role, the task and audience, the rules, how to handle uncertainty, the tone and the output format. The system prompt is passed separately from user messages, and a guardrail enforces what the prompt can only request.
The example wording is illustrative.
Sort into groups

Parts of a system prompt

Exam skills 1.6.1

Decide which part of a system prompt each sentence belongs to.

Log in to try this activity Interactive activities are free with an account.

Templates for consistency

When each developer writes prompts from scratch, the same application ends up with different wording, rules and output formats in different places, and an improvement made in one prompt never reaches the others. A prompt template fixes the structure of a prompt and leaves variables for the parts that change, such as the retrieved documents, the user's question and the customer's tier.

Templates ensure that every request includes the required rules and context, that format instructions are identical across applications, and that an improvement is made once and applied everywhere. Amazon Bedrock Prompt Management stores templates with variables written as {{variable}}, keeps immutable versions of them and lets applications invoke a specific version, so that approved role definitions and rules are enforced across teams rather than copied by hand.

The following diagram compares scattered copies of a persona prompt in five applications with one governed template.

Fixing drifting role definitions. Five applications each edited their own copy of a persona, and some copies still allowed discussing competitor products. One approved template in Prompt Management, invoked by version ARN everywhere, and a guardrail with a denied topic for competitor products keep the persona and the policy consistent.
The guardrail enforces the policy that the prompt only states.

Guardrails complete the framework

Instructions influence a model's behaviour but cannot guarantee it. Users can try to override them with prompt injection, and models occasionally ignore an instruction, especially in long or unusual conversations. A safety rule written only in the system prompt is therefore a request, not a control.

Amazon Bedrock Guardrails enforce responsible AI policies independently of the prompt. A guardrail evaluates both the user's input and the model's output and blocks denied topics, filters harmful content, masks or blocks personal information and checks that answers are grounded in the supplied sources, regardless of what the prompt says. A complete instruction framework therefore combines three layers: the system prompt defines behaviour and format, templates make it consistent, and guardrails enforce the rules that must never be broken. The following table summarises the layers.

LayerControlsGuarantee
System promptRole, rules, tone, formatStrong influence, not enforcement
Prompt template (Prompt Management)Consistent structure and variables across appsSame instructions everywhere
Response format specificationMachine-readable outputEnforced when combined with schema validation
GuardrailsTopics, harmful content, PII, groundingPolicy enforcement on input and output
True or false

Instructions and guardrails

Exam skills 1.6.1 · 3.1.1

Check what system prompt instructions can and cannot guarantee.

Log in to try this activity Interactive activities are free with an account.
Worked example

Role definitions drifting

Five applications use the same customer-service persona, but each team edited its own copy of the system prompt. Some versions still allow discussing competitor products, which policy now forbids.

The fix has two parts: a single approved system prompt template in Prompt Management that all applications invoke by version ARN, and a guardrail with a denied topic for competitor products, so the policy holds even if a prompt is edited.

Check yourself

A system prompt says "never give medical advice". Is that enough to enforce the rule?

Show answer

No. Prompts influence behaviour, but guardrails enforce it, so use a denied topic in Bedrock Guardrails.

Exam Tips

Remember for the exam

  • System prompt: role, task, rules, uncertainty handling, tone, format.
  • Shared, versioned templates: Prompt Management.
  • Prompts influence; guardrails enforce.