Artificial IntelligenceAnthropicPrompt Engineering

Prompt Engineering Refresher: 10 Techniques Every Claude Developer Should Know

TT
TopicTrick
Prompt Engineering Refresher: 10 Techniques Every Claude Developer Should Know

Before moving into Claude's advanced capabilities — tools, vision, computer use, and agents — this is the right moment to lock in the fundamentals. The techniques in this refresher are the foundation underneath everything more advanced. If any of these are shaky, the complex features that build on them will be harder to use correctly.

This post consolidates the ten most important prompt engineering techniques from Modules 2 and 3 of this series. It is designed to be fast to read, easy to bookmark, and useful to return to when something in a later module does not behave as expected. Think of it as your quick-reference card.


Technique 1 — Be Specific, Not Vague

Vague instructions produce vague results. The single biggest improvement in prompt quality comes from replacing general directions with specific, concrete instructions.

  • Vague: "Summarise this document"
  • Specific: "Summarise this document in three bullet points, each no longer than 20 words, focusing on action items for a project manager"

Specificity about format, length, audience, and focus unlocks dramatically better output.


Technique 2 — Assign a Role in the System Prompt

Claude adapts its tone, vocabulary, and depth of reasoning based on the role you assign it. A clearly defined role in the system prompt is one of the most cost-effective prompt engineering tools available.

System: You are a senior information security consultant with 15 years of experience in enterprise risk management. You communicate in concise, technical language appropriate for a CISO audience. You never speculate — if something is uncertain, you say so explicitly.

Role assignment is most powerful when it includes domain expertise, communication style, and behavioural constraints.


Technique 3 — Use XML Tags to Structure Complex Prompts

For prompts with multiple components — instructions, background context, examples, and the actual query — XML tags eliminate ambiguity about which part is which.

xml
1<instructions> 2 Classify the following support ticket by severity and category. 3</instructions> 4 5<categories>critical, high, medium, low</categories> 6 7<ticket> 8 Users across the APAC region cannot log into the billing portal. 9 Approximately 400 accounts affected. Started 20 minutes ago. 10</ticket>

Claude processes XML-structured prompts more reliably than the same content written as a paragraph because the tags create unambiguous boundaries.

XML Tags for Long-Context Prompts

XML tags are especially valuable in long-context scenarios where you are passing thousands of tokens of background data. Without tags, Claude must infer where the context ends and the instruction begins. With tags like <context> and <question>, there is no ambiguity.


    Technique 4 — Provide Examples (Few-Shot Prompting)

    Examples are the fastest path to the exact output format you want. If instructions alone are not producing the right result, add two or three worked examples of the input-output pair you expect.

    Input: "The server went down at 3am and nobody noticed until 8am." Output: {"severity": "high", "category": "availability", "response_sla_hours": 4} Input: "Password reset emails are arriving 10-15 seconds late." Output: {"severity": "low", "category": "performance", "response_sla_hours": 48} Input: "All customer-facing APIs returned 503 errors for 12 minutes." Output:

    Claude uses the pattern in your examples to complete the final output consistently.


    Technique 5 — Use Negative Examples

    Negative examples explicitly show Claude what you do not want. They are particularly useful for preventing a specific mistake Claude keeps making.

    Do NOT respond like this: "That's a great question! As an AI, I should point out that..." DO respond like this: "The answer is [direct response]."

    Pairing a negative example with a positive one is more effective than a positive example alone for correcting persistent formatting mistakes.


    Technique 6 — Ask Claude to Think Before Answering

    For complex reasoning tasks, asking Claude to think through the problem before answering — chain-of-thought prompting — produces more accurate results.

    Before giving your final recommendation, think through the trade-offs systematically. Consider costs, risks, implementation complexity, and long-term maintainability. Then give your recommendation.

    Chain-of-thought works because it allocates more computation to the reasoning process before commitment to a final answer.


    Technique 7 — Use Prompt Chaining for Complex Workflows

    Instead of trying to do everything in one massive prompt, break complex tasks into a sequence of simpler prompts where each step's output feeds the next.

    • Step 1: Extract key data from a raw document
    • Step 2: Analyse the extracted data for risks
    • Step 3: Draft a risk report based on the analysis

    Each step is independently verifiable, and errors at any stage can be caught and corrected before they propagate downstream.


    Technique 8 — Control Format Explicitly

    If you need a specific output format, state it explicitly rather than hoping Claude guesses. Claude will match almost any format you describe clearly.

    • "Return your answer as a numbered list"
    • "Format this as a professional email with subject line, greeting, body paragraphs, and a sign-off"
    • "Return only valid JSON — no markdown, no explanation, no preamble"
    • "Use HTML list tags, never markdown dashes"

    State What You Do NOT Want

    Format instructions work better when you include both what you want and what you do not want. Instead of just saying 'return JSON', say 'return only raw JSON with no markdown code fences and no explanatory text before or after the JSON object'. The negative constraint prevents the most common formatting mistakes.


      Technique 9 — Define Constraints Clearly

      Constraints are specific boundaries Claude must operate within. They prevent Claude from producing responses that are technically correct but practically unhelpful.

      Examples of effective constraints:

      • Length: "No more than 150 words"
      • Scope: "Only reference information explicitly stated in the document — do not use external knowledge"
      • Tone: "Always maintain a professional, neutral tone — do not editorialize"
      • Output: "If you cannot answer with confidence, respond with 'INSUFFICIENT DATA' rather than guessing"

      Well-defined constraints reduce variability and make Claude's output predictable in production.


      Technique 10 — Iterate Systematically

      Prompt engineering is not a one-shot process — it is an iterative loop. The most effective approach:

      1. Write an initial prompt and run it against 5-10 diverse test inputs
      2. Identify the most common failure mode in the outputs
      3. Add a specific instruction or example that targets that failure mode
      4. Test again and confirm the failure mode is resolved without introducing new ones
      5. Repeat until performance across your test set is acceptable

      Never judge a prompt by a single output. Evaluate it across a representative sample of the inputs your production system will encounter.


      Quick Reference Table

      Since this is a refresher, here is a condensed version of all ten techniques:

      1. Specificity: Replace vague instructions with concrete, detailed directions
      2. Role assignment: Define expertise, tone, and behavioural constraints in the system prompt
      3. XML tags: Structure multi-component prompts to eliminate ambiguity
      4. Few-shot examples: Show the exact input-output format you expect
      5. Negative examples: Explicitly demonstrate what you do not want
      6. Chain-of-thought: Ask Claude to reason before committing to an answer
      7. Prompt chaining: Break complex workflows into sequential, verifiable steps
      8. Format control: State your format requirements explicitly including exclusions
      9. Constraints: Define hard boundaries on scope, length, tone, and fallback behaviour
      10. Systematic iteration: Test on diverse inputs, identify failure modes, refine, repeat

      These Techniques Compound

      The full power of prompt engineering comes from combining these techniques. A well-designed production prompt might include role assignment, XML structure, two or three examples, explicit format instructions, a chain-of-thought instruction, and fallback constraints — all in a single system prompt. Each technique reinforces the others.


        What is Coming Next

        With prompt engineering fundamentals consolidated, you are ready to move into Claude's most powerful capabilities for building real applications. Module 4 covers the tools and features that transform Claude from a text generator into a system that can interact with the real world.

        The next post introduces the foundation of all of them: Claude Tool Use Explained: Give Claude the Ability to Act.


        This post is part of the Anthropic AI Tutorial Series. Previous post: Structured Outputs with Claude: Getting JSON Every Time.