Homework
Three tasks to cement prompt engineering skills — to be completed before Lesson 04.
homework03.pdf in this lesson folder, or document your results in a markdown cell within lab.pdf. Be ready to discuss one finding during the next class.
📥 Reference Solution
⬇ lab_answer.pdfTask 1 — RTCF Prompts for Real Work
What to do
Identify 3 tasks you actually do at work (or in a project). For each task, write a complete RTCF prompt and run it against Claude. Document the results.
Requirements
- Each prompt must address a real, recurring task you face (not hypothetical)
- Each prompt must contain all 4 RTCF components, clearly labeled
- Run each prompt at least twice and note whether outputs are consistent
- Write 2–3 sentences per prompt explaining why you chose each RTCF element
Example structure
Task: Weekly status report draft
Role: You are a senior project manager writing for a non-technical executive audience.
Task: Draft a 3-bullet weekly status update for the mobile app project.
Context: This week: completed login flow, started payment integration,
blocked on third-party API credentials. Team size: 4 engineers.
Format: 3 bullets max. Each bullet: one sentence. Lead with status emoji
(green/yellow/red). Formal tone. No jargon.
Self-check: Can you identify all 4 RTCF components in each of your prompts? Does each prompt have at least one Format constraint?
Task 2 — Inconsistent Prompt Diagnosis
What to do
Find a prompt (from your work, a past project, or online) that produces inconsistent or unpredictable results across multiple runs. Diagnose the root cause using the failure mode taxonomy from the theory notes, then rewrite it to be more reliable.
Requirements
- Run the original prompt at least 5 times and document the variance (copy 2–3 different outputs)
- Identify which failure mode(s) apply: ambiguity, under-specification, over-constraining, conflicting instructions, or implicit assumptions
- Rewrite the prompt to fix the identified failure mode(s)
- Run the fixed prompt 5 times — are outputs now more consistent?
- Write a 100-word analysis: what was wrong, what you fixed, and how you measured improvement
Self-check: Your 100-word analysis should name a specific failure mode from the theory notes, not just say "it was vague."
Task 3 — Force JSON Without JSON Mode
What to do
Claude has a JSON mode (available via API), but in this task you are not allowed to use it. Instead, instruct Claude to return valid JSON using only natural language instructions in your prompt. Test reliability across 5 runs.
The task
Write a prompt that extracts the following fields from a job description (provide your own job description — copy any posting from LinkedIn or a company website):
{
"job_title": "string",
"company": "string",
"location": "string",
"salary": "string or null",
"required_skills": ["list", "of", "strings"],
"remote": true or false
}
Requirements
- Your prompt must use only natural language — no API parameters, no
response_format - The output must parse cleanly with
json.loads()on at least 5 out of 5 runs - Test with 2 different job descriptions
- If it fails, document what failed and how you fixed the prompt
Hints
- Be explicit: "Return only valid JSON. No preamble, no explanation, no markdown fences."
- Include the target schema in the prompt
- Tell Claude what to do when a field is not found (e.g., "use null")
Self-check: Run json.loads(output) in Python after each call. 5/5 successful parses = success. If you're getting 4/5 or less, revise the prompt and document what changed.
Grading Criteria
| Task | Points | Key Criterion |
|---|---|---|
| Task 1 — RTCF prompts | 30 | All 4 RTCF components present; real-world relevance |
| Task 2 — Diagnosis | 40 | Failure mode correctly identified; 100-word analysis is specific |
| Task 3 — JSON forcing | 30 | 5/5 parses succeed; prompt uses only natural language |