Domain 420% weight

Quick Reference: Domain 4Prompt Engineering & Structured Output

System Prompt Structure

A well-structured system prompt contains: role definition, behavioral constraints, output format specification, and context. Order matters — Claude weighs earlier content more heavily.

SectionPurposeExample
RoleDefine persona and expertiseYou are a senior code reviewer...
ConstraintsSet boundariesNever execute code. Only analyze.
Output FormatDefine structureRespond in JSON with fields: severity, message, line
ContextProvide backgroundThe codebase uses TypeScript and React...

Structured Output Techniques

TechniqueReliabilityWhen to Use
Tool use (forced)HighestProduction systems requiring exact schema
Prefilling ({)HighSimple JSON when tool use is unavailable
System prompt instructionsMediumFlexible formatting, non-critical outputs
XML tagsMedium-HighMulti-section responses with clear boundaries

Key rule: For production JSON output, use tool use with a defined schema. It is the only method that guarantees schema compliance.

Prompt Chaining Decisions

Chain when: steps need different models, temperatures, or tools. Steps have independently verifiable outputs. You need to inspect or modify intermediate results.

Single call when: the task is straightforward, all steps need the same context, and latency matters.

Anti-PatternWhy It Fails
Chaining simple tasksAdded latency and cost for no quality improvement
No validation between stepsErrors propagate and compound through the chain
Passing full context between stepsToken waste — pass only what the next step needs

Few-Shot Example Rules

RuleDetails
Include 2-5 examplesFewer may not establish the pattern; more wastes tokens
Cover edge casesShow the hard cases, not just the obvious ones
Consistent formatExamples must match the expected output format exactly
Place after instructionsInstructions first, then examples, then the real input
Use diverse examplesAvoid examples that are too similar to each other

Key Parameters

ParameterDefaultWhen to Change
temperature1.00 for deterministic output (JSON, classification)
max_tokensModel dependentSet explicitly to control output length and cost
top_pModel dependentRarely needed — temperature is usually sufficient
stop_sequencesNoneCustom stop tokens for structured output parsing