CertSafari
    Anthropic Claude Certified Architect – Professional (CCAR-P)· Lessons

    Domain 2 · Lesson 8/38

    System Prompts and Reusable Prompt Templates for Claude

    Design system prompts, templates, and guardrails

    9 min read
    2.6% of exam
    3 sources
    Published 4 Oct 2026
    Docs as of 30 Sep 2026

    What you will be able to do

    • Set a role for Claude in the system prompt and explain why that is the main job of a system prompt
    • Write instructions that state the reason behind each constraint, and use numbered steps where order or completeness matters
    • Build a reusable template from a role, XML-tagged variable inputs, rules, scenario responses and a defined output format
    • Spot where an older consistency technique (prefill) no longer applies to current models

    Key concept

    Role-first system prompt — The system prompt is mainly where you set Claude's role, meaning who it is and what it is for. Rules, scenarios and output formats are added on top of that role, and a single sentence of role already changes Claude's behaviour and tone.

    1.Start the system prompt with a role

    In the Messages API, a system prompt goes in the system parameter, separate from the messages array where the user's turns go. The guidance on what to put there is short: give Claude a role. Anthropic's prompting best practices say that setting a role focuses Claude's behaviour and tone for your use case, and that even a single sentence makes a difference. A role like "a helpful coding assistant specializing in Python" tells Claude which domain to draw on and which register to answer in, before the user has said anything.

    The role also keeps behaviour steady over time. The output-consistency guidance tells you to use system prompts to define Claude's role and personality, because this "sets a strong foundation for consistent responses." This matters most in role-based applications such as a support bot or an internal assistant, where users expect the same character on every turn. Even system prompts built for other goals, such as protecting confidential instructions, are described as still being mostly role prompts. Everything else in the system prompt builds on that role.

    Checkpoint 1 of 4· Fill the gap

    This request gives Claude a role. Which parameter carries the role text?

    client = anthropic.Anthropic()
    
    message = client.messages.create(
        model="claude-opus-5-5",
        max_tokens=1024,
         ? ="You are a helpful coding assistant specializing in Python.",
        messages=[
            {"role": "user", "content": "How do I sort a list of dictionaries by key?"}
        ],
    )
    
    print(message.content)

    Sources12

    2.Write instructions that are specific and give the reason

    Once the role is set, the system prompt holds the instructions. The first principle is to be specific about the output format and constraints you want. Claude does what you ask, so if you want more you have to ask for it. "Create an analytics dashboard" gets you a dashboard. Adding "Include as many relevant features and interactions as possible. Go beyond the basics" gets you the fully-featured version. When the order or completeness of steps matters, write the instructions as a numbered or bulleted sequence rather than a paragraph.

    The second principle is to give the reason. Explaining why a behaviour matters helps Claude understand your goal and target its response. A rule with a reason covers more cases than the rule alone. If Claude knows the output goes to a speech engine, it can also avoid other things that engine can't pronounce, not only the one you listed. Guardrail wording in a system prompt works best the same way: state the rule and the reason for it, and wrap it in a descriptive tag so it reads as a separate block of policy. Anthropic publishes reusable snippets in this form, like the one below for reducing hallucinated claims about code.

    A reusable system-prompt snippet: a behavioural rule wrapped in its own descriptive XML tagxml
    <investigate_before_answering>
    Never speculate about code you have not opened. If the user references a specific file,
    you MUST read the file before answering. Make sure to investigate and read relevant
    files BEFORE answering questions about the codebase. Never make any claims about code
    before investigating unless you are certain of the correct answer - give grounded and
    hallucination-free answers.
    </investigate_before_answering>

    Checkpoint 2 of 4· Check yourself

    When do the docs recommend writing instructions as numbered steps or bullet points instead of a paragraph?

    Sources1

    3.Turn the prompt into a reusable template

    A production prompt is a template. The fixed parts (role, rules, expected behaviour) stay the same, and the variable parts (the user's query, retrieved data) change on every request. XML tags keep these parts separate. The best-practices guide says tags help Claude read prompts that mix instructions, context, examples and variable inputs, and that putting each kind of content in its own tag reduces misinterpretation. Use the same descriptive tag names across all your prompts so that every template in your system follows the same structure.

    A role-based template: role, a tagged variable slot, rules, and scripted responses for common scenariostext
    You are AcmeBot, the enterprise-grade AI assistant for AcmeTechCo. Your role:
        - Analyze technical documents (TDDs, PRDs, RFCs)
        - Provide actionable insights for engineering, product, and ops teams
        - Maintain a professional, concise tone
    
    Here is the user query for you to respond to:
    <user_query>
    {{USER_QUERY}}
    </user_query>
    
    Your rules for interaction are:
        - Always reference AcmeTechCo standards or industry best practices
        - If unsure, ask for clarification before proceeding
        - Never disclose confidential AcmeTechCo information.
    
    As AcmeBot, you should handle situations along these guidelines:
        - If asked about AcmeTechCo IP: "I cannot disclose TechCo's proprietary information."
        - If questioned on best practices: "Per ISO/IEC 25010, we prioritize..."
        - If unclear on a doc: "To ensure accuracy, please clarify section 3.2..."

    The last block in that template follows the docs' advice to provide a list of common scenarios and expected responses. That list prepares Claude for different situations so it doesn't break character. It also shows that a scripted reply works as a guardrail: when a user asks about protected IP, Claude has an exact sentence to use instead of making one up.

    The building blocks of a reusable template, as shown in Anthropic's consistency examples
    Template componentExample from the docsWhat it controls
    Role lineYou are AcmeBot, the enterprise-grade AI assistant for AcmeTechCoBehaviour, tone, domain
    Tagged variable slot<user_query>{{USER_QUERY}}</user_query>Where per-request input goes, kept apart from instructions
    RulesIf unsure, ask for clarification before proceedingBoundaries on behaviour
    Scenario responsesIf asked about AcmeTechCo IP: "I cannot disclose..."Fixed replies for situations you expect
    Output format<response><kb_entry>...</kb_entry><answer>...</answer></response>The structure of every response

    Templates also fix the shape of the output. Define the format you want precisely, in JSON, XML or a custom template, and Claude will follow every formatting element you require. Examples are among the most reliable ways to set format, tone and structure. They should be relevant to your real use case and varied enough that Claude doesn't copy unintended patterns. Wrap them in <example> tags (and several in <examples>) so Claude can tell them apart from instructions. For chatbots and knowledge bases, add a tagged block of retrieved entries (for example, a <kb> section) to ground answers in a fixed information set. Older consistency advice also suggests prefilling the Assistant turn with the start of the format. Prefilling is not supported on Claude 4.6 and later models or on Claude Mythos Preview, so a template meant for current models should get its format from instructions and examples instead.

    Checkpoint 3 of 4· Exam question

    A team is building a customer support assistant and wants the system prompt to reliably shape Claude's tone and behavior across thousands of daily conversations. The current system prompt is a single sentence: "You are a helpful assistant." Support agents report inconsistent formality and occasional off-topic tangents. What is the most effective first change to the system prompt design?

    Checkpoint 4 of 4· Match them up

    Match each template technique to what it does

    Tap a term, then the definition that fits it.

    Sources21

    Exam traps

    Each one states something that sounds right. Open it to see what is actually true.

    1. 1.Prefilling the Assistant turn is a dependable way to enforce a template's output format on any Claude model.Why is that wrong?

      Prefill appears in older consistency guidance, but it is not supported on Claude 4.6 and later or on Claude Mythos Preview. On those models, define the format precisely and show it with examples.

      Covered in Turn the prompt into a reusable template

    2. 2.A capitalised absolute rule like "NEVER use ellipses" is the strongest way to word a constraint.Why is that wrong?

      The docs label the bare rule as less effective. Stating the reason behind it (the speech engine can't pronounce ellipses) works better, because Claude can extend the reason to related cases.

      Covered in Write instructions that are specific and give the reason

    Sources

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Setting a role in the system prompt focuses Claude's behavior and tone for your use case. Even a single sentence makes a difference”
      ↩︎ Start the system prompt with a role
      “Be specific about the desired output format and constraints.”
      ↩︎ Write instructions that are specific and give the reason
      “Providing context or motivation behind your instructions, such as explaining to Claude why such behavior is important, can help Claude better understand your goals”
      ↩︎ Write instructions that are specific and give the reason
      “Use consistent, descriptive tag names across your prompts.”
      ↩︎ Turn the prompt into a reusable template
      “Claude is smart enough to generalize from the explanation.”
      ↩︎ Exam trap 2
      “Claude is smart enough to generalize from the explanation.”
      ↩︎ Prediction
      “Provide instructions as sequential steps using numbered lists or bullet points when the order or completeness of steps matters.”
      ↩︎ Checkpoint
      “Wrapping each type of content in its own tag (for example, <instructions>, <context>, <input>) reduces misinterpretation.”
      ↩︎ Checkpoint
    2. 2.
      “Use system prompts to define Claude's role and personality. This sets a strong foundation for consistent responses.”
      ↩︎ Start the system prompt with a role
      “Provide a list of common scenarios and expected responses in your prompts.”
      ↩︎ Turn the prompt into a reusable template
      “Precisely define your desired output format using JSON, XML, or custom templates so that Claude follows every output formatting element you require.”
      ↩︎ Turn the prompt into a reusable template

    Also cited

    Continue to page 2 of 2

    Guardrails for Claude Apps: Jailbreaks, Prompt Injection, Hallucinations and Prompt Leaks

    Spotted a mistake, or was something unclear? Tell us.