Why this page exists
"It worked on my prompt" is the LLM equivalent of "it works on my machine." The official courses pair prompt engineering with prompt evaluation for a reason: technique tells you what to try, evals tell you whether it worked. This page covers both shared modules, and you leave with a runnable eval harness under 30 lines.
Three techniques that actually move the needle 14 min
Hundreds of "prompt hacks" circulate. Three survive contact with evals: be clear and specific, structure with XML tags, and show examples.
CoreClear, direct, and specific5 min▶
This is the 4D Description from Session 1, held to an engineering standard: every vague word in your prompt is a decision you delegated to the model. Name the audience, the format, the length, the edge-case behavior. The test: could a new hire execute your prompt without asking a follow-up question?
Notice what "after" pins down: audience, sections, limits, evidence rule, empty-case behavior, dialect, length. None of that is clever - it is just complete. Most prompt "engineering" is finishing your own specification.
CoreStructure with XML tags4 min▶
Once a prompt contains more than one KIND of thing - instructions plus a document plus examples - prose runs together and Claude can confuse your data with your rules. XML tags draw hard boundaries. Claude is specifically trained to respect them, and you can reference tags by name ("the document in <context> tags").
Common tags: <context>, <instructions>, <examples>, <data>, <output_format>. The names are yours to choose - consistency matters more than the vocabulary. Tags also defuse a classic failure: a document that itself contains instruction-like sentences no longer hijacks your prompt, because your instructions live outside the <context> block.
CoreFew-shot: show, don't describe5 min▶
The highest-leverage technique per minute spent: 1-3 gold examples of input → ideal output routinely beat paragraphs of format description. An example carries tone, structure, level of detail, and edge-case handling all at once - things prose describes badly.
Rules of thumb: pick examples that span your real variety (one easy, one messy, one edge case); keep them SHORT - the model imitates length too; and make them genuinely gold, because Claude will faithfully reproduce any sloppiness you include. If you cannot produce a gold example yourself, that is a sign the task is underspecified, not a prompting problem.
A data team spent a week tuning instructions for converting analyst notes into release-note bullets - output kept drifting corporate and bloated. Deleting half the instructions and pasting in two real before/after pairs from their best writer fixed it in one attempt. Their eval pass rate (next section) jumped 23 points. Examples are compressed specification.
Evals: from vibes to numbers 16 min
You changed the prompt and the one output you looked at got better. Did the other 200 cases? An eval is just a test suite for a prompt: dataset in, grades out, one number to compare versions.
CoreWhy evals, and the workflow3 min▶
Prompts fail quietly and unevenly: a change that fixes your favorite test case often breaks three you never look at. The eval workflow is the same loop as ML model development:
- 1 · Define the task - inputs, expected outputs, and what "correct" means, in writing.
- 2 · Build a test dataset - 20-100 realistic cases with expected answers, including the ugly ones.
- 3 · Run - execute the prompt against every case.
- 4 · Grade - code-based checks for structured tasks, model-based rubrics for subjective ones.
- 5 · Iterate - change ONE thing in the prompt, rerun, compare pass rates. Keep what wins.
CoreGenerating test datasets with Claude3 min▶
Writing 50 test cases by hand is why people skip evals. So don't: have Claude generate them, then human-review before trusting. You are curating, not authoring.
Then the non-negotiable step: read every generated case and fix or delete the bad ones. Claude's label IS your answer key - an unreviewed answer key silently corrupts every eval you run against it. Add real production examples (anonymized) as they accumulate; synthetic data starts the flywheel, real data keeps it honest.
CoreCode-based grading: cheap and objective3 min▶
If the output is structured - a category, a JSON object, a SQL string - grade it with plain Python. Exact match, regex, or schema checks: free, instant, deterministic, and immune to flattery.
Design your task to be code-gradable where you can - forcing a category from a fixed list, or JSON with known keys, is often a better prompt AND a free grader. Save the expensive grading for outputs that genuinely need judgment.
CoreModel-based grading: rubrics for the subjective4 min▶
Summaries, emails, explanations - no regex can score "faithful and clear". Instead, a second Claude call grades the first against a written rubric. The rubric is the whole game: grade specific, checkable qualities, never "is this good?".
Note the 6.1 moves reused: temperature 0, JSON prefill, validation. Spot-check the grader against your own judgment on 10 cases before trusting it at scale - a grader is a prompt, and prompts need evals too. Which grader when:
| Code-based | Model-based | |
|---|---|---|
| Best for | Categories, JSON, extraction, SQL, anything with one right answer | Summaries, tone, explanations, "did it follow the style guide" |
| Cost & speed | Free, instant | One extra API call per case |
| Objectivity | Perfect | Good with a tight rubric; drifts without one |
| Watch out for | False fails on harmless format variation | Grading its own vibe - always spot-check vs a human |
AdvancedA minimal eval harness3 min▶
Everything above, assembled. A JSONL dataset, a loop, a grader, a pass rate. This is genuinely all an eval needs to be useful - frameworks add convenience later, not correctness.
Workflow: change the prompt, bump PROMPT_VERSION, rerun, read the failures - they tell you exactly what to fix next. Keep a log of version → pass rate and prompt tuning becomes boring, measurable engineering. Which was the point.
Three builds ◐ 10 min in session, finish after
- 1 · Upgrade one of your prompts. Take a prompt you actually use, apply all three techniques (specific, XML tags, 2 gold examples), and run old vs new on the same 5 inputs side by side. Note WHICH technique changed the output most - it is usually the examples.
- 2 · Build the classifier eval end to end. Generate 20 ticket cases with the dataset prompt, review every label by hand, then run the harness from Part 2. Get your baseline pass rate before touching the prompt.
- 3 · Beat your baseline. Read the failures, change ONE thing (add an example covering the failure pattern, or tighten a category definition), rerun. Repeat until the pass rate stops moving. Two or three iterations is normal; the discipline of one-change-at-a-time is the exercise.
Official courses covered
This page teaches the shared Prompt Engineering and Prompt Evaluation modules from the three official 8-hour engineering courses at claude.com/resources/courses.