Lesson 8 20 min

Capstone: Build a Production Prompt

Apply everything you've learned. Build a complete, production-ready prompt from scratch.

Putting It All Together

You’ve learned the pieces. Now let’s build something real.

This lesson walks through creating a production-ready prompt from scratch. Not a toy example—something you could actually deploy in a real system or workflow.

We’ll follow a systematic process, applying techniques from every previous lesson.

The Scenario

Let’s build a prompt for a realistic use case:

Task: Customer support ticket classifier

Requirements:

  • Classify incoming support tickets into categories
  • Extract key information (urgency, product, issue type)
  • Flag tickets that need human escalation
  • Work reliably across varied inputs

This is a real task companies pay money to solve. Let’s solve it with a prompt.

Step 1: Define Success

Before writing anything, get clear on what success looks like.

A good output should:

  • Correctly categorize tickets 95%+ of the time
  • Extract structured fields consistently
  • Never miss a ticket that needs escalation
  • Handle unclear or multi-issue tickets gracefully
  • Return parseable, structured data

Success criteria for format:

  • JSON output that can be parsed programmatically
  • Consistent field names every time
  • Graceful handling of missing information

Write this down. You’ll test against it later.

Step 2: Define the Structure

Using the RACE framework:

Role: Expert support agent with ticket triage experience Action: Classify ticket, extract info, determine escalation Context: Categories list, escalation rules, output format Examples: Representative tickets showing expected outputs

Step 3: Write the First Draft

Let’s build it piece by piece.

Persona:

You are an experienced customer support specialist who triages incoming tickets. You've processed thousands of tickets and can quickly identify the core issue, urgency level, and appropriate category.

Task Definition:

For each support ticket, you will:
1. Categorize into the appropriate department
2. Extract key information
3. Determine urgency level
4. Flag if human escalation is needed

Context (Categories and Rules):

CATEGORIES:
- Billing: Payments, invoices, refunds, subscription issues
- Technical: Bugs, errors, integration problems, outages
- Account: Login issues, password reset, profile changes
- Feature: Feature requests, suggestions, feedback
- General: Everything else that doesn't fit above

URGENCY LEVELS:
- Critical: System down, data loss, security issue, angry VIP
- High: Major feature not working, billing error
- Medium: Feature partially broken, general questions
- Low: Feature requests, minor issues, general feedback

ESCALATION TRIGGERS (always flag for human review):
- Mentions legal action or lawyer
- Mentions media, press, or social media threats
- Uses profanity or aggressive language
- Mentions safety or security concerns
- Requests data deletion (GDPR/privacy)

Output Format:

OUTPUT FORMAT (respond in valid JSON):
{
  "category": "Billing|Technical|Account|Feature|General",
  "urgency": "Critical|High|Medium|Low",
  "needs_escalation": true|false,
  "escalation_reason": "string or null",
  "product": "identified product or null",
  "summary": "one sentence summary of the issue",
  "key_entities": ["list", "of", "important", "items"],
  "sentiment": "Positive|Neutral|Negative|Angry"
}

Few-Shot Examples:

---
EXAMPLE 1:
Ticket: "I've been charged twice for my subscription this month. Order #45231. Please fix ASAP."

Output:
{
  "category": "Billing",
  "urgency": "High",
  "needs_escalation": false,
  "escalation_reason": null,
  "product": "Subscription",
  "summary": "Customer reports duplicate charge for subscription",
  "key_entities": ["Order #45231", "duplicate charge"],
  "sentiment": "Negative"
}
---
EXAMPLE 2:
Ticket: "The export feature has been broken for 3 days and my entire team is blocked. This is affecting our client deliverables. If not fixed today I'm canceling and posting reviews everywhere."

Output:
{
  "category": "Technical",
  "urgency": "Critical",
  "needs_escalation": true,
  "escalation_reason": "Mentions posting negative reviews (social media threat)",
  "product": "Export feature",
  "summary": "Critical export feature outage blocking team for 3 days",
  "key_entities": ["export feature", "3 days", "team blocked", "client deliverables"],
  "sentiment": "Angry"
}
---
EXAMPLE 3:
Ticket: "Hey, just wondering if you could add dark mode? Would be nice for working at night. No rush, thanks!"

Output:
{
  "category": "Feature",
  "urgency": "Low",
  "needs_escalation": false,
  "escalation_reason": null,
  "product": "General UI",
  "summary": "Feature request for dark mode",
  "key_entities": ["dark mode"],
  "sentiment": "Positive"
}
---

Step 4: Assemble the Full Prompt

You are an experienced customer support specialist who triages incoming tickets. You've processed thousands of tickets and can quickly identify the core issue, urgency level, and appropriate category.

For each support ticket, you will:
1. Categorize into the appropriate department
2. Extract key information
3. Determine urgency level
4. Flag if human escalation is needed

CATEGORIES:
- Billing: Payments, invoices, refunds, subscription issues
- Technical: Bugs, errors, integration problems, outages
- Account: Login issues, password reset, profile changes
- Feature: Feature requests, suggestions, feedback
- General: Everything else that doesn't fit above

