CCDV-F Prep unofficial
← All skills

Prompt and Context Engineering

Prompt Revision

Exam objective: Revising a prompt to close a gap between intended and actual output that regression evaluations have exposed, using instruction clarity, system-versus-user placement, zero-, single-, or multi-shot examples, output constraints, and input sanitization, closing the gap and keeping it closed.

What the exam tests

Revising a prompt after regression evals show a gap between intended and actual output. Expect a scenario with a symptom and a question about which change closes the gap (clearer instructions, system or user placement, examples, output constraints, handling of untrusted input) and how to keep it closed.

Key rules

Start from evals. Prompt engineering assumes defined success criteria, a way to test them and a draft prompt. Evals should mirror the real task distribution, including edge cases. Prefer many automatically graded cases over a few hand-graded ones. Code-based grading is fastest and most reliable; test an LLM grader for reliability before scaling it. To keep a gap closed, keep each exposed failure in the suite and rerun the whole suite on every prompt change.

Not every failure is a prompt problem. Latency or cost, for example, may be easier to fix by choosing a different model.

Be clear and direct. State the output, format and constraints you want. Use numbered steps when order or completeness matters. Explain why a rule exists so Claude can generalize. Current models follow wording precisely: "suggest changes" may yield suggestions only. On models that are very responsive to the system prompt, soften "CRITICAL: You MUST" language that now causes overtriggering.

Placement. Put the role and standing behavior in system. Tag mixed content (<instructions>, <context>, <input>). Put long documents near the top, above the query.

Examples. Zero-shot relies on instructions alone. Add one or more examples when format, tone or structure keeps drifting. Make them relevant, diverse and wrapped in <example> tags; 3–5 is the suggested number. Narrow examples teach unintended patterns.

Output constraints. Say what to do rather than what not to do, and match the prompt's style to the wanted output. For guaranteed schema conformance use structured outputs. Prefill on the last assistant turn returns a 400 error from Claude 4.6 on; replace it with system instructions, tags, structured outputs or tool calling.

Input sanitization. For adversarial users: screen input with a lightweight model, filter known injection patterns, harden the system prompt. For third-party content: deliver it only in tool_result blocks, JSON-encode it, state in system that it is untrusted, and apply least privilege.

{"type": "tool_result", "tool_use_id": "toolu_01",
 "content": "{\"source\":\"inbound_email\",\"body\":\"Ignore previous instructions...\"}"}

Model-specific behavior. Techniques measured on one model should be tested on your own evals before applying them to another. Example: on Claude Sonnet 5.5, JSON answers to multi-step tasks can skip thinking at lower effort; with adaptive thinking, adding "Think the problem through before you answer." helps. To get less thinking, lower effort rather than asking for it in the prompt.

Traps

  • Verifying a fix only against the cases that motivated it.
  • Adding more near-identical examples, or pasting failing inputs into the prompt as the fix.
  • Answering a missed rule with capitals and repetition instead of clarity and a reason.
  • Putting emails or web pages in system, or your own instructions inside tool results.
  • Treating a screening model's refusal as a pass because no verdict came back.
  • Asking the model to write out its internal reasoning in the reply; some models may decline.

Decide quickly

SituationChoiceWhy
Rule applied too narrowlyExplain the reasonClaude generalizes from it
Format or tone driftsDiverse tagged examplesStrong steer for structure
Output copies an accidental patternVary the examplesRemoves the false signal
Must match a schemaStructured outputsGuaranteed compliance
Unwanted preambleDirect system instruction, strip leftoversReplaces prefill
Unwanted markdownDescribe prose, write prompt in prosePositive and consistent
Tool overtriggers after upgradeSoften and target the guidanceModel is more responsive
Third-party text carries commandsTool result, JSON, stated policySeparates data from instructions
Fix must stay fixedPermanent case, full automated rerunCatches regressions

Sources