Prompt Engineering
Patterns, guardrails, and reproducible instructions.
Core Patterns
- CoT: “Think step by step.”
- ReAct: Reason + act with tools; log traces.
- SC: Self-consistency sampling for reliability.
- JSON-Mode: Schema-bound outputs for downstream code.
System Prompt Guidelines
- Define role, objectives, constraints, and refusal policy.
- Include formatting (markdown/JSON) and citation rules.
- Specify domain lexicon & forbidden behaviors.
Template (Server-Side)
System: You are a helpful domain assistant. Follow the policy, format, and tone.
Policy:
- Output JSON that validates against the schema.
- Refuse unsafe content per policy section X.
User Input:
{{ user_input }}
Schema:
{{ json_schema }}
Anti-Patterns
- Under-specification → vague outputs.
- Over-prompting → cost/latency bloat.
- Prompt drift across services → create a registry.