<!-- skill: Prompt Engineering | version: 1.0.0 | description: Writing instructions that get reliable results from AI models | category: AI & Automation -->
## Instructions
- Be specific about output shape: format, length, tone, and what "done" looks like. Vague prompts get vague answers; constraints get compliance.
- Give context, not just tasks: background, audience, and what the output is FOR changes results more than clever wording.
- One job per prompt: multi-task prompts (analyze + rewrite + summarize) produce mediocrity in all three. Chain single-purpose prompts instead.
- Show, don't just tell: 1–2 input/output examples beat paragraphs of description for style, format, and edge cases.
- For agents/tools: state what's allowed explicitly (which tools, which directories), demand verification steps ("read the file back", "run the tests"), and forbid common failure modes by name ("never paste code in chat, always use file_write").
- Iterate on failures: when output misses, add the missing constraint to the prompt permanently instead of re-explaining every time. Prompts are code — version them.
- Temperature matters: low (0.0–0.3) for factual/tool work, higher (0.7–1.0) for ideas and creative writing.
- Structure every serious prompt the same way: Context → Task → Constraints → Output format → Examples → Definition of done. Skipping sections is where vagueness hides.
- Constraints are load-bearing: state length caps, forbidden moves ("no invented dates"), required moves ("cite sources"), and edge behavior ("if data is missing, say so") — each constraint removes a failure class.
- Delimiters beat prose: wrap inputs in ``` or <tags>, one block per input; models respect boundaries far better than "the text below".
- Ask for reasoning where it helps, hide it where it hurts: `think step-by-step privately, then output ONLY the result` for math/tools; visible chain-of-thought for teaching/debugging.
- Calibrate refusal vs compliance: spell out what to do with ambiguous/harmful requests ("ask one clarifying question" vs "decline + offer safe alternative") instead of leaving it to model mood.
- Version prompts like code: name + date + change note in the file header; keep the last working version until the new one beats it on 3+ test inputs.
## Examples
- Weak: "Write about dogs." Strong: "Write a 150-word beginner-friendly paragraph about why dogs tilt their heads, curious tone, no jargon, end with one question for the reader."
- Agent brief: role + workspace boundaries + tool list + definition of done + "report blockers instead of guessing".
- Rewrite brief: "Audience: busy CTO. Input: <notes>. Output: 5 bullets, ≤15 words each, decisions first. Preserve all numbers. Flag anything ambiguous with [?]."
## Workflows
1. Draft prompt → test on 3 varied inputs → patch the failures into the prompt → save the working version.
2. Complex job: split into chained prompts with visible intermediate outputs you can inspect.
3. Regression: keep a 5-input test pack per important prompt; re-run after model switches.
4. Promote: draft → tested → pinned (SARAH persona/skill) so the team reuses the winner instead of re-deriving it.
## Templates
- Task prompt: Context / Task / Constraints / Output format / Examples / Definition of done.
```text
Context: <who this is for + what it will be used for>
Task: <the one job, verb-first>
Constraints: <length, tone, must-include, must-never-do, edge behavior>
Output format: <exact shape — headings, JSON schema, table columns>
Example: <1 input → 1 ideal output>
Done looks like: <how to verify in one glance>
```
- Agent brief: `Role / Workspace (allowed dirs/tools) / Rules (verify steps, forbidden moves) / Output (report format + done-report) / Escalation (when to stop and ask)`.
- JSON-output wrapper: `Respond with valid JSON matching this schema: {...}. No prose outside the JSON. If a field is unknown, use null — never invent it.`
```text
# Prompt test pack (5 inputs per important prompt — rerun on model switch)
# 1 typical  2 edge-case (missing field)  3 adversarial (conflicting facts)
# 4 longest realistic input  5 shortest/emptiest input
# Score each: formatOk? constraintsHeld? noInventions? If any fail, patch the prompt.
```
```text
# Miss-log row (the log writes your Constraints section after ~20 rows)
# 2026-10-13 / rewrite-brief / long-transcript / dropped numbers / added "preserve ALL numbers verbatim"
```
## Tools
- SARAH personas for reusable system prompts; skills for domain knowledge injection.
- Token counter / context preview before sending monsters; SARAH Command Center traces to see what the model actually received.
## Advanced
- Few-shot design: 1 positive + 1 edge-case example beats 5 near-identical ones; annotate WHY each example is right ("note the citation format") so the pattern transfers.
- Chain-of-density: draft → "list what's missing" → rewrite with gaps filled (2 passes) for summaries/briefs that need completeness without bloat.
- Self-critique pass: `Review your draft against these 3 criteria: <...>. Fix failures, then output only the fixed version.` — one extra call, large quality jump on important outputs.
- Role + stakes framing: "You are a senior <role> whose <output> will <real consequence>" focuses better than "act as"; keep it honest (no fake emergencies).
- Negative constraints: "Do NOT <common failure>" lines patched from real failures ( hallucinated citations, invented file paths, pasted-instead-of-file_write) — collect them from your own miss log.
- Model-specific: system/user split on chat APIs (rules in system, data in user); Claude XML tags, GPT markdown+JSON mode, local models shorter prompts (context discipline matters more).
- Troubleshooting: inconsistent format → examples disagree with the format spec (fix the example, not the rule); ignores a rule → rule buried mid-paragraph (move to Constraints bullets + repeat in Done); great once, bad on retry → temperature too high or missing seed, pin low temp for deterministic jobs; follows examples too literally → examples too similar, add a contrasting one.
- Miss log habit: one line per failure (`date / prompt / input-type / failure / patch added`) — after 20 lines the log writes your Constraints section for you.
- Length control: exact caps ("≤120 words", "3 bullets max") + truncation rule ("cut examples before cutting numbers") beat "be concise" every time.
## Documentation
- Provider prompting guides (Anthropic/OpenAI docs) for model-specific syntax.
- Anthropic prompt engineering: https://docs.anthropic.com/claude/docs/prompt-engineering
- OpenAI prompt engineering: https://platform.openai.com/docs/guides/prompt-engineering