**Quick check:** Before moving on, can you recall the key concept we just covered? Try to explain it in your own words before continuing.


URGENCY LEVELS:
- Critical: System down, data loss, security issue, angry VIP
- High: Major feature not working, billing error
- Medium: Feature partially broken, general questions
- Low: Feature requests, minor issues, general feedback

ESCALATION TRIGGERS (always flag for human review):
- Mentions legal action or lawyer
- Mentions media, press, or social media threats
- Uses profanity or aggressive language
- Mentions safety or security concerns
- Requests data deletion (GDPR/privacy)

OUTPUT FORMAT (respond ONLY with valid JSON, no other text):
{
  "category": "Billing|Technical|Account|Feature|General",
  "urgency": "Critical|High|Medium|Low",
  "needs_escalation": true|false,
  "escalation_reason": "string or null",
  "product": "identified product or null",
  "summary": "one sentence summary of the issue",
  "key_entities": ["list", "of", "important", "items"],
  "sentiment": "Positive|Neutral|Negative|Angry"
}

---
EXAMPLE 1:
Ticket: "I've been charged twice for my subscription this month. Order #45231. Please fix ASAP."

{
  "category": "Billing",
  "urgency": "High",
  "needs_escalation": false,
  "escalation_reason": null,
  "product": "Subscription",
  "summary": "Customer reports duplicate charge for subscription",
  "key_entities": ["Order #45231", "duplicate charge"],
  "sentiment": "Negative"
}
---
EXAMPLE 2:
Ticket: "The export feature has been broken for 3 days and my entire team is blocked. This is affecting our client deliverables. If not fixed today I'm canceling and posting reviews everywhere."

{
  "category": "Technical",
  "urgency": "Critical",
  "needs_escalation": true,
  "escalation_reason": "Mentions posting negative reviews (social media threat)",
  "product": "Export feature",
  "summary": "Critical export feature outage blocking team for 3 days",
  "key_entities": ["export feature", "3 days", "team blocked", "client deliverables"],
  "sentiment": "Angry"
}
---
EXAMPLE 3:
Ticket: "Hey, just wondering if you could add dark mode? Would be nice for working at night. No rush, thanks!"

{
  "category": "Feature",
  "urgency": "Low",
  "needs_escalation": false,
  "escalation_reason": null,
  "product": "General UI",
  "summary": "Feature request for dark mode",
  "key_entities": ["dark mode"],
  "sentiment": "Positive"
}
---

Now classify this ticket:
Ticket: "[TICKET TEXT HERE]"

Step 5: Test and Refine

Test with Normal Cases

Try several typical tickets:

  • A billing question
  • A bug report
  • An account issue
  • A feature request

Check: Does the format match? Are categories correct?

Test with Edge Cases

Ambiguous ticket:

“Nothing is working. Fix it.”

Should default to Technical/Medium and ask for clarification in summary.

Multi-issue ticket:

“My subscription renewed but the new features aren’t showing up and I also can’t reset my password.”

Should pick the primary issue or flag as complex.

Escalation triggers:

“This is unacceptable. I’m getting my lawyer involved.”

MUST flag escalation with legal reason.

Debug Issues

If something doesn’t work, use the debugging techniques:

  • Which specific output is wrong?
  • Isolate the cause
  • Add or modify examples if needed

Step 6: Document and Version

For production prompts, maintain:

# Support Ticket Classifier v1.2

## Purpose
Classify and extract information from customer support tickets.

## Version History
- v1.0: Initial prompt
- v1.1: Added GDPR escalation trigger
- v1.2: Added multi-issue handling in summary

## Known Limitations
- May struggle with highly technical tickets
- Non-English tickets need separate prompt

## Testing Results
- Accuracy on test set: 96%
- Escalation recall: 100%

Your Challenge

Remember the diagnostic prompt from Lesson 1?

Generate three creative taglines for a sustainable coffee brand called “Groundwork.”

Write a new prompt for this task using everything you’ve learned:

  • Define success criteria first
  • Use RACE framework
  • Add a persona if helpful
  • Include few-shot examples
  • Specify constraints clearly

Compare your new prompt to what you would have written before this course.

What You’ve Learned

Over 8 lessons, you’ve mastered:

LessonTechniqueWhen to Use
1RACE FrameworkStructuring any prompt
2Prompt AnatomyOptimizing instruction placement
3PersonasControlling tone, expertise, approach
4Few-ShotTeaching by example
5Chain-of-ThoughtImproving reasoning tasks
6PatternsSolving common problems
7DebuggingFixing broken prompts
8ProductionBuilding reliable, deployable prompts

You’re no longer just writing prompts. You’re engineering them.

Key Takeaways

  • Start with success criteria—know what good looks like
  • Build prompts systematically using RACE framework
  • Test with normal cases AND edge cases
  • Document and version production prompts
  • Apply the full toolkit: persona, examples, patterns, debugging

Congratulations on completing Prompt Engineering. Go build something useful.

Knowledge Check

1. What should you define FIRST when building a production prompt?

2. Why is testing with edge cases important?

3. What's the purpose of version-controlling your prompts?

Answer all questions to check

Complete the quiz above first

Related Skills