System Prompts with Explicit Criteria: Worked Example — Prompt Engineering & Structured Output (Claude Certified Architect)

System Prompts with Explicit Criteria — Worked Example In the context of the Claude Certified Architect - Foundation certification, mastering prompt...

System Prompts with Explicit Criteria — Worked Example

In the context of the Claude Certified Architect - Foundation certification, mastering prompt engineering is essential to design reliable AI solutions. This worked example demonstrates how to craft a system prompt with explicit criteria to improve precision and enforce structured output for a realistic extraction and review task.

Scenario

Suppose you are designing a Claude-based application to extract key information from customer feedback emails. The goal is to reliably extract three fields:

The output must be in a strict JSON format for downstream processing and review.

Step 1: Define Explicit Criteria in the System Prompt

Start by clearly specifying the extraction requirements and output format in the system prompt. Explicit criteria reduce ambiguity and false positives.

Example system prompt snippet:

"You are an AI assistant extracting data from customer emails. Extract the Customer Name, a concise Issue Description summarizing the problem, and the Urgency Level which must be one of: Low, Medium, or High. Output the result only as a JSON object with keys: 'customer_name', 'issue_description', 'urgency_level'. Do not add any explanation or extra text."

Step 2: Incorporate Few-Shot Examples

Provide 2-3 few-shot examples within the system prompt to demonstrate the expected input-output pattern. This helps the model learn consistent formatting and interpretation.

Example:

{ "input": "Hi, this is Jane Doe. My internet is down since yesterday.", "output": { "customer_name": "Jane Doe", "issue_description": "Internet outage since yesterday", "urgency_level": "High" } }

Repeat for other examples with varying urgency levels and issue types.

Step 3: Enforce Structured Output Using JSON Schema

Define a JSON schema that the output must conform to, specifying required fields and enumerated values for urgency_level. This schema can be used programmatically to validate outputs and trigger retries if necessary.

Step 4: Implement Validation, Retry, and Feedback Loops

After receiving the AI's output, validate it against the JSON schema. If the output is malformed or fields are missing, automatically retry the prompt with a clarifying system message or escalate for human review.

Step 5: Design Efficient Batch Processing

For processing multiple emails, batch inputs and use a single prompt with clear separators and instructions for each entry. This improves throughput and consistency.

Step 6: Multi-Pass or Multi-Instance Review Architecture

To ensure extraction quality, design a multi-pass system where initial extraction is followed by a secondary review agent that checks for inconsistencies or missing data, possibly requesting clarifications or corrections.

Worked Example Summary

  1. Compose system prompt with explicit extraction criteria and output format.
  2. Embed few-shot examples demonstrating correct JSON output.
  3. Define JSON schema to validate outputs.
  4. Implement validation and retry logic to handle errors.
  5. Batch process inputs for efficiency.
  6. Use multi-pass review to enhance reliability.

This approach ensures precise, structured extraction from unstructured text, aligning with the Claude Certified Architect - Foundation skillset for prompt engineering and structured output enforcement.

More in this topic

Multi-Instance and Multi-Pass Review — Prompt Engineering & Structured Output (Claude Certified Architect)System Prompts with Explicit Criteria — Prompt Engineering & Structured Output (Claude Certified Architect)System Prompts with Explicit Criteria: Common Mistakes — Prompt Engineering & Structured Output (Claude Certified Architect)Multi-Instance and Multi-Pass Review: Practice Questions — Prompt Engineering & Structured Output (Claude Certified Architect)Prompt Engineering & Structured Output — Claude Certified Architect - FoundationBatch Processing Strategies — Prompt Engineering & Structured Output (Claude Certified Architect)Multi-Instance and Multi-Pass Review: Quick Reference — Prompt Engineering & Structured Output (Claude Certified Architect)Multi-Instance and Multi-Pass Review: Worked Example — Prompt Engineering & Structured Output (Claude Certified Architect)System Prompts with Explicit Criteria: Practice Questions — Prompt Engineering & Structured Output (Claude Certified Architect)Few-Shot Prompting — Prompt Engineering & Structured Output (Claude Certified Architect)Validation, Retry, and Feedback Loops — Prompt Engineering & Structured Output (Claude Certified Architect)Multi-Instance and Multi-Pass Review: Common Mistakes — Prompt Engineering & Structured Output (Claude Certified Architect)System Prompts with Explicit Criteria: Quick Reference — Prompt Engineering & Structured Output (Claude Certified Architect)Structured Output with Tool Use — Prompt Engineering & Structured Output (Claude Certified Architect)

Related topics:

#prompt-engineering #claude-architecture #structured-output #system-prompts #ai-certification

Ready to test your knowledge?

Put what you've learned into practice with a quick quiz and track your progress.

Test your knowledge →