CertSafari
    CLAUDE-CERTIFIED-DEVELOPER-FOUNDATIONS-CCDV-F · Lessons

    Domain 6 · Lesson 17/25

    Writing Clear Claude Prompts: Instructions, Examples, Roles and Output Format

    Prompt Engineering

    9 min read
    3.67% of exam
    3 sources
    Published 29 Sep 2026
    Docs as of 24 Sep 2026

    What you will be able to do

    • Rewrite a vague or bare-rule instruction into a specific one that explains its purpose
    • Choose few-shot examples that are relevant, diverse and clearly separated from instructions
    • Use XML tags to keep instructions, context, examples and inputs distinct
    • Decide what belongs in the system prompt and what belongs in the user turn
    • Constrain Claude's output with an explicit JSON, XML or template format

    Key concept

    Prompt as a briefing for a capable newcomer — Claude brings strong general ability to a request but knows nothing about your norms, audience or definition of done. Every prompt technique on this page is a way to supply that missing context explicitly instead of hoping Claude infers it.

    1.Write the prompt a new colleague could follow

    Claude starts every request without knowing your conventions, your audience, or what a finished answer looks like. Anthropic's guidance says the more precisely you explain what you want, the better the result, and it gives a simple test, the golden rule. Show your prompt to a colleague who has minimal context on the task and ask them to follow it. If they would be confused, Claude will be too.

    Three habits follow from that test. First, be specific about the output format and constraints instead of leaving them implied. Second, if you want more than the minimum, 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 to create a fully-featured implementation" asks explicitly for the fuller version. The guidance tells you to request "above and beyond" behaviour directly rather than relying on Claude to infer it from a vague prompt. Third, when the order or completeness of steps matters, write the steps as a numbered list or bullet points.

    The documented fix is to give a reason, not to shout louder. The best-practices guide rewrites the rule as: "Your response will be read aloud by a text-to-speech engine, so never use ellipses since the text-to-speech engine will not know how to pronounce them." Giving the context or motivation behind an instruction helps Claude understand your goal and respond more precisely. The guide's explanation is short: Claude is smart enough to generalize from the explanation.

    A developer prompts Claude with the bare request "Create an analytics dashboard" and consistently gets a minimal, bare-bones implementation. The team wants a fully-featured result with rich interactions on the first attempt, without relying on multiple follow-up turns. What change to the prompt best achieves this?

    Sources1

    2.Steer format and tone with a few well-chosen examples

    Sometimes describing the output isn't enough, and it's clearer to show it. The guide calls examples one of the most reliable ways to steer Claude's output format, tone and structure. It says a few well-crafted examples, a technique known as few-shot or multishot prompting, improve accuracy and consistency. What makes them work is quality, not quantity, and the guidance names three properties to aim for.

    The three properties of effective few-shot examples
    PropertyWhat to do
    RelevantMirror your actual use case closely
    DiverseCover edge cases and vary enough that Claude doesn't pick up unintended patterns
    StructuredWrap each example in <example> tags, and multiple examples in <examples> tags, so Claude can tell them apart from instructions

    A team is building a multishot prompt to classify support tickets into categories, but Claude's output format is inconsistent across different ticket inputs. They want to revise the example set to follow Anthropic's guidance on using examples effectively. Select the changes that align with that guidance.(Select 3)

    Sources1

    3.Separate instructions, context and inputs with XML tags

    Examples aren't the only content that can blur into your instructions. Retrieved documents and variable inputs can too. According to the guide, XML tags help Claude parse complex prompts unambiguously, particularly when a prompt mixes instructions, context, examples and variable inputs. Putting each type of content in its own tag, such as <instructions>, <context> or <input>, reduces misinterpretation.

    The guide lists two best practices. Use consistent, descriptive tag names across your prompts, and nest tags when the content has a natural hierarchy: documents go inside <documents>, and each one sits in its own <document index="n">. When every source has its own indexed tag, Claude can still tell the sources apart. If they are pasted in as one undifferentiated block, it can't.

    Sources1

    4.Put the role in the system prompt and the request in the user turn

    Where an instruction goes matters as much as how it is worded. The guide says that setting a role in the system prompt focuses Claude's behaviour and tone for your use case, and that even a single sentence makes a difference. In the Messages API, the system parameter says who Claude is for this application, and the messages array carries the specific request:

    A one-sentence role in the system prompt, with the task in the user messagepython
    client = anthropic.Anthropic()
    
    message = client.messages.create(
        model="claude-opus-5-5",
        max_tokens=1024,
        system="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)

    The system prompt is also where standing guidance on tone belongs. On Claude Sonnet 5, setting temperature, top_p or top_k to a non-default value returns a 400 error. The Sonnet 5 guide says to remove those parameters and use system-prompt instructions to guide tone and variety instead.

    Sources12

    5.Constrain the output with an explicit format

    The final part of a clear prompt is the shape of the answer. The consistency guide says to define your output format precisely, using JSON, XML or a custom template, so that Claude follows every formatting element you require. A JSON instruction can name the keys and their allowed values. The guide's customer-feedback example asks for "sentiment" (positive/negative/neutral), "key_issues" (list) and "action_items" (list of dicts with "team" and "task"). A template goes further and can fix the structure and length of each field. This market-intelligence prompt puts the input in <data> tags and then shows the exact shape to follow:

    An output template that fixes structure and per-field lengthxml
    <competitor>
      <name>Rival Inc</name>
      <overview>A 50-word summary.</overview>
      <swot>
        <strengths>- Bullet points</strengths>
        <weaknesses>- Bullet points</weaknesses>
        <opportunities>- Bullet points</opportunities>
        <threats>- Bullet points</threats>
      </swot>
      <strategy>A 30-word strategic response.</strategy>
    </competitor>

    The template uses several techniques from this page at once. It is an example that also serves as a format specification, it uses XML to keep the data separate from the instruction, and it sets explicit length limits ("A 50-word summary", "A 30-word strategic response").

    Sources31

    Exam traps

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

    1. 1.If Claude ignores a rule, restating it in capitals ("NEVER ...") is the best way to enforce it.Why is that wrong?

      The guidance improves the rule by adding its reason. Once Claude understands the goal behind an instruction, it follows it more precisely and can generalize from the explanation.

      Covered in Write the prompt a new colleague could follow

    2. 2.Few-shot examples work best when they are near-identical, so Claude sees one consistent pattern.Why is that wrong?

      Examples should vary and include edge cases. Uniform examples can teach patterns you never intended.

      Covered in Steer format and tone with a few well-chosen examples

    3. 3.Concatenating several source documents as plain text is fine because Claude will keep them apart on its own.Why is that wrong?

      When a prompt mixes content types, give each its own tag and nest documents in indexed tags. This reduces misinterpretation.

      Covered in Separate instructions, context and inputs with XML tags

    Sources

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

    1. 1.
      “Golden rule: Show your prompt to a colleague with minimal context on the task and ask them to follow it.”
      ↩︎ Write the prompt a new colleague could follow
      “Provide instructions as sequential steps using numbered lists or bullet points when the order or completeness of steps matters.”
      ↩︎ Write the prompt a new colleague could follow
      “Claude is smart enough to generalize from the explanation.”
      ↩︎ Write the prompt a new colleague could follow
      “Examples are one of the most reliable ways to steer Claude's output format, tone, and structure.”
      ↩︎ Steer format and tone with a few well-chosen examples
      “Wrap examples in <example> tags (multiple examples in <examples> tags) so Claude can distinguish them from instructions.”
      ↩︎ Steer format and tone with a few well-chosen examples
      “XML tags help Claude parse complex prompts unambiguously, especially when your prompt mixes instructions, context, examples, and variable inputs.”
      ↩︎ Separate instructions, context and inputs with XML tags
      “Nest tags when content has a natural hierarchy”
      ↩︎ Separate instructions, context and inputs with XML tags
      “Setting a role in the system prompt focuses Claude's behavior and tone for your use case. Even a single sentence makes a difference”
      ↩︎ Put the role in the system prompt and the request in the user turn
      “Be specific about the desired output format and constraints.”
      ↩︎ Constrain the output with an explicit format
      “Think of Claude as a brilliant but new employee who lacks context on your norms and workflows.”
      ↩︎ Key concept
      “Providing context or motivation behind your instructions, such as explaining to Claude why such behavior is important, can help Claude better understand your goals”
      ↩︎ Exam trap 1
      “Diverse: Cover edge cases and vary enough that Claude doesn't pick up unintended patterns.”
      ↩︎ Exam trap 2
      “Wrapping each type of content in its own tag (for example, <instructions>, <context>, <input>) reduces misinterpretation.”
      ↩︎ Exam trap 3
    2. 3.
      “Precisely define your desired output format using JSON, XML, or custom templates so that Claude follows every output formatting element you require.”
      ↩︎ Constrain the output with an explicit format

    Continue to page 2 of 2

    Refining, Placing and Sanitizing Claude Prompts